❮ Previous Next ❯

Python elif or nested if statement


Lets see an example for better clarity.
name=input("name?")
if(name=="Lingaraj"):
print("The name entered is",name)
elif(name=="Sradha"):
print("The name enterd is",name)
elif(name=="Priyambada"):
print("The name entered is",name)
else:
print("Invalid name")

python elif
Example:
#program to find largest of given 3 numbers from the keyboard
n1=eval(input("Enter first number:"))
n2=eval(input("Enter first number:"))
n3=eval(input("Enter first number:"))
if n1>n2 and n1>n3:
print("largest number is:",n1)
elif n2>n3:
print("largest number is:",n2)
else:
print("largest number is:",n3)

python elif output
❮ Previous Next ❯

Follow Us




  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved