Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Example of break, continue and pass statements in python

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()
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Example #continue #pass #statements #python
ADD COMMENT
Topic
Name
3+3 =