-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculator_py
More file actions
55 lines (32 loc) · 1.01 KB
/
Calculator_py
File metadata and controls
55 lines (32 loc) · 1.01 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
x = input("Enter the value of x ")
y = input("Enter the value of y ")
z = int(x) + int(y)
print(z)
#nesting the functions
x = int(input("Enter the value of x"))
y = int(input("Enter the value of y"))
print("Your answer is",x + y)
#using floats
x = float(input("Enter the value of x"))
y = float(input("Enter the value of y"))
print("Your answer is",x + y)
#Round floats to the nearest whole number
x = float(input("Enter the value of x"))
y = float(input("Enter the value of y"))
z = round(x + y)
print("Your answer is",z)
#Adding Separators
x = float(input("Enter the value of x"))
y = float(input("Enter the value of y"))
z = round(x + y)
print("Your answer is",(f"{z:,}"))
#Rounding to specific number of decimal points
x = float(input("Enter the value of x"))
y = float(input("Enter the value of y"))
z = round(x / y, 2)
print("Your answer is",z)
#Another way of rounding off
x = float(input("Enter the value of x"))
y = float(input("Enter the value of y"))
z = x / y
print("Your answer is",(f"{z:.2f}"))