Unformatted text preview: Adding the Class ECS 10
10/1 There are 18 people on the waiting lists. There are 183 people registered; this room seats 185. We W are trying to get a l i larger l lecture h ll hall. I will finish a few minutes early today, and those on the waiting list can stay and we will discuss strategy for adding the class. If you are going to drop, the sooner the better! Starting up Python
From START menu, pick "all programs", then Python Pick the "IDLE" option IDLE
IDLE is an interpreter Can use it like a calculator Responds to input linebyline lineby Remainder
0,1,2,3... and 1,2,3.... are integers 1,2,7/3 is integer division 7%2 = 1 % gives the remainder when 7 is divided by 2 (7/2)*2 + (7%2) = 7 Floating point numbers
7.0, 2.0,0.0006, 7.34 floating point numbers 7.0/2.0 = 3.5 floating point division If either number is floating point, so is the answer so 7.0/3 produces the value 3.5 0/3 d h l 35 1 Data types
Integers and floating point numbers are two different data types in Python Can do different things with them. 3.0 is different from 3 3 0 i diff f 3/2 is different from 3.0/2.0 Floating point is not exact
>>> 8.0/3.0 2.6666666666666665 This is weird...why? Computer numbers have a fixed number of decimal places Exact results with floating point numbers would have an infinite number of decimal places: Example: 8.0/3.0 has the value 2.666666....... Variables
>>> x = 2.0 >>> x = x+3.0 >>> x 5.0 Variables
>>> x = 2.0 >>> x = x+3.0 >>> x 5.0 x is a variable "x = 2.0" is called an assignment statement Variable on lefthand side gets value on rightleftrighthand side. Pronounce this "x gets 2.0" or "x becomes 2.0" Assignment statement puts a data value into variable x, it is not itself a data value or an expression. IDLE does not type a value back after an assignment statement the way it does after an expression. Errors
Lots of things you do will cause errors Something Python doesn't understand 5.0 = x variable is supposed to be on the left. y = y+3 you ask it to give the value y+3 to y, but it doesn't know what y is. Variables don't stand for "any old number" like they do in algebra; a variable must always have a specific value. Python commands in IDLE
You can type any Python command into IDLE, and it does it immediately print is a Python command `a ` rose is a rose' is a string i 'i i "9.0/7.0" is also a string, because it's in quotes 2 Strings in English Making a program
Do something more complicated Remember and repeat a bunch of commands A program
A program is a list of statements in a file Python executes the statements one by one Your program
Uses print Uses some arithmetic? Could use a variable? Adding the Class
You have to add a specific section ONLY sections that can be added: A01 F 8:008:50 8:00A02 F 9:009:50 9:00A05 R 11:0011:50 11:00Get on the wait list for one of those Some possibility that you will not be able to add You can submit homework from the wait list 3 ...
View
Full Document
 Fall '07
 Amenta
 Imperative programming, Fixedpoint arithmetic

Click to edit the document details