Answers for "python elif"

11

if else python

# IF ELSE ELIF 

print('What is age?')
age = int(input('number:')) # user gives number as input
if age > 18:
    print('go ahead drive')
elif age == 18:
    print('come personaly for test')
else:
    print('still underage')
Posted by: Guest on August-12-2020
16

elif python

The elif statement allows you to check multiple expressions for TRUE 
and execute a block of code as soon as one of the conditions evaluates
to TRUE. Similar to the else, the elif statement is optional. However,
unlike else, for which there can be at most one statement, there can 
be an arbitrary number of elif statements following an if.

if expression1:
   statement(s)
elif expression2:
   statement(s)
elif expression3:
   statement(s)
else:
   statement(s)
Posted by: Guest on April-17-2020
5

if statement in python

#Conditionals statements in python
#'=' conditionals statements
a = 123
b = 123

if(a==b):
  print('True')
  
#<, > conditionals statements

a = 2
b = 45

if(a<b):
  print('A is smaller than B')
Posted by: Guest on October-04-2020
8

if statement in python

answer = input(":")
if answer == "lol":
  print("haha")
else:
  print("not haha")
  exit()

please note that the exit() command is optional and is not necessary.
Posted by: Guest on June-17-2020
5

else if python

if expression1:
   statement(s)
elif expression2:
   statement(s)
elif expression3:
   statement(s)
else:
   statement(s)
Posted by: Guest on May-31-2020
0

python elif

if num > 0:
    print("Positive number")
elif num == 0:
    print("Zero")
else:
    print("Negative number")
Posted by: Guest on July-28-2021

Python Answers by Framework

Browse Popular Code Answers by Language