At the end of this lesson, you will be able to:
create if..then..elsif..else statements
With a pencil and paper, answer the following questions:
Write the line of code you need before you can use the random function in Python.
Write the line of code in Python to generate a random number between 10 and 20 and assign it to a variable called "random_num".
Create the pseudocode for a program that does the following:
Generate a random number between 1 and 100 that represents the number of smarties in the smartie jar.
Ask the user how many smarties are in the smartie jar.
If they guess correctly, tell them so.
Otherwise, tell them they guessed incorrectly.
Create 2 test cases for the above program: 1 for a user that guesses correctly and 1 for a user that guesses incorrectly.
how to generate random numbers
if..then..else statements
Note: ELSE does not need a condition. See the pseudocode below:
IF (temperature is below 5 degrees Celsius) THEN
WEAR a jacket
ELSE
WEAR a hat
ENDIF
from the online book Computer Based Problem Solving by Patrick Coxall, read:
read "Python if..else statement"
watch the video within from 5:50 to 9:00
create a "Positive / Negative / Zero" program that asks the user to enter an integer
if the user enters a positive number, it says: "<The number> is a positive number."
otherwise, if the user enters a negative number, it says: "<The number> is a negative number."
otherwise, it says: "<The number> is a just zero."
use a 3 level "If..Then..ElseIf..Else" to do this program
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++