Post date: Aug 24, 2011 8:2:4 PM
Announcements
New Assignment: Chapter 3 Quiz on D2L
Due before you first lab on Monday
Homework
Readings from Zelle before Monday's Lab
Read Sections 3.1 and 3.2 on pages 55 through 62
Skip section 3.4 (factorial via a for loop)
Read Sections 3.4 and 3.5 pages on pages 66 through 71
Take the Chapter 3 quiz BEFORE going to your Monday Lab
Lecture Outline
1) Demonstrate Python with an interactive Python session
Expressions consist of
literals: 3 1.23 "Kim"
identifiers: spam eggs __spam_and_eggs__
operators: + - * / **
functions (print, input, eval, and round are 'built-in'):
print("3 + 4 =", 3+4)
input("Prompt: ") #returns a string
eval(input("Enter number: ")) #changes strings to numbers
round(4.56789)
round(4.56789, 2)
A few library functions that need an import (Chapter 3).
To get these functions, you first import math
math.sqrt(4.0)
math.ceil(5.00000001)
math.floor(7.9)
Assignment statements
swap the values of two variables
with a third variable name temp
with simultaneous assignment (asked to skip, but will see again)
Defining our own functions
def main():
print('Hello', 'Dakota')
print('How are you', 'Dakota')
Passing arguments to a function via a parameter (name in this example)
def main(name):
print('Hello', name)
print('How are you', name)
2) Software Development pptx or pdf
3) Code demo: Implement the course grade problem introduced in the above presentation
the program is on Code demos page and last page of handout