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;
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;
use the 6 step process to solve any problem
use built-in modules in Python and C++
create test cases
With a pencil and paper, answer the following questions:
What does each of the following code output?
a) print("{:.3f}".format(9.812734))
b) print(10-2**3)
c) print("The remainder of 10/3 is {}.".format(10%3))
d) print ("8 - 4 / 2 = {}". format(8-4/2))
Explain the difference between a constant and a variable.
Are there constants in Python? Explain.
Declare a constant called "MAX_LIVES" as an integer with a value of 3 in Python and C++. Make sure to put a comment above the line.
Declare a variable called "username" as a string with a value of "Guest" in Python and C++. Make sure to put a comment above the line.
basic math operators
how to print calculations in Python and C++
make sure to put comments in header AND body of code
go over Python modules
in other languages, they are called libraries but in Python they are called modules
modules contain libraries of pre-made functions for us to use
import math
watch "The Math Library in Python 3"
watch “Using math.pi to Calculate the Area & Circumference of a Circle”
create a program in Python that calculates the area & perimeter of a circle
remember to use math.pi and not 3.14!
why do we need test cases?
to make sure our program is doing what it is supposed to do!
to make sure our program's calculations are correct
if radius, r = 5.37 cm
then Area, A = 9.59 cm²
if radius, r = 5.37 cm
then Circumference, C = 33.74 cm
*** Note: Perimeter of a circle is called the Circumference
in groups of 2, do the following on the board for today's daily assignment:
Top-Down Design
Flowchart
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
watch "Libraries in C++"
in C++ we will be using "Libraries"
what we did above in Python is actually a "library" as well. It is just more commonly referred to as a "module".
C++ uses an "include" statement to use libraries
create the above program in C++
in C++, π is M_PI