Make a function This is a starter activity and should take 5 minutes [ slide 1 ] >>> def count(number): n=1 while n <= number: print(n) n = n+1 1. Log in to your computer 2. Open IDLE 3. In interactive mode create this function: 4. Press return untill the >>> prompt returns, then type this line: >>> count(10)
Lesson Aims [ slide 2 ] Vocabulary function def key word argument hacking In this lesson you are going to: 1.learn about functions 2.write your own functions 3.use your own functions
Interactive session [ slide 3 ] 1.Read Delving deeper on page 47 – how to stop a code that will not finish. 2.Work your way through pages 47 – 50 in Python Basics. Top Tip: Do you remember how to copy chunks of code easily in IDLE? If not, read what Mr Campbell has to say on page 50. If you have finished: 1. Help other students who may be stuck 2.Try Idea 1 on page 53. Save your file in your Python Code folder.
Homework 1.Play the Light-Bot game here: Take a screen shot of where you got to in 30minutes and send it to your teacher. 3.Stop if you have other homeworks to do! [ slide 4 ]
Lesson Summary [ slide 5 ] In this lesson you have: 1.learn about functions 2.written your own functions 3.used your own functions Vocabulary You now know what a function is but what Python keyword is required? What does hacking mean? What is an argument? Information required by a function Re-writing bits of existing code to change what it does def