Im new to python and i made this i want to know how to interact with it like a ui or something

Viewed 29

I would want this code to have an ui or an interface i can use. My question is what to learn to make this into something that a person can interact with. Also is this a good code for a beginner.

#_______________________________________________________________________________inputs from keyboards
foodtype= str(input("What type of Food did you eat choose from the following \n Burger \n Pizzaslice \n Popcorn \n Enter food here= ")) 
pecies_consummed = int(input("how many grams of the " +foodtype +" did you consume? \n Enter grams here= "))
#______________________________________________________________________________________values for stuff
#calories per gram
Burger= 3
Pizzaslice= 3 
Popcorn= 4
kilometre= 62
#_______________________________________________________________________________________________________functions
def burger_calories(pecies_consummed):
    calories_consumed= pecies_consummed*Burger
    print(calories_consumed)

def pizza_calories(pecies_consummed):
    calories_consumed= pecies_consummed*Pizzaslice
    print(calories_consumed)

def popcorn_calories(pecies_consummed):
    calories_consumed= pecies_consummed*Popcorn
    print(calories_consumed)

def calories_burned_burger(pecies_consummed):
    calories_consumed= pecies_consummed*Burger
    burn_calori= calories_consumed//kilometre
    print("you need to walk this many km to burn it off")
    print(burn_calori)
    
def calories_burned_pizzaslice(pecies_consummed):
    calories_consumed= pecies_consummed*Pizzaslice
    burn_calori= calories_consumed//kilometre
    print("you need to walk this many km to burn it off")
    print(burn_calori)
    
def calories_burned_popcorn(pecies_consummed):
    calories_consumed= pecies_consummed*Popcorn
    burn_calori= calories_consumed//kilometre
    print("you need to walk this many km to burn it off")
    print(burn_calori)

#_________________________________________________________________________________________________________________________calories calculted
if foodtype == "Burger":
    print("This many calories were consumed while eating burgers")
    burger_calories(pecies_consummed)
    
elif foodtype == "Pizzaslice":
    print("This many calories you consumed while eating pizzaslices") 
    pizza_calories(pecies_consummed)

elif foodtype == "Popcorn":
    print("This many calories you consumed with your popcorn")
    popcorn_calories(pecies_consummed)
    
else:
    print("succesfully failed at eating")
#_________________________________________________________________________________________________________________________How much will take to burn it off
if foodtype == "Burger":
     calories_burned_burger(pecies_consummed)
    
        
elif foodtype == "Pizzaslice":
    calories_burned_pizzaslice(pecies_consummed)
    

elif foodtype == "Popcorn":
    calories_burned_popcorn(pecies_consummed)
    
else:
    print("and at walking aswell daam")

I would want this code to have an ui or an interface i can use. My question is what to learn to make this into something that a person can interact with. Also is this a good code for a beginner.

1 Answers

Actually with that code you already have a user interface more specifically a Command Line Interface (CLI), or do you mean by that can you turn your code into more user friendly interface or nowaday known as Graphical User Interface (GUI)?

yes absolutely you could, for example in python you can use framework called Flask it is a great tool for making website with python you'll learn an MVC concept and etc, but before jump dive into right into flask i recommend you learn the basic foundation of what created a website: HTML, CSS, Javascript.

Related