If-elseif and else statement in Python programming allows you to control and check conditions and execute the specific block of code if the condition is true, otherwise, execute the else block.
num = int(input("Enter a number less than 10: "))
if num > 10: #if 'num' value is greater then 10 then
print("Entered value is greater then 10!") #print this.
elif num < 10: #if 'num' value is Less then 10 then
print("Entered value is Less then 10!") #print this.
else: #if not in above mean equal to 10 then
print("Entered value is Equal to 10") #print this.
n = input("Enter Ur Name: ")
if n.endswith("Ls"): #if 'n' value Ends with 'Ls' then
print("Hello HiLaLs") #print this.
elif n.startswith("Af"): #if 'n' value Starts with 'Af' then
print("Hello Afridi") #print this.
else: #if Not then
print("Invalid Entry") #print this.
num = input("Please Enter Ur Name: ")
if num == "HiLaLs": #if 'num' value equal to 'HiLaLs' then
print("Hi Programmer!") #print this.
elif num == "Nawaz": #else if 'num' value equal to 'Nawaz' then
print("Hi Web Developer") #print this.
elif num == "Amir": #else if 'num' value equal to 'Amir' then
print("Hi Network") #print this.
elif num == "Asad": #else if 'num' value equal to 'Asad' then
print("Hi DataBase") #print this.
else: #if not in above then
print("I Dont Know You") #print this.
val = input("Enter Ur Name: ")
if val == "HiLaLs" or val == "Amir": #if 'val' value Equal to 'HiLaLs' OR 'Amir'
print("Hi Programmer!") #then print this.
elif val == "Nawaz" or val == "Ali" or val == "Hedayat": #if 'val' value Equal
print("Hi Web Developer!") #to 'Nawaz' OR 'Ali' OR 'Hedayat' then print this.
elif val == "Sadam" or val == "Usman": #if 'val' value Equal to 'Sadam' or
print("Hi Networkers!") #'Usman' then print this.
else: #if not then
print("I Dont Know You") #print this.
num = int(input("Enter value from 1 to 3: "))
if num <= 3: #if 'num 'value is Less then or Equal to 3 then
if num ==1: #if 'num' value equal to 1 then
print("Entered value is 1") #print this.
elif num == 2: #if 'num' value equal to 2 then
print("Entered value is 2") #print this.
elif num == 3: #if 'num' value equal to 3 then
print("Entered value is 3") #print this.
else: #if not then
print("Entered value is Less then 1") #print this.
else: #if not then
print("Invalid Entry!") #print this.