Class 7 – Wednesday, April 12
Make Bill Murray proud
Take another step — Chrestomathics awaits you — Feel the momentum
Look both ways
Comments about Homework 05
- The program was supposed to get a single integer as input. To try different values the program gets run different times.
- Use spaces to make operators stand out.
- Do not use
input()
unless you want a reply from the user. Useprint()
to display the result of a computation
- In Python, variables are as a rule always lowercase and if they are composed of multiple words they are in snake_case.
- When better variable names are available use them; some examples that could be improved
x
,y
,response
,value
, andn
are not good names for ages.
agefake
is not a good Python variable name -- it should be in snake_case; i.e.,age_fake
or even betterfake_age
.
AgeNot
is not a good Python variable name -- it should be in lowercase snake_case; i.e.,age_not
.
Faux_age
is not a good Python variable name -- it should be in lowercase snake_case; i.e.,faux_age
.
Supposed_age
is not a good Python variable name -- it should be in lowercase snake_case; i.e.,supposed_age
.
Agenda
- Continue exploration of the basics of problem solving — getting data, performing computation, and displaying information. Along the way we will develop an appreciation:
- General expression evaluation and formulation
- Relational evaluation and composition
- Input acquisition
Examples (today you should left-click rather than right-click)
- math_illiteracy.py – some math and math-like demonstrations
- temperature.py – another expression evaluation nuance
- can_you_relate.py – introduces the comparison operators
- logical_operators.py – introduces the logical operators
- break_the_bank.py – practice problem solving
To do list
- Review class artifacts
- Read about the Python
random
module capabilities
- Read about Python built-in functions
- Read about Python string capabilities.
- Read problem-solving epistle
© 2019 Jim Cohoon | Resources from previous semesters are available. |