10.3k views
4 votes
Accepting a sequence of arbitrary length 1. Write a function that adds the given numbers together and prints the sum. 2. Then add any other numbers that were sent to the arbitrary number of arguments and print the results HINT: * is needed for arbitrary number of arguments

User Ruddra
by
4.3k points

1 Answer

2 votes

Answer:

def _main_():

print('Are you Sure you want to quit ? y/n')

#take user input

user_input=input()

if user_input=='n':

while(user_input!='q'):

#Provide option on the User Screen

print('Welcome to the fitness center. What would you like to do?')

print('[1] Enter 1 to take a bike ride.')

print("[2] Enter 2 to go for a run.")

print("[3] Enter 3 to climb a mountain.")

print("[4] Enter 4 to go swimming.")

print('[q] Enter q to Quit!.')

#Simple if Else

choice=input("\\What would you like to do? ")

if choice=='1':

print("\\ Here's your bike. Grab a helment from the rack. Have fun!\\")

elif choice == '2':

print("\\ Here are some sneakers. Run fast!\\")

elif choice == '3':

print("\\ Here's a map. Can you leave a trip plan for us?\\")

elif choice == '4':

print("\\ Don't pee in the pool. Good Luck!\\")

elif choice == 'q':

print("\\ Thanks for playing. See you later.\\")

else:

print("\\ I don't understand that choice, please try again. \\")

user_input=choice

#Function for printing favorite color

def name(name,color):

print(name+"'"+' '+'favorite color is '+color)

def phone(brand,model):

print(brand+' '+model)

def arbitary(*argv):

li=[]

for i in argv:

li.append(i)

print(sum(li))

name('abhi','blue')

name('sunny','black')

name('rahul','silver')

phone('iphone','8 plus')

phone('samsung','Note 3')

phone('xiomai','8')

arbitary(1,2,3)

arbitary(3,5)

Step-by-step explanation:

The program function will perform these functions;

Take in a sequence of arbitrary length.

Write a function that adds the given numbers together and prints the sum.

Then add any other numbers that were sent to the arbitrary number of arguments and print the results

User Timedt
by
4.6k points