Skip to content

Commit adf7d9c

Browse files
Add files via upload
1 parent ebcacf2 commit adf7d9c

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

python_calculator.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
def calculator():
2+
if choose == 5:
3+
quit() #Exit Program
4+
elif choose >=6 or choose <= 0:
5+
print("\nOops! There not an option with this number to select.\n ")
6+
return #Finish Function
7+
number1 = float(input("\nInsert the First Number: "))
8+
number2 = float(input("Insert the Second Number: "))
9+
if choose == 1:
10+
if number1 == 0 or number2 == 0:
11+
print("\nIf you add 0 you will receive the same value that you had get before.\n")
12+
return
13+
resultado = number1+number2
14+
print("\n{:.2f} + {:.2f} = {:.2f}\n".format(number1, number2, resultado))
15+
elif choose == 2:
16+
if number1 == 0 or number2 == 0:
17+
print("\nYou cant use 0 to subtraction method because there's no value to subtract.\n")
18+
return
19+
resultado = number1 - number2
20+
print("\n{:.2f} - {:.2f} = {:.2f}\n".format(number1, number2, resultado))
21+
elif choose == 3:
22+
if number1 == 0 or number2 == 0:
23+
print("\nEvery multiply to 0 is equal to 0.\n")
24+
return
25+
resultado = number1 * number2
26+
print("\n{:.2f} * {:.2f} = {:.2f}\n".format(number1, number2, resultado))
27+
elif choose == 4:
28+
if number1 == 0 or number2 == 0:
29+
print("\nYou cant use 0 to division method because it will return the same number.\n")
30+
return
31+
resultado = number1 / number2
32+
print("\n{:.2f} / {:.2f} = {:.2f}\n".format(number1, number2, resultado))
33+
active = True
34+
while active == True:
35+
print("What is Your Choose?"
36+
"\n1 - Addition"
37+
"\n2 - Subtraction"
38+
"\n3 - Multiplication"
39+
"\n4 - Division"
40+
"\n5 - Exit")
41+
choose = int(input("\n"))
42+
calculator()

0 commit comments

Comments
 (0)