Skip to content

Commit c1536bc

Browse files
author
VaradRege
authored
Added to code
Just edited for beginners Thanks.
1 parent e3f096e commit c1536bc

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Simple Calculator.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1+
""" Python Simple Calculator """
2+
3+
# Setting all values to 0 (empty, nothing)
14
output = 0
25
num1 = ""
36
operation = ""
47
num2 = ""
8+
9+
# Asking What numbers you want using print command
510
num1 = input("Hello, What is your First Number?\n")
611
operation = input("Operation (+, -, *, /)?\n")
712
num2 = input("Your Second Number?\n")
813

14+
# Setting asked numbers to float, so that it would give an exact answer
915
floatnum1 = float(num1)
1016
floatnum2 = float(num2)
1117

18+
# If selected operation is the following then do the following
1219
if operation == "+":
1320
output=floatnum1+floatnum2
1421
if operation == "-":
@@ -19,5 +26,7 @@
1926
output=floatnum1/floatnum2
2027
if operation == "+" or operation == "-" or operation == "/" or operation == "*":
2128
print("Your Answer: "+str(output))
29+
30+
# If none of above is the operation then give a error
2231
else:
2332
print("Your operation is invalid, please try again")

0 commit comments

Comments
 (0)