-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx2.py
More file actions
110 lines (104 loc) · 3.89 KB
/
Ex2.py
File metadata and controls
110 lines (104 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
from math import *
first_input = input("Enter the first number: ")
if first_input.isdigit() or first_input.__contains__("."):
op = input("choose the operator:\n1_+\n2_-\n3_*\n4_/\n5_^\n6_%\n")
if op == "1" or op == "+":
second_input = input("Enter the second number: ")
if second_input.isdigit() or second_input.__contains__("."):
result = float(first_input) + float(second_input)
print(result)
op2 = input("Extra choices:\n1_Rounded the number\n2_Floor the number\n3_Exit\n")
if op2 == "1":
print(round(result))
elif op2 == "2":
print(floor(result))
elif op2 == "3":
print(result)
else:
print("Error")
else:
print("Error")
elif op == "2" or op == "-":
second_input = input("Enter the second number: ")
if second_input.isdigit() or second_input.__contains__("."):
result = float(first_input) - float(second_input)
print(result)
op2 = input("Extra choices:\n1_Rounded the number\n2_Floor the number\n3_Exit\n")
if op2 == "1":
print(round(result))
elif op2 == "2":
print(floor(result))
elif op2 == "3":
print(result)
else:
print("Error")
else:
print("Error")
elif op == "3" or op == "*":
second_input = input("Enter the second number: ")
if second_input.isdigit() or second_input.__contains__("."):
result = float(first_input) * float(second_input)
print(result)
op2 = input("Extra choices:\n1_Rounded the number\n2_Floor the number\n3_Exit\n")
if op2 == "1":
print(round(result))
elif op2 == "2":
print(floor(result))
elif op2 == "3":
print(result)
else:
print("Error")
else:
print("Error")
elif op == "4" or op == "/":
second_input = input("Enter the second number: ")
if second_input.isdigit() or second_input.__contains__("."):
result = float(first_input) / float(second_input)
print(result)
op2 = input("Extra choices:\n1_Rounded the number\n2_Floor the number\n3_Exit\n")
if op2 == "1":
print(round(result))
elif op2 == "2":
print(floor(result))
elif op2 == "3":
print(result)
else:
print("Error")
else:
print("Error")
elif op == "5" or op == "^":
second_input = input("Enter the second number: ")
if second_input.isdigit() or second_input.__contains__("."):
result = float(first_input) ** float(second_input)
print(result)
op2 = input("Extra choices:\n1_Rounded the number\n2_Floor the number\n3_Exit\n")
if op2 == "1":
print(round(result))
elif op2 == "2":
print(floor(result))
elif op2 == "3":
print(result)
else:
print("Error")
else:
print("Error")
elif op == "6" or op == "%":
second_input = input("Enter the second number: ")
if second_input.isdigit() or second_input.__contains__("."):
result = float(first_input) % float(second_input)
print(result)
op2 = input("Extra choices:\n1_Rounded the number\n2_Floor the number\n3_Exit\n")
if op2 == "1":
print(round(result))
elif op2 == "2":
print(floor(result))
elif op2 == "3":
print(result)
else:
print("Error")
else:
print("Error")
else:
print("Error")
else:
print("Error")