In Class: Week 2 Tuesday, Thursday
Run update21 to download this week's files, then move to the week02 directory
% cd
% cd cs21/class
% pwd
/home/your_user_name/cs21/class
% cd week02
% pwd
/home/your_user_name/cs21/class/week02
% ls
Topics
- Types in python (type() funciton)
- Numeric types (float and int)
- Converting types float(), int(), str(), etc.
- Numeric operators and expressions
- Accumulator pattern
- String data type and operators
- For loops/accumulator pattern with strings
We are going to do some of the following:
- open expr.py in vim. This program contains some examples of
numeric expressions and order of evalution. Let's take a look
at some of them.
- Together we are going to write a program that computes
the average of integer values that are entered by a user by employing
the accumulator pattern. Be careful
to avoid errors due to integer division.
- open test_math.py in vim. Work on using the math library and
accumulator pattern to solve the problems.
- After introducing strings, we will take a look at test_string.py.
Review the first few lines of code, and together we will solve some of
the easier problems. Then, practice using indexing and slicing to print
out the months of the year.