# Untitled

Feb 6th, 2023
624
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import math
2.
3.
5.     return x + z
6.
7. def subtract(x, z):
8.     return x - z
9.
10. def multiply(x, z):
11.     return x * z
12.
13. def divide(x, z):
14.     return x / z
15.
16. def percent(x, z):
17.     return x % z
18.
19. def power(x, z):
20.     return math.pow(x, z)
21.
22. def square_root(x):
23.     return math.sqrt(x)
24.
25. def Average():
26.     range1 = input("Enter Loop Count: ")
27.     sum = 0.0
28.     for i in range(range1):
29.         print range1-i-1,"Left"
30.         num = input("Give number: ")
31.         sum = sum+num
32.     print "Average of", sum, "is:", float((sum)/range1)
33.
35. print ("2 | Subtract")
36. print ("3 | Multiply")
37. print ("4 | Divide")
38. print ("5 | Percent (%)")
39. print ("6 | Power")
40. print ("7 | Square Root")
41. print ("8 | Find Average")
42.
43. choice = input("Enter choice| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |: ")
44.
45. if choice in (1, 2, 3, 4, 5):
46.     num1 = float(input("Enter first number: "))
47.     num2 = float(input("Enter second number: "))
48.
49.     if choice == 1:
51.
52.     elif choice == 2:
53.         print num1,"-",num2,"=", subtract(num1,num2)
54.
55.     elif choice == 3:
56.         print num1,"*",num2,"=", multiply(num1,num2)
57.
58.     elif choice == 4:
59.         print num1,"/",num2,"=", divide(num1,num2)
60.
61.     elif choice == 5:
62.         print num1,"%",num2,"=", percent(num1,num2)
63.
64.     else:
65.         print ("Invalid input")
66.
67. elif choice == 6:
68.     num1 = float(input("Enter first number: "))
69.     num2 = float(input("Enter second number: "))
70.     print num1, "**", num2, "=", power(num1,num2)
71.
72. elif choice == 7:
73.     num1 = float(input("Enter number: "))
74.     print "Square Root of", num1, "is:", square_root(num1)
75.
76. elif choice == 8:
77.     Average()
78.
79. else:
80.     print ("Invalid input")