Skip to content

Commit fadce93

Browse files
committed
Added arithmetic_operators.py to Python-Basic-to-Advance repo
1 parent 6611d0d commit fadce93

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

arithmetic_operators.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
a = 10
2+
b = 2
3+
4+
print("Div=", a/b) # True Division → always float → 5.0
5+
print("Div=", a//b) # Floor Division → 5
6+
7+
print("Mul=", 5*2) # Multiplication → 10
8+
print("Square of 2 is=", 2**2) # 2^2 → 4
9+
print("Cube of 2 is=", 2**3) # 2^3 → 8
10+
print("3 raised power 4=", 3**4) # 3^4 → 81
11+
12+
"""
13+
PEMDAS (Operator Precedence in Python)
14+
P = Parentheses ()
15+
E = Exponent **
16+
M = Multiplication *
17+
D = Division /
18+
F = Floor Division //
19+
Mod = Modulus %
20+
A = Addition +
21+
S = Subtraction -
22+
L-> R
23+
"""
24+
25+
expression = 5 + 2*3 - 1 + 10/5#5+6-1+2.0->11-1+2.0->10+2.0->12.0
26+
print(expression)
27+
28+
# Calculate BMI
29+
weight = float(input("Enter weight (kg): "))
30+
height = float(input("Enter height (m): "))
31+
32+
print("BMI =", (weight / (height**2)))
33+
print("BMI =", round(weight / (height**2), 1))

0 commit comments

Comments
 (0)