At the end of this lesson, you will be able to:
understand and use a continue statement inside a loop
With a pencil and paper, answer the following questions:
What is the purpose of a break statement?
Where can we place a break statement in code?
Create a flowchart for a looping program that does the following:
Ask the user to enter a mark
If they enter "q", break out of the loop
Keep track of the number of marks they get that are greater than or equal to 80
Display the total number of 80+ marks they got
Write the code in Python that for the program above.
break statements
from the online book Computer Based Problem Solving by Patrick Coxall, read:
used to skip over part of a loop where a boolean condition is triggered
Top-Down Design
Test Cases
Flow Chart
Pseudocode
Code
Get the number of numbers from the user
What if it is a string?
What is it is a negative number?
What if it is 0?
User a loop to get each number from the user
What will happen if they enter a string?
What will happen if they enter a negative number?
What will happen if they enter 0?
Write a program that asks the user how many numbers they would like to add together.
It then uses a while loop to do the following:
ask for the number the user wants to add
add it to the current sum BUT if it is negative do not (use a continue for this part)
Display the numbers added and the final sum to the user.
Make sure your program does not crash if a user enters invalid input!
in groups of 2, do the following on the board for today's daily assignment:
Top-Down Design
Flow Chart
Pseudocode
Test Cases
complete the Daily Assignment section in Hãpara Workspace for this day
if Hãpara is not working, make a copy of this document
move it to your IMH-ICS folder for this course
recreate the same program in C++