Python For Og Lecture 16 Nested If Else If Elif Else

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

1/30/2021 Python for O&G Lecture 16 - Nested if else & If elif else - Colaboratory

Python for O&G

Website - https://petroleumfromscratchin.wordpress.com/

LinkedIn - https://www.linkedin.com/company/petroleum-from-scratch

YouTube - https://www.youtube.com/channel/UC_lT10npISN5V32HDLAklsw

API Gravity

1. Light - API > 31.1

2. Medium - 22.3 < API < 31.1

3. Heavy - 10 < API < 22.3

4. Extra Heavy - API < 10

# Let us ignore the Extra Heavy category fo a while

api = float(input('What is the API of crude oil? '))

if api > 31.1: /


1/30/2021 Python for O&G Lecture 16 - Nested if else & If elif else - Colaboratory

print('Light Crude Oil')


else:
if 22.3 < api < 31.1:
print('Medium Crude Oil')
else:
print('Heavy Crude Oil')

What is the API of crude oil? 35


Light Crude Oil

api = float(input('What is the API of crude oil? '))

if api > 31.1:


print('Light Crude Oil')
else:
if 22.3 < api < 31.1:
print('Medium Crude Oil')
else:
print('Heavy Crude Oil')

What is the API of crude oil? 25


Medium Crude Oil

api = float(input('What is the API of crude oil? '))

if api > 31.1:


print('Light Crude Oil')
else:
if 22.3 < api < 31.1:
print('Medium Crude Oil')
else:
print('Heavy Crude Oil')

What is the API of crude oil? 10


Heavy Crude Oil

if elif else

/
1/30/2021 Python for O&G Lecture 16 - Nested if else & If elif else - Colaboratory

api = float(input('What is the API of crude oil? '))

if api > 31.1:


print('Light Crude Oil')
elif 22.3 < api < 31.1:
print('Medium Crude Oil')
elif 10 < api < 22.3:
print('Heavy')
else:
print('Extra heavy')

What is the API of crude oil? 5


Extra heavy

ASSIGNMENT 7

Given:

1. Cubic - 0.476 (max porosity)


2. Hexagonal - 0.395 (max porosity)
3. Rhomohedral - 0.260 (max porosity)
4. Tetragonal - 0.302 (max porosity)

# use if elif else program


# Create a variable asking for the value of maximum porosity
# Create a program for checking if is it either of above and print 'It is Cubic paking ya hexagonal packing etc etc'
# if not anyone among them, print the statement 'This kind of packing does not match any of the options given'

max_porosity = float(input('What is the maximum porosity for current grain packing structure? '))

if max_porosity == 0.476:
print('It is Cubic Packing')
elif max_porosity == 0.395:
print('It is Hexagonal Packing')
elif max_porosity == 0.260:
print('It is Rhombohedral paking')
elif max_porosity == 0.302:
print('It is Tetragonal Packing') /
1/30/2021 Python for O&G Lecture 16 - Nested if else & If elif else - Colaboratory
p ( g g )
else:
print('This kind of packing does not match any of the available options')

What is the maximum porosity for current grain packing structure? 0.395
It is Hexagonal Packing

You might also like