Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- calc = []
- # function
- def calculation(operation):
- how_many = input("How many numbers? ")
- how_many = int(how_many)
- total = (0)
- for user_number in range(how_many):
- number = input("Enter number " + str(user_number + 1) + ": ")
- calc.append(number)
- len(calc)
- result = str(len(calc))# Function "len"
- total = total + int(number)
- if operation == "total":
- print ("I have " + result + " numbers in my list")
- print("The sum total of numbers is " + str(total))
- else:
- result = total / how_many
- print("The average is " + str(result))
- return
- # main
- print("I am Eley, your personal bot.")
- users_name = input("What is your name?")
- print("Hi "+users_name + ", nice to meet you. ")
- print("Let's do some maths:")
- # loop
- finished = False
- while finished == False:
- operation = input("What operation would you like 'total' or 'average'? : ")
- if operation in ["total","average"]:
- calculation(operation)
- elif operation == "bye":
- finished = True
- print("See you again")
- else:
- print("I'm sorry, I don't understand " + operation)
Advertisement
Add Comment
Please, Sign In to add comment