Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python if statement

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 by codefreelance.net #
 
PREVIOUS NEXT
Tagged: #python #statement
ADD COMMENT
Topic
Name
5+3 =