At the end of this lesson, you will be able to:
A1.4 demonstrate the ability to use Boolean operators (e.g., AND, OR, NOT), comparison operators (i.e., equal to, not equal to, greater than, less than, greater than or equal to, less than or equal to), arithmetic operators (e.g., addition, subtraction, multiplication, division, exponentiation, parentheses), and order of operations correctly in computer programs;
understand and use compound boolean expressions
With a pencil and paper, answer the following questions:
What is the purpose of a try..catch?
Create the flowchart for a program that does the following:
Ask the user to enter a mark between 0% and 100%
If their mark is above or equal to 60%, tell them they are doing well. Otherwise, tell them they need to work harder!
If they entered erroneous data, tell them that they did not enter a number.
In all cases, tell the user "Thanks for playing".
Create 3 test cases for the above problem. Make sure 1 test case is above 60, 1 test case for a mark below 60 and 1 test case is erroneous.
try catch statements
from the online book Computer Based Problem Solving by Patrick Coxall, read:
watch "AND OR NOT Logic Gates Explained"
an AND statement is used when BOTH expressions must be TRUE for the condition to execute
an OR statement is used when ONE OR BOTH expressions must be TRUE for the condition to execute
a NOT statement is used when the OPPOSITE of the expressions must be TRUE for the condition to execute
in Python, and, or and not are keywords that can be used to achieve these results
Choose 1 of the following problems to complete:
Option A: Imagine grandparents #1 who will only approve of you dating their grandchild if you are older than 25 AND younger than 40. Write a program where the user enters their age and then the program tells you if you can date their grandchild.
Option B: Imagine grandparents #2 who will only approve of you dating their grandchild if you are either rich OR really good looking. Write a program where the user enters these 2 pieces of information (maybe as a "yes" or "no" answer) and then the program tells you if you can date their grandchild.
Make sure to "catch" any invalid entries so that your program does not crash.
Make sure that the user enters a valid age (i.e. between 0 and 120)
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
in C++, we use the following boolean operators:
AND = &&
OR = ||
NOT = !
recreate the same program in C++