17
loading...
This website collects cookies to deliver better user experience
if (expression):
statement(s)
x, y = 34, 98
If (y>x):
result = "x is less than y."
print(result)
print("Welcome to TechGeekBuzz!")
x is less than y.
Welcome to TechGeekBuzz!
if (expression):
statement(s)
else:
statement(s)
a = 23
if (a > 20):
print("a is greater than 20.")
else:
print("a is less than 20.")
print("Welcome to TechGeekBuzz!")
a is greater than 20.
Welcome to TechGeekBuzz!
if (expression):
statement(s)
elif (expression):
statement(s)
else:
statements(s)
n = 5
if (n<0):
print("n is a negative number")
elif (n==0):
print("n is zero")
else:
print("n is a positive number")
print("Welcome to TeckGeekBuzz!")
n is a positive number.
Welcome to TechGeekBuzz!
if (expression):
if (expression):
statement(s)
else:
statement(s)
else:
statement(s)
p = 20
if (p>0):
#First if
if (p<30):
print("p is smaller than 30.")
#Nested if
#The below 'if' statement gets executed only
#if the above one holds true
if (p<15):
print("p is smaller than 15 too.")
else:
print("p is greater than 15.")
else:
print("p is a negative number.")
print("Welcome to TechGeekBuzz!")
p is smaller than 30.
p is greater than 15.
Welcome to TechGeekBuzz!
if (expression):
statement(s)
elif (expression):
statements(s)
elif (expression):
statement(s)
.
.
.
else:
statement(s)
marks = 95
if (marks<35):
print("Fail")
elif (marks>35 and marks<60):
print("Second Class")
elif (marks>60 and marks<80):
print("First Class")
else:
print("Distinction")
Distinction
If condition: statement
i = 10
If i<20:
print("i is less than 20.")
i is less than 20.
statement_when_True if condition else statement_when_False
i = 20
print(True) if i<15 else print(False)
False