Question : python conditions
Answered by : sxnsei-dev
# 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')
Source : | Last Update : Wed, 27 Apr 22
Question : conditional and in python
Answered by : jessica-koekemoer
if 1 > 2 and 4 < 10: print("condition not met")
if 4 < 10 or 1 < 2: print("condition met")
Source : https://opentechschool.github.io/python-beginners/en/logical_operators.html | Last Update : Tue, 01 Jun 21
Question : python conditionals
Answered by : successful-stork-hj0afrf6kxf3
a == b (is equal)
a != b (is not equal)
a < b (a is less than b)
a > b (a is greater than b)
a <= b (a is less than or equal to b)
a >= b (a is greater than or equal to b)
Source : http://127.0.0.1:8000/guides/conditionals.html | Last Update : Fri, 30 Jul 21
Question : python conditional statement
Answered by : jerome-scott
num = 1
if num == 1: print("num is 1"))
elif num == 2: print("num is 2")
else: print('invalid number')
# output num is 1
# if the conditional is true the left side of side the expression is resolved else the right side is resolved
print("num is 2") if num == 2 else print("num is 1")
# output num is 1
Source : https://codefreelance.net/python_cheatsheet.html | Last Update : Fri, 02 Sep 22
Question : python conditions
Answered by : roy-miller
Stack Overflow requires cookies for authentication -- are your browser cookies enabled for this domain?
yes
Source : https://stackoverflow.com/users/openidconfirm | Last Update : Wed, 02 Nov 22