//
) and remainder (%
)
operatorsWork on this lab with your partner (or on your own if you have not been assigned one).
Unless otherwise indicated, use only the Python operations and commands we have described thus far in class.
Show your work for a given problem to the instructor or one of the lab assistants before moving on to the next problem, but do not get too bogged down on any one problem.
In the common case, you will not complete the exercises during our scheduled lab. It is then up to you to complete the lab on your own time.
Email me a copy of your work (attach the lab0.py) file by replying to the email that officially announces the lab. If working with a lab partner send me just one copy for the pair, but CC your partner.
Exercises that ask you to use simple assignments mean of the form:
n = 7
your_favorite_number = my_favorite_number + 1
in other words: the simple expression can be either an atom (literal number or varaible) or combination of two atomic expressions using a single binary arithmetic operator. Only use this appraoch when it is specifically asked of you; otherwise, use your judgement about how complicated you wish your expressions to get (most problems won’t require that they be particulrly complicated).
Python basics in the IDLE shell. Try these examples in order, one at a time:
>>> 33 + 47
>>> x
>>> x = 5
>>> x
>>> y = x + 1
>>> y
>>> x = x * 2
>>> x
>>> y
>>> (x + 1) * (y - 1)
>>> 15 / 3
>>> 15 / 2
>>> 15 // 2
>>> 17 / 5
>>> 17 // 5
>>> 17 % 5
Open the file simple_functions.py
in IDLE. Read the
examples. Use “Run module” to load the file into the shell. Try each
function in the shell as in:
>>> three_one(25)
To work on the remaining problems:
lab0.py
in the lab0
folder.