# ---------------------------
# -- Continue, Break, Pass --
# ---------------------------
myNumbers = [1, 2, 3, 5, 7, 10, 13, 14, 15, 19]
# Continue ==> Skip The ( Specific Element ) And Continue
for numbers in myNumbers :
if numbers == 13 :
continue
print( numbers )
print( "_" * 100 ) # -- Separator --
# Pass ==> Skip Any Program If I Completed Or Not
for numbers in myNumbers :
pass
print( "Here We Have 'pass'." )
print( "_" * 100 ) # -- Separator --
# Break ==> Stop The Function
for numbers in myNumbers:
if numbers == 13:
break
print( numbers )
while True:
line = input('Write something: ')
if not line == '': # if the line variable is not empty, run the code block
print(line)
continue # Continues back to the beginning of the while loop
else:
break # if the line variable is empty come out the loop and run the next code
print('End of the program')
def main():
check = input("Are you a new student(yes/no): ")
if check == "yes":
pass
elif check == "no":
totalMarks = 0
numOfSub = 0
while True:
marks = input( 'Marks for subject ' + str(numOfSub +1) + ": ")
if marks == '':
break
marks = float(marks)
if marks < 0 or marks >100:
print("Invalid marks")
continue
numOfSub = numOfSub+1
totalMarks = totalMarks + marks
percentage = totalMarks/numOfSub
print("Total marks: ", totalMarks)
print("Number of Subject is: ", numOfSub)
print("Percentage: ", round(percentage,2))
else:
print("enter a valid response")
main()
# break - used to terminate the loop or statement
# continue - skip the current iteration and continue from the next
# pass - continue the statement, often used as a placeholder to execute
# empty loops/statements