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;
write a program that uses basic math operators
With a pencil and paper, answer the following questions:
State the 2 audiences of someone's code.
What is a comment?
Write 1 example of a comment.
What is a shebang?
What is black? What does it do to your code?
For ICS3U Only:
Why is if __name__ == "__main__" necessary in Python?
What is cpplint? What does it do to your code?
how to write comments in Python
how to write comments in C++
black style checker in Python and cpplint style checker in C++
what is a shebang?
what is the purpose of: if __name__ == "__main__" ?
Note: Use Programiz (an online Python interpreter) to run code and check your answers!
read "Python Operators" and watch the video within
watch "Basic Math Operators in Python"
the entire point of creating electronic computers was to automate doing math
add
subtract
multiply
divide
exponent
read "Python String Formatting"
use: print("STRING EXPRESSION = {}".format(CALULATION)), where EXPRESSION is the string you want to write and CALCULATION is what you want to calculate
if I want to print "2 + 3 = 5", I would type:
print ("2 + 3 = {}". format (2+3))
if I wanted to print the number 3.1415926 rounded to 2 decimal places, I would type:
print ("{:.2f}.format(3.1415926))
this would output: 3.14
watch "Area & Perimeter of a Rectangle in Python"
calculate and display the area and perimeter of a rectangle that has a length of 5cm and a width of 3cm.
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 "Basic Math Operators in C++"
create the "Basic Math Operators" program in C++