-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconditions_task.py
More file actions
63 lines (53 loc) · 1.26 KB
/
conditions_task.py
File metadata and controls
63 lines (53 loc) · 1.26 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
"""
Output message, so the user know what is the code about
and some instructions
Condition_Task
author: Abdullah Alhasan
"""
print("""
Welcome to Abdullah's Calculator!
Please choose vaild numbers and an operator to be calculated...
Calculation example:
first number [operation] second number = results
""")
calc_results = 0
num1= input("Input first number: ")
try:
num1 = int(num1)
except ValueError:
print("Invaild values!")
else:
num2= input("Now, second number: ")
try:
num2 = int(num2)
except ValueError:
print("Invaild values!")
else:
op = input("""Please type in the operator symbol what is between the [..]:
[ + ]: Addition
[ - ]: Substraction
[ x ]: Multiplying
[ / ]: Division
Type here: """)
if op == "+":
results = num1 + num2
print("""
{} {} {} = ...
answer is {} """.format(num1,op,num2,results))
elif op == '-':
results = num1 - num2
print("""
{} {} {} = ...
answer is {} """.format(num1,op,num2,results))
elif op.lower() == "x":
results = num1 * num2
print("""
{} {} {} = ...
answer is {} """.format(num1,op,num2,results))
elif op == "/":
results = num1 / num2
print("""
{} {} {} = ...
answer is {} """.format(num1,op,num2,results))
else:
print("Operator is invaild!")