Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

or statement python

if x==1 or y==1:
  print(x,y)
Comment

python or

x = 1
y = 10

if x%2 == 0 or y%2 == 0:
  print(x%2)
  
#Output#
#1
Comment

python or

# If a is truthy,
# returns a, otherwise b

# Use bool(<value>) to know whether a value
# is truthy or falsy

#  a  b | True | False
# -------+------+-------
#  True  | a    | a
# -------+------+-------
#  False | b    | b

print(True or True) # True
print(True or False) # True
print(False or False) # False

print(1 or 0) # 1 is truthy -> 1
print([] or {}) # [] is falsy -> {}
print([] or {} or ()) # "([] or {}) or ()" -> "{} or ()" -> "()"
print([1, 2] or (3, 4)) # [1, 2] is true -> [1, 2]
Comment

PREVIOUS NEXT
Code Example
Python :: Iterate through string in python using for loop and rang 
Python :: sum values in django models and insert value in model field 
Python :: Django serializer, 
Python :: matplotlib.pyplot 
Python :: python *args and **kwargs 
Python :: def calc_mean_mode(df, column_name) 
Python :: drf not getting form 
Python :: if start and end point is same in range function python 
Python :: python telegram 
Python :: pandas series add word to every item in series 
Python :: dockerize django app 
Python :: pop function in python 
Python :: how to see truncated values in jupyter notebook 
Python :: python select file in folder given extension 
Python :: Shuffle the data before GridSearchCV 
Python :: matplotlib remove white lines between contour 
Python :: gunicorn django static files 
Python :: how to list gym envirolments 
Python :: python unittest setUpClass 
Python :: pandas.describe per group 
Python :: sum the contents of a list python 
Python :: undef variable 
Python :: path selecter in tkinter 
Python :: how to capitalize words in python 
Python :: logistic regression python family binomial 
Python :: Python __floordiv__ 
Python :: python create list of empty lists 
Python :: store in a variable the ocntent of a file python 
Python :: how to send image to template thats not in static flask 
Python :: graphics.py how to make a button 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =