-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask2.py
More file actions
45 lines (39 loc) · 1.23 KB
/
task2.py
File metadata and controls
45 lines (39 loc) · 1.23 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
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 30 17:35:32 2018
@author: Ola
Python challenge by kodolamacz.pl
Task 2: The calculator
"""
def calculator():
decision = "t"
while decision=="t":
# Show the calculator's instruction
print("Podaj w oddzielnych wierszach liczbę, operację matematyczną: +,-,*,/,%, następnie kolejną liczbę:")
# Get the inout data
number1 = int(input())
operator = input()
number2 = int(input())
# Interpretation of the operator
if operator is "+":
wynik = number1 + number2
elif operator is "-":
wynik = number1 - number2
elif operator is "*":
wynik = number1 * number2
elif operator is "/":
wynik = number1 / number2
elif operator is "%":
wynik = number1 % number2
# Print the result
print("Twój wynik to: ", wynik)
# End or continue the calculations?
print("Chcesz wynikać kolejne działanie? Wpisz literę t lub n.")
decision = input()
if decision=="t":
continue
elif decision=="n":
break
# Call the function
if __name__ == "__main__":
calculator()