Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

using the return statement, defining a function, with input from the user.

#Asks for input from the user.
user = input('Are you male or female?')

#Gains the information needed to return the user value.
def user_gender(user):

    if user == 'female' or user == 'f' or user == 'fe':
        print('As a female, you need around 1,600 to 2,400 calories a day.')
        return

    elif user == 'male' or user == 'm' or user == 'ma':
        print('As a male, you need around 2,000 to 3,000 calories a day.')
        return

#runs defined function above.
user_gender(user)


#Output: Female
Are you male or female? female
As a female, you need around 1,600 to 2,400 calories a day.

#Output: Male
Are you male or female? male
As a male, you need around 2,000 to 3,000 calories a day.
 
PREVIOUS NEXT
Tagged: #return #defining #input
ADD COMMENT
Topic
Name
2+2 =