Avatar

Avatar
MrsAnderson

Sunday 4 December 2016

8xcCP2 Unit 3 Lesson 4 - Fantastic Functions

Homestudy

LO To understand how to use and call functions

Fantastic Functions - Teachers' slides

Starter:  Find out what a Function is  programming. Where might we use functions?

Look at the code on the board, what might this do?  How is this a function?

Copy and paste the code from below into repl.it and experiment with making mistakes to see which errors you get and correct them

def pullRabbit ():
    print ("    ,__           ")
    print ("   / /^\  ,____   ")
    print ("   \_), ^^  _, \  ")
    print ("      / @ @ \(_/  ")
    print ("  ___{_-.x.-_}__  ")
    print ("(_______________) ")
    print ("     |       |    ")
    print ("     |       |    ")
    print ("     |       |    ")
    print ("     |       |    ")
    print ("     |_______|    ")
magicWord = input("Enter the magic word: ")
if magicWord == "abracadabra":
    pullRabbit()
else:
    print("That's not the magic word!")

Follow the teachers slides above.

Extension tasks are slide 5 onwards.

No comments:

Post a Comment