-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic add calculator.py
More file actions
169 lines (122 loc) · 4.18 KB
/
basic add calculator.py
File metadata and controls
169 lines (122 loc) · 4.18 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#-------------------------------------------------------------------------------
# Name: module2
# Purpose:
#
# Author: user
#
# Created: 28/03/2019
# Copyright: (c) user 2019
# Licence: <your licence>
#-------------------------------------------------------------------------------
num1=input('Please enter a number: ')
num2=input('Please enter another number: ')
result=float(num1)+float(num2)
print(result)
print("""Mathematical operator order is - BEDMAS
or PEDMAS""")
print("""print("BEDMAS" "=") will show , ("BEDMAS" "=") """)
print("BEDMAS" "=" """"Brackets, Exponents, Division,
Multiplication, Addition, Subtraction""")
print("""PEDMAS = Parenthecis (), Exponents **, Division /,
Multiplication *, Addition + , Subtraction - """)
print("""left to right or left associative rule
for * / - + operators""")
print(("print(6-3+2) =") + str(6-3+2))
print(("print(6-3+2) =") + str(6-3+2))
print(("print(6-3+2) =") + str(6-3+2))
print(("print(6/3*2) =") + str(6/3*2))
print("left to right or left associative rule for * / - + operators")
#----------------------
print("but for ** right to left or right associative rule for * / - + operators")
print(("print(2**3**2) =") + str(2**3**2))
print(("2+3")+ "=" + str(2+3))
print(2+(3-1))
print("(2+(3-1))"+ "=" + str(2+(3-1)))
print(9/3)
print(("9/3")+ "=" + str(9/3))
print(9/3.0)
print(("9/3.0")+ "=" + str(9/3.0))
print(9.0/3)
print(("9.0/3")+ "=" + str(9.0/3))
print(9*3)
print(("9*3")+ "=" + str(9*3))
print(9.0*3)
print(9*3.0)
print(("9*3.0")+ "=" + str(9*3.0))
print((9-1+2)+(9/3*3))
print(("((9-1+2)+(9/3*3))")+ "=" + str((9-1+2)+(9/3*3)))
print(("(((-9)-1+2)+(9/3*(-3)))")+ "=" + str(((-9)-1+2)+(9/3*(-3))))
print((-9)*(-3))
print(("(-9)*(-3)")+ "=" + str((-9)*(-3)))
print(("(-9)/(-3)")+ "=" + str((-9)/(-3)))
print(("-9/-3")+ "=" + str(-9/-3))
print(("-9*-3")+ "=" + str(-9*-3))
print("idleAllin2.py")
print("================03-03-2019=====================04-03-2019=========\n==========================\n=====================")
print(("10/3")+ "=" + str(10/3))
print(("-10/3")+ "=" + str(-10/3))
print(("10/-3")+ "=" + str(10/-3))
print(9.73800000000)
print(("9.73800000000")+ "=" + str(9.73800000000))
print(("9.738043625475237500")+ "=" + str(9.738043625475237500))
print(("9.73804362547523750082364862865821")+ "=" + str(9.73804362547523750082364862865821))
print(("10**3")+ "=" + str(10**3))
print((" Quotient of " ) + ( " 10//3 ")+ " = " + str(10//3))
print((" Remainder of " ) + ( " 10%3 " )+ " = " + str(10%3))
A=14
B=40
print(""" IF input is A=14 and B=40 then,
modolous // and remainder % is """)
print("print(A//B) = " , A//B)
print("print(A%B) = " , (A%B))
print('''
''')
a1=float(input("Enter the first number: "))
op=input("Enter the operator or sign : ")
b1=float(input("Enter the second number: "))
if op=="+":
print(str(a1),"+", str(b1), "=", a1+b1 )
elif op=="-":
print(str(a1),"-", str(b1), "=", a1-b1 )
elif op=="/":
print(str(a1),"/", str(b1), "=", a1/b1 )
elif op=="*":
print(str(a1),"*", str(b1), "=", a1*b1 )
elif op=="**":
print(str(a1),"**", str(b1), "=", a1**b1 )
elif op=="//":
print(str(a1),"//", str(b1), "=", a1//b1 )
elif op=="%":
print(str(a1),"%", str(b1), "=", a1%b1 )
else:
print("invalid operator or number")
print('''
print(eval(input()))
''')
print(eval(input()))
print('''
op=input( """please input a calculating or math operetion:
like 12+14 or 14*30 or 34//22 etc
""" )
print(eval(op))
''')
op=input( """please input a calculating or math operetion:
like 12+14 or 14*30 or 34//22 etc
""" )
print(eval(op))
print('''
''')
print('''
codex=input(''' please input your code by typing
copy paste will not work till now :
''' )
print(codex)
print("The above code that you typed - will give output")
exec(codex)
''')
codex=input(''' please input your code by typing
copy paste will not work till now :
''' )
print(codex)
print("The above code that you typed - will give output")
exec(codex)