RU beehive logo ITEC dept promo banner
ITEC 109
2014spring
ibarland

homeinfolectslabsexamshws
D2Lbreeze (snow day)tutor/PIs

lab08-variable-practice
variables
practice

Review


Example: Write a series of expressions to calculate what character corresponds to 'a' shifted backwards by 32. Use variables to store intermediate results (rather than one big expression chr( ord('a')-32 )).
Sample solution:

startLetter = 'a'
startCode = ord(startLetter)
shiftedCode = startCode - 32
shiftedLetter = chr(shiftedCode)
shiftedLetter
      

Self-practice: Type in and run the following (filling in blanks as appropriate):

TODO: For each of the following, have a series of python statements which call a single function at a time and store the result into a new variable, and the following statement will use that variable (and one more function call).

Note that if we first want to do one thing, and use that result in the next step, and so-on, we can either compose functions, or we can make up name for intermediate results and store those results in those variables.


If you finish the above, you can start working on the next problem.


1 We say that this function has a “side effect”, since calling it multiple times gives you different stuff (multiple windows), unlike calling len multiple times which .      

homeinfolectslabsexamshws
D2Lbreeze (snow day)tutor/PIs


©2014, Ian Barland, Radford University
Last modified 2014.Feb.07 (Fri)
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Powered by PLT Scheme