4
Copy, paste, amend This is a starter activity and should take 5 minutes [ slide 1 ] 1. Log in to your computer 2. Open myEtchASketch.py in IDLE 3. Check you have the code below: 4. Copy and paste the whole function and try to amend it to create a p1_move_S(self)function.

Copy, paste, amend This is a starter activity and should take 5 minutes [ slide 1 ] 1.Log in to your computer 2.Open myEtchASketch.py in IDLE 3.Check you

Embed Size (px)

Citation preview

Page 1: Copy, paste, amend This is a starter activity and should take 5 minutes [ slide 1 ] 1.Log in to your computer 2.Open myEtchASketch.py in IDLE 3.Check you

Copy, paste, amendThis is a starter activity and should take 5 minutes

[ slide 1 ]

1. Log in to your computer

2. Open myEtchASketch.py in IDLE

3. Check you have the code below:

4. Copy and paste the whole function and try to amend it to create a p1_move_S(self)function.

Page 2: Copy, paste, amend This is a starter activity and should take 5 minutes [ slide 1 ] 1.Log in to your computer 2.Open myEtchASketch.py in IDLE 3.Check you

Lesson Aims

[ slide 2 ]

In this lesson you are going to:

1. practise writing functions

2. practise using tkinter’s lines widget

3. review how to add keyboard control to your game

4. finish the MyEtchASketch game

5. Open and customise a free two player Etch A Sketch® game

Page 3: Copy, paste, amend This is a starter activity and should take 5 minutes [ slide 1 ] 1.Log in to your computer 2.Open myEtchASketch.py in IDLE 3.Check you

Finishing Off

[ slide 3 ]

1. Check your code for p1_move_N(self) is correct by looking at Code Box 5.4 on page 68 in Python Basics

2. Copy all the missing code from Code Box 5.4 into your Etch A Sketch® app

3. Test it out and make sure it works.

Top Tip:

There are four very similar functions supplied. It is quickest to copy the first function three more times and then amend it.

Whenever a coder keeps copying and pasting it hints that there is probably a better way of doing things.

Page 4: Copy, paste, amend This is a starter activity and should take 5 minutes [ slide 1 ] 1.Log in to your computer 2.Open myEtchASketch.py in IDLE 3.Check you

What now?

[ slide 4 ]

Try the Quick Ideas on page 701

Try the Puzzle on page 71 (this is quite difficult).2

Get ourEtchASketch.py from the source code folder and try some of the Extra ideas on page 72

3