Python From Scratch: Website - Linkedin - Youtube - Logical Conditions
Python From Scratch: Website - Linkedin - Youtube - Logical Conditions
Website - https://petroleumfromscratchin.wordpress.com/
LinkedIn - https://www.linkedin.com/company/petroleum-from-scratch
YouTube - https://www.youtube.com/channel/UC_lT10npISN5V32HDLAklsw
Logical Conditions
# a > b
# a < b
# a == b
# a != b
# a <= b
# a >= b
a = 5
b= 5
c =8
print(a)
print(c)
5
8
print(a == b) # This is asking a question whether a and b has same value or not
True
print(a != b)
False
print(a>=c)
False
print(c>=a)
True
If statements
# method 1
# Method 2
Pass statement
x = 56
if x>56:
# let's say that i know that I want to use this conditon but I'm not sure what I want to print right now.
# If you leave it empty. It will give an error
# Hence, we use pass statement
x = 56
if x>56:
pass
Else Statement
else:
print('This is a normal pressure')
var = 25
if var>21:
print('Var is greater than 20')
else:
print('kjcsbiibv')
in keyword
if 'z' in xyz:
print('Character z is present in variable xyz')
else:
print('Character z is not present in variable xyz')
Space is present
/
1/30/2021 Python for O&G Lecture 14th and15th - If else statements, in, and/or operators - Colaboratory
nothing
nothing
if drill_rate:
print(f'Drill rate of well is {drill_rate} ft/hr') # string formatting
else:
/
print('No Input Given')
1/30/2021 Python for O&G Lecture 14th and15th - If else statements, in, and/or operators - Colaboratory
print( No Input Given )
if drill_rate:
print(f'Drill rate of well is {drill_rate} ft/hr') # string formatting
else:
print('No Input Given')