2. Basic Types, Operators & Expressions
Table of Contents
Here is a list of programming concepts that we will be covering this week. After going through the readings, in particular chapters 1 and 2 of How To Think Like a Computer Scientist (HTTLACS), you should have a good grasp of the concepts, and you should be able to being to work through the exercises.
In class we will go through the exercises together. There are sample solutions provided with each exercise; my suggestion is to have a go at them on your own first and only if you get really stuck, have a look at the sample solutions.
We will also have a look at the first assignment together and talk about how best to approach it.
1 Basic Types, Operators and Expressions
1.1 expressions
- arithmetic operators
- relational & logical operators
1.2 variables
- numeric variables
- characters & strings
2 Control Flow
- if / then / else
- for loop / while loop
3 Readings
- Chapter 1 of How To Think Like a Computer Scientist (HTTLACS)
- variables and statements: Chapter 2 of HTTLACS
- strings: Variables and Strings section of Python Programming (PP) and the strings section as well, plus Chapter 7 of HTTLACS
- conditionals
- iteration: the Loops section of PP
- tuples: the Tuples section of Dive Into Python (DIP) and the Tuples and Sequences section of the Python Tutorial (PT)
- also have a look through Digital Representation of Data if you haven't been exposed before to how digital computers represent information
4 Exercises
Exercises 1 through 7 are designed to get you writing some basic programs to do arithmetic and generate output to the screen, and to get used to the idea of seeing mathematical expressions and equations, and tranlsating them into programs that run on your computer.
5 Assignment
Assignment 1 is due no later than Sunday Sep 21, 2014, 23:59:59 EDT. For your reference here is US Naval Observatory Master Clock Time. Please send me your solution by email to paul [at] gribblelab [dot] org. I want a single file that I can directly run (or compile and run) in whichever language you choose to use.