-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
130 lines (97 loc) · 3.3 KB
/
main.py
File metadata and controls
130 lines (97 loc) · 3.3 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import math
#Calculator lvl 1
x = input("Enter a number: ")
y = input("Enter another number: ")
# Convert inputs to floats
x = float(x)
y = float(y)
# Perform calculations
sum_result = x + y
diff_result = x - y
prod_result = x * y
quot_result = x / y if y != 0 else "Division by zero error"
# Display results
print("Sum:", sum_result)
print("Difference:", diff_result)
print("Product:", prod_result)
print("Quotient:", quot_result)
# # Calculator lvl 2
# x = input("Enter a function: ")
# if x == "add":
# y = float(input("Enter 1st number: "))
# z = float(input("Enter 2nd number: "))
# print("Sum:", y+z)
# if x == "subtract":
# y = float(input("Enter 1st number: "))
# z = float(input("Enter 2nd number: "))
# print("Difference:", y-z)
# if x == "multiply":
# y = float(input("Enter 1st number: "))
# z = float(input("Enter 2nd number: "))
# print("Product:", y*z)
# if x == "divide":
# y = float(input("Enter 1st number: "))
# z = float(input("Enter 2nd number: "))
# print("Quotient:", y/z if z != 0 else "Division by zero error")
# if x == "power" or "exponent":
# y = float(input("Enter base: "))
# z = float(input("Enter exponent: "))
# print("Result:", math.pow(y, z))
# if x == "sqrt" or x == "square root":
# y = float(input("Enter a number: "))
# print("Result:", math.sqrt(y))
# if x == "log" or x == "logarithm":
# y = float(input("Enter a number: "))
# print("Result:", math.log(y))
# if x == "sin" or "cos" or "tan":
# y = input("Degrees of radians? ")
# if y == "degrees":
# y = (y/180)*math.pi
# if x == "sin":
# print("Result:", math.sin(y))
# if x == "cos":
# print("Result:", math.cos(y))
# if x == "tan":
# print("Result:", math.tan(y))
# if y == "radians":
# y = float(input("Enter a number: "))
# if x == "sin":
# print("Result:", math.sin(y))
# if x == "cos":
# print("Result:", math.cos(y))
# if x == "tan":
# print("Result:", math.tan(y))
#Level 3 calculator
# while True:
# x = input()
# if '+' in x:
# side = x.split('+')
# print("=", float(side[0]) + float(side[1]))
# if '-' in x:
# side = x.split('-')
# print("=", float(side[0]) - float(side[1]))
# if '*' in x:
# side = x.split('*')
# print("=", float(side[0]) * float(side[1]))
# if '/' in x:
# side = x.split('/')
# print("=", float(side[0]) / float(side[1]) if float(side[1]) != 0 else "Division by zero error")
# if '^' in x:
# side = x.split('^')
# print("=", math.pow(float(side[0]), float(side[1])))
# if 'sqrt' in x:
# side = x.split('sqrt')
# print("=", math.sqrt(float(side[1])))
# if 'log' in x:
# side = x.split('log')
# print("=", math.log(float(side[1])))
# if 'sin' in x or 'cos' in x or 'tan' in x:
# if 'sin' in x:
# side = x.split('sin')
# print("=", math.sin(math.radians(side[1])))
# if 'cos' in x:
# side = x.split('cos')
# print("=", math.cos(math.radians(side[1])))
# if 'tan' in x:
# side = x.split('tan')
# print("=", math.tan(math.radians(side[1])))