Professional Documents
Culture Documents
Python For Og Lecture 25 Break Continue Keywords
Python For Og Lecture 25 Break Continue Keywords
Website - https://petroleumfromscratchin.wordpress.com/
LinkedIn - https://www.linkedin.com/company/petroleum-from-scratch
YouTube - https://www.youtube.com/channel/UC_lT10npISN5V32HDLAklsw
Python has a set of keywords that are reserved words that cannot be used as variable names, function names, or any other identi ers
if = 'scratch'
/
2/1/2021 Python for O&G Lecture 25 - Break, Continue keywords - Colaboratory
continue = 45
and = 'String'
And = 'string'
print(And)
string
break and coninue keyword is used when we want to stop at a certain point or want to skip something particular in a loop /
2/1/2021 Python for O&G Lecture 25 - Break, Continue keywords - Colaboratory
break keyword
3
4
5
6
7
8
9
print(i)
break
3
4
5
6
7
8
9
This is the random line
print(i)
break /
2/1/2021 Python for O&G Lecture 25 - Break, Continue keywords - Colaboratory
3
This is the random line
4
5
6
7
8
9
10
11
12
13
This is end of the loop
Generally we use these break and continue statemnents when there is need of speci c conditions
# while True:
# porosity = float(input('Enter a porosity value: '))
# if porosity < 0.6:
# print('Thanks for the input!')
# break
# else:
# print('You entered an unrealistic porosity value. Enter the value again!')
while True:
porosity = float(input('Enter a porosity value: ')) /
2/1/2021 Python for O&G Lecture 25 - Break, Continue keywords - Colaboratory
/
2/1/2021 Python for O&G Lecture 25 - Break, Continue keywords - Colaboratory