Answers for "python if elseif"

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
1

else if python

name = input("What's your name? n") # Asks user for a name

# Following if order:
# first program checks if the if is true
# next program lists down the elifs (or else ifs) in the order 
# in which they are listed
# Lastly, if there is an else, program does whatever is inside
# of there.

if name == "Aguy12": # First checks if they answered "Aguy12"
  print("Wait a second...")
elif name == "Aguy11": # Then checks if they answered with "Aguy11"*
  print("Now that's definitely not true")
else: # If none of those are true greets the person accordingly
  print(f"Hello, {name}!")
  
# * ONLY IF THE IF STATEMENT IS NOT TRUE
Posted by: Guest on January-23-2021

Python Answers by Framework

Browse Popular Code Answers by Language