World's Best AI Learning Platform with profoundly Demanding Certification Programs
Designed by IITians, only for AI Learners.
Designed by IITians, only for AI Learners.
New to InsideAIML? Create an account
Employer? Create an account
Download our e-book of Introduction To Python
4.5 (1,292 Ratings)
559 Learners
Sulochana Kamshetty
a year ago
Sales = 66%
off sales = 200%
if b > a:
print("off sales is greater
than sales")
Output :- off
sales is greater than sales
If statement, without
indentation (will raise an error):
Sales = 33%
offsales = 200%
if b > a:
print("off sales is greater than sales") # you will get an error
a = 33
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
a = 200%
b = 33%
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
else:
print("a is greater than b")
a = 200
b = 33
if b > a:
print("b is greater than a")
else:
print("b is not greater than a")
One line if else statement:
a = 2
b = 330
print("A") if a > b else print("B")
One line if else statement, with 3 conditions:
a = 330
b = 330
print("A") if a > b else print("=") if a
== b else print("B")
Test if a is greater than b, AND
if c is greater than a:
a = 200
b = 33
c = 500
if a > b and c > a:
print("Both conditions are true")
Test if a is greater than b, OR
if a is greater than c:
a = 200
b = 33
c = 500
if a > b or a > c:
print("At least one of the conditions is true")
x = 41
if x > 10:
print("Above ten,")
if x > 20:
print("and also above 20!")
else:
print("but not above 20.")
a = 33
b = 200
if b > a:
pass