Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

condition in python

# How conditions work
if condition:
	# if condition met
	# code here
elif condition2: # (else if) checked if the first condition is false
  	# if condition2 met
    # code here
elif condition3: # elif can be chained
    # if condition3 met
	# code here
else:
  	# if none of the conditions are met
    # code here

    
# example

if name == "bob": # ex. a == b (is a equal to b)
    print("the wifi password is 1234")
    
elif name == "jake": # if the first condition is not met python checks this one
    print("the secret formula is under the bed")

else: # if none of the conditions are met
    print("sorry i don't know who you are")

    
# Other Example
if age >= 18:
    print('You can go in')
else:
    print('you cannot pass, you are underage')
Comment

condition python

ensoleille = False
neige = True

if ensoleille:
   print("on va à la plage !")
elif neige:
   print("on fait un bonhomme de neige")
else:
   print("on reste à la maison !")
Comment

condition python

with_sun = True
in_week = False

if with_sun and not in_week:
   print("we go to the beach !")
elif with_sun and in_week:
   print("we go to work !")
else:
   print("we stay at home !")
Comment

condition python

avec_soleil = True
en_semaine = False

if avec_soleil and not en_semaine:
   print("on va à la plage !")
elif avec_soleil and en_semaine:
   print("on va au travail !")
else:
   print("on reste à la maison !")
Comment

PREVIOUS NEXT
Code Example
Python :: python while loop break 
Python :: close a file python 
Python :: shuffle text lines python 
Python :: get mode using python 
Python :: is_isogram 
Python :: pandas fillna with none 
Python :: replace nan 
Python :: extract value from tensor pytorch 
Python :: python single line function 
Python :: get particular columns from dataframe 
Python :: index duplicates python 
Python :: python indentation 
Python :: while True: 
Python :: python jinja2 from string 
Python :: if and else in python 
Python :: mysql store numpy array 
Python :: django sessions for beginners 
Python :: python syntax errors 
Python :: python tree 
Python :: python print values inside request.POST 
Python :: how to pop an exact number from a list in python 
Python :: ValueError: cannot reshape array of size 98292 into shape (16382,1,28) site:stackoverflow.com 
Python :: python array find lambda 
Python :: get height of image in pygame 
Python :: add image to pdf with python 
Python :: Python Tkinter Scale Widget 
Python :: selenium python tkinter 
Python :: python filter numbers from list 
Python :: Static Language Programmers 
Python :: remove all parentheses from string python 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =