Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Adding or Subtracting two numbers including Averaging the chosen number of numbers
- print("Would you like to Add or Subtract two numbers or find the Average of multiple numbers?")
- operator = input("Enter 'A' for Add, 'S' for Subtract or 'AVG' for Averages > ")
- if operator == "A" or operator == "S" or operator == "AVG":
- if operator == "A":
- input1 = input("Please enter your first number ")
- input2 = input("now enter your second number ")
- num1 = float(input1)
- num2 = float(input2)
- print("Add two numbers")
- result = num1 + num2
- output = str(result)
- print("The sum of " + input1 + " and " + input2 + " is " + output)
- elif operator == "S":
- input1 = input("Please enter your first number ")
- input2 = input("now enter your second number ")
- num1 = float(input1)
- num2 = float(input2)
- print("Subtract two numbers")
- result = num1 - num2
- output = str(result)
- print("The subtraction of " + input1 + " and " + input2 + " is " + output)
- elif operator == "AVG":
- how_many = input("How many numbers> ")
- how_many = int(how_many)
- total = 0
- for number_count in range(how_many):
- number = input("Enter number " + str(number_count) + "> ")
- total = total + int(number)
- result = total / how_many
- print("the average = " + str(result))
- else:
- print("Try again and select 'A' / 'P' or 'AVG ")
- print("Bye")
Advertisement
Add Comment
Please, Sign In to add comment