Search
 
SCRIPT & CODE EXAMPLE
 

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.
Comment

PREVIOUS NEXT
Code Example
Python :: numpy add to same index multiple times 
Python :: Crop Image as Circle with transparent background 
Python :: add js file in web.assets_backend 
Python :: python groupby 1d array 
Python :: backslashing in an interactive session in python 
Python :: python class optional arguments 
Python :: Print Multiple Variables 
Python :: smallest string with a given numeric value 
Python :: use python logging to log user ips+time in a file whenever a request comes to the server, this should be done in a custom middleware. 
Python :: csv file python 
Python :: check if a PID exists on a UNIX based system 
Python :: accessing 2d list in python 
Python :: python write multiline string to file 
Python :: python too many values to unpack 
Python :: Comparing Sets with issubset() Function in python 
Python :: How to subtract all the numbers in a list from the first number? 
Python :: python input() google suche 
Python :: python yield async await 
Python :: convert set to list python time complexity method 1 
Python :: python enum key string get 
Python :: generate a hash/secret python 
Python :: Python List insert() add element at designated place 
Python :: how to detect if a key was press down 
Python :: python Access both key and value using iteritems() 
Python :: images in pygame 
Python :: Convert torch.nn.Embedding layer to numpy array 
Python :: filter titlecase django 
Python :: c# script for download music from telegram channel 
Python :: use ipython magic in script 
Python :: python numpy read from stdin 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =