Answers for "elseif in python"

3

how to use if else in python

print("Welcome to Rolercoster rider")
print()
#taking input of your hight
Your_hight = int(input("What is Your hight:- "))
#if condition 
if Your_hight >= 120:
    print("You are good to go to the roller coster")
else:
    print("Grow taller to go to the rolercoster")
Posted by: Guest on July-31-2021
5

python if else

# The if,elif,else statements check if something is True
# example
if 10 > 5:
	print("Ten is greater than five")

#but let's say we write
if 10 < 5:
	print("Ten is less than five")
#then this condition wouldn't be true
#so we create an "else" statement
if 10 < 5:
	print("Ten is less than five")
else:
  	print("Ten is greater than five")

#this will print "Ten is greater than five"
# because in the if statement it checks if something is true
# we wrote 'if 10 < 5' and it's not true
# so in case the 'if' condition evaluates to false
# it executes another command

#now, the 'elif' statement
# this will check for another thing after the if statement
#example
if 10 < 5:
  	print("Ten is less than five")
elif 10 > 5:
	print("Ten is greater than five")
# here we check if 10 is less than five
# then the statement evaluated to false because 10 is greater than 5
# so the program checked with the 'elif' (that means 'Else if')
# if the statement was true, and it was so it executed the command

#we can add as many elif statements as we want in our program
# but they always need to start with an 'if' statement
# and we can make only ONE 'else' statement at the end
# let's add an 'else' statement to the previous program
if 10 < 5:
  	print("Ten is less than five")
elif 10 > 5:
	print("Ten is greater than five")
else:
  	print("Ten isn't greater or less than five")
# in this case it will print 'Ten is greater than five'
# hope this helped
Posted by: Guest on September-24-2020
2

Python If ... Else

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")
Posted by: Guest on February-01-2021
3

else if python

word = input('Word: ') # This will ask you to print a word

if word == 'hello': # <- If your response is: 'hello'
	print('world') # <- It will output: 'world'
    
elif word == 'world': # If the response is: 'world'
	print("Hey, that's my line >:(") # It will print this
else:
	print("Hey buster you gonna say hello or not?")
# If sombody prints ANYTHING ELSE other than 'hello' or 'world'
# It will output that print statment above!

#Hope this helped you!
Posted by: Guest on December-24-2020
2

if else python

# IF ELSE ELIF
age=int(input("Enter your age:"))
if age<=18:
  print("sorry your are not eligible for vote")
elif age>=18:
  print("u are eligible for vote")
else:
  print("in some how the previou's condition fails else part will run")
Posted by: Guest on January-01-2021
6

python if elif

num = 20
if num > 30:
  print("big")
elif num == 30:
  print("same")
else:
  print("small")
#output: small
Posted by: Guest on May-09-2020

Python Answers by Framework

Browse Popular Code Answers by Language