pet1 = "Spot" pet2 = "Stella" pet3 = - - PowerPoint PPT Presentation

pet1 spot pet2 stella pet3 kimchee print see pet1 see pet1
SMART_READER_LITE
LIVE PREVIEW

pet1 = "Spot" pet2 = "Stella" pet3 = - - PowerPoint PPT Presentation

pet1 = "Spot" pet2 = "Stella" pet3 = "Kimchee" print("See " + pet1 + ". See " + pet1 + " run. Run, " + pet1 + ", run!") print("See " + pet2 + ".


slide-1
SLIDE 1
slide-2
SLIDE 2
slide-3
SLIDE 3

pet1 = "Spot" pet2 = "Stella" pet3 = "Kimchee" print("See " + pet1 + ". See " + pet1 + " run. Run, " + pet1 + ", run!") print("See " + pet2 + ". See " + pet2 + " run. Run, " + pet2 + ", run!") print("See " + pet3 + ". See " + pet1 + " run. Run, " + pet3 + ", run!")

slide-4
SLIDE 4
slide-5
SLIDE 5

def tellStory(pet): print("See " + pet + ". See " + pet + " run. Run, " + pet + ", run!") tellStory("Spot") tellStory("Stella") tellStory("Kimchee")

slide-6
SLIDE 6
slide-7
SLIDE 7

functionName(input1, input2, ...)

slide-8
SLIDE 8

print(type(int("4") + float(3))) int("4") float(3) type print

slide-9
SLIDE 9

abs(-2) # absolute value type(2) # the type of the value str(2) # converts the value to a string int(3.5) # converts the value to an integer float(5) # converts the value to floating point print("Hello World") # displays the value print(1, 2, 3) # print can take any number of inputs

slide-10
SLIDE 10
slide-11
SLIDE 11

pow(x, y) pow(2,3) pow(3,2)

slide-12
SLIDE 12

pow(2,3) 8

slide-13
SLIDE 13

print()

slide-14
SLIDE 14

None

None None True False print() None

slide-15
SLIDE 15
slide-16
SLIDE 16

int(0.07) print("15", "-", "110")

slide-17
SLIDE 17
slide-18
SLIDE 18

math. import math print(math.ceil(6.5)) # ceiling of a float number print(math.log(64, 2)) # finds the log of 64 with base 2 print(math.radians(90)) # converts degrees to radians print(math.pi)) # it's π!

slide-19
SLIDE 19
slide-20
SLIDE 20

import tkinter

slide-21
SLIDE 21

import tkinter root = tkinter.Tk() canvas = tkinter.Canvas(root, width=400, height=400) canvas.pack() # your code goes here root.mainloop()

root canvas

slide-22
SLIDE 22
slide-23
SLIDE 23

canvas.create_rectangle canvas.create_rectangle(10, 50, 110, 100)

slide-24
SLIDE 24
slide-25
SLIDE 25
slide-26
SLIDE 26
slide-27
SLIDE 27

def helloWorld(): print("Hello World!") print("How are you?") helloWorld() def helloWorld

slide-28
SLIDE 28

def hello(name): print("Hello, " + name + "!") print("How are you?") hello("Scotty") hello("Dippy")

slide-29
SLIDE 29

None def makeHello(name): return "Hello, " + name + "! How are you?" s = makeHello("Scotty")

slide-30
SLIDE 30

None def drawDonut(canvas): # call drawDonut in graphics # create_oval makes an oval in the given bounding box canvas.create_oval(100, 100, 300, 300) canvas.create_oval(180, 180, 220, 220)

slide-31
SLIDE 31

None def singHappyBirthday(name): print("Happy birthday to you") print("Happy birthday to you") print("Happy birthday dear " + name) print("Happy birthday to you!") singHappyBirthday("Dippy")

slide-32
SLIDE 32

def addTip(cost, percentToTip): return cost + cost * percentToTip total = addTip(20.00, 0.17)

slide-33
SLIDE 33

def distance(x1, y1, x2, y2): xPart = (x2 - x1)**2 yPart = (y2 - y1)**2 print("Partial Work:", xPart, yPart) return (xPart + yPart) ** 0.5

slide-34
SLIDE 34
slide-35
SLIDE 35

def addItUp(x, y, z): answer = x + y answer = answer + z print(answer) # NameError!

answer

addItUp

slide-36
SLIDE 36

x = 5 def test(): y = x + 2 return y print(test() - x)

slide-37
SLIDE 37

x = "bar" def test(): x = "foo" print("A", x) test() print("B", x) x x

slide-38
SLIDE 38

name = "Farnam" def greet(day): punctuation = "!" print("Hello, " + name + punctuation) print("Today is " + day + punctuation) def leave(): punctuation = "." print("Goodbye, " + name + punctuation) greet("Wednesday") leave()

slide-39
SLIDE 39

frog = "King Harold" def greet1(): print("Hello", frog) greet1() Hello King Harold frog = "King Harold" def greet2(): frog = "Kermit" print("Hello", frog) greet2() Hello Kermit frog = "King Harold" def greet3(): print("Hello", frog) frog = "Kermit" Error: local variable 'frog' referenced before assignment.

slide-40
SLIDE 40