Python Programming · Week 2
Hyeongmin Lee · SeoulTech, Dept. of Electronic Engineering
The same steps as in week 1.
This video is all typing. Pause whenever you need to catch up.
One line, Enter, read the answer. Then the next one.
>>> 7 / 2
>>> 6 / 2
>>> 7 // 2
>>> 7 % 2
>>> 2 ** 10
>>> 2 + 3 * 4
>>> (2 + 3) * 4
then look back
Which answers have a decimal point?
and why: the three rules from the theory video
On purpose.
>>> 1 / 0
>>> 2 +
>>> 2 ^ 10
two loud errors: good news · one silent wrong answer: the worst case · read an error from its last line
In your week02 folder. Run it with the Run button.
# Week 2 practice
# a line that starts with # is a note for humans
# Python skips it
3 * 7
print(3 * 7)
print(258 // 60)
print(258 % 60) 21
4
18
the bare 3 * 7 line shows nothing · the three print lines do
# = a note for humans · Python skips the line · use it to label your work
In a new file: examples.py
print(24 * 60 * 60) 86400
Two answers, so two print lines.
print(347 // 60)
print(347 % 60) 5
47
A thinking one.
The last digit of any number is the remainder after dividing by 10.
print(2 ** 100 % 10) 6
All in one file: week02_exercise.py, on e-Class.
Next steps
Before class. Everything you need is on e-Class.
See you in class.