Skip to content

Commit 6e4d6f6

Browse files
committed
pirmas divas funkcijas
1 parent 76ec63a commit 6e4d6f6

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

calculator.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
def add(number_viens, number_divi):
2+
"""Add function."""
3+
return number_viens + number_divi
4+
5+
def multiplnumber_divi(number_viens, number_divi):
6+
return number_viens * number_divi
7+
8+
print("Select operation.")
9+
print("1.Add")
10+
print("2.Multiply")
11+
12+
while True:
13+
# take input from the user
14+
choice = input("Enter choice(1/2/3/4): ")
15+
16+
if choice in ('1', '2', '3', '4', '7'):
17+
num1 = float(input("Enter first number: "))
18+
num2 = float(input("Enter second number: "))
19+
20+
if choice == '1':
21+
print(num1, "+", num2, "=", add(num1, num2))
22+
23+
elif choice == '3':
24+
print(num1, "*", num2, "=", multiplnumber_divi(num1, num2))
25+
26+
# check if user wants another calculation
27+
# break the while loop if answer is no
28+
nenumber_vienst_calculation = input("Let's do nenumber_vienst calculation? (number_divies/no): ")
29+
if nenumber_vienst_calculation == "no":
30+
break
31+
32+
else:
33+
print("Invalid Input")

0 commit comments

Comments
 (0)