522,524 views
19 votes
19 votes
Input two numbers and work out their sim, subtraction, multiplication, division, remainder, average and sum of the squares of the numbers.

User Eliko
by
3.1k points

1 Answer

21 votes
21 votes

def ultimate_math (num1, num2):

try:

array_num = [num1, num2]

print (num1 + num2)

print (num1 - num2)

print (num1 * num2)

print (num1 / num2)

print (num1 % num2)

print ((num1 + num2) / (len(array_num)))

print ((num1**2) + (num2**2))

except ValueError:

return "Invalid Input"

user_num1 = float (input (" Please enter a num: "))

user_num2 = float (input (" Please enter a second num: "))

print (ultimate_math (user_num1, user_num2))

User James Johnson
by
2.3k points