At the end of this lesson, you will be able to:
A1.3 use assignment statements correctly with both arithmetic and string expressions in computer programs;
B1.1 use various problem-solving strategies (e.g., stepwise refinement, divide and conquer, working backwards, examples, extreme cases, tables and charts, trial and error) when solving different types of problems;
B2.4 represent the structure and components of a program using industry-standard programming tools (e.g., structure chart, flow chart, UML [Unified Modeling Language], data flow diagram, pseudocode);
B4.1 describe the phases (i.e., problem definition, analysis, design, writing code, testing, implementation, maintenance), milestones (e.g., date of completion of program specification), and products (e.g., specification, flow chart, program, documentation, bug reports) of a software development life cycle;
understand what a flowchart is and how to create one
understand what a constant is and how to use one in Python & C++
With a pencil and paper, answer the following questions:
Declare a variable in Python that holds the total quantity of mass of a boomerang in a science experience. Set it to 339.5 grams. Then do the same for C++.
Declare a constant in Python called HST and set it to 0.13. Then do the same for C++.
Write the line of code in Python to ask the user to enter the subtotal cost of a t-shirt. Then do the same for C++.
Create the top-down design for a program that asks the user for the length and width of a soccer field and tells them the perimeter.
top-down design
user input
variables
from the online book Computer Based Problem Solving by Patrick Coxall, read:
go over what a Flowchart is
different shapes have different meanings (see image on the right)
arrows always point down
normally left black and white
create a flowchart for the "Area & Perimeter of a Rectangle with User Input"
watch "Create a Flowchart for the Area & Perimeter of a Rectangle"
use draw.io with a Blank Template
ALWAYS export it as a PNG file to maintain the resolution regardless of the size
File, Export As, PNG...
then insert the PNG into your Google Doc
ensure that you center, size and crop the image so that it fits nicely on the page
NEVER take a screenshot and paste it in as the resolution is not maintained
go over what a constant is
uppercase with words separated by underscores as necessary to improve readability
constants will always be created in a separate module
go over how to create a module, it is just a separate python file
i.e. MONTHS_IN_YEAR = 12
i.e. SECONDS_IN_MINUTE = 60
i.e. HST = 0.13
i.e. BRAND = "Nike"
i.e. ALWAYS_ON = true
Note:
in Python even when you declare a constant, someone could still change it
this is not true in all languages
in C# and Swift, for example, if you declare a constant it can never be changed
to get around this we normally create a new python file (usually called constants.py) and place our constants in there and then "import" that file
watch "Tau versus Pi"
C = τr, τ ~= 6.28 dimensions entered by the user
create a program that asks the user for the radius and then calculates the circumference of a circle using tau, 𝞽
you will have to create a constants.py file to hold the value of tau
TAU = 6.28
when writing comments in code, make sure to:
describe what the next line or section of code should be doing
leave a blank line AFTER the code and BEFORE the next commented section
in groups of 2, do the following on the board for today's daily assignment:
Top-Down Design
Flow Chart
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
create the program from above in C++
note: constants in C++ are NOT declared in a separate file, they are declared above variables
i.e. const int LENGTH = 10;
i.e. const float MAX_VOL = 99.99;
i.e. const string PLANET = "Earth";
i.e. const bool ALWAYS_ON = true;