def get_data():
user_name = input(“Enter your name: ”)
user_age = int(input(“Enter your age: ”))
data_tuple = (user_name, user_age)
return data_tuple
Defines a subprogram called “get_data()” which will ask the user for their name and
age. As we want to send more than one piece of data back to the main program for other
parts of the program to use, we have combined them together. The return line can only
return a single value, which is why we combined the user_name and user_age variables
into a tuple (see page 58) called data_tuple.
Do'stlaringiz bilan baham: |