Category Archives: Lessons

pygame: WallBouncing_YI.py

Classwork:
Continue working on the program, WallBouncing_YI.py.
Screen Shot 2014-03-07 at 11.09.04 AM
Home work: Keep on reading chapter 17.
Screen Shot 2014-03-07 at 9.30.28 AM

Visit edmodo.com to answer the following questions from your reading material:
1. If a block is moving DOWNLEFT, how is the x coordinate behaving? how is the y coordinate behaving?
2. If a block is moving DOWNRIGHT, how is the x coordinate behaving? how is the y coordinate behaving?
3. If a block is moving UPLEFT, how is the x coordinate behaving? how is the y coordinate behaving?
4. If a block is moving UPRIGHT, how is the x coordinate behaving? how is the y coordinate behaving?
5. If a block is moving UPRIGHT, when would it bounce off the top of the window?
6. If a block is moving UPRIGHT, when would it bounce off the right side of the window?
7. If a block is moving DOWNRIGHT, when would it bounce off the bottom of the window?
8. If a block is moving UPLEFT, when would it bounce off the left side of the window?
9. Why did the author pick numbers 1, 3, 7, and 9 for the constants DOWNLEFT, DOWNRIGHT, UPLEFT AND UPRIGHT?

Think about your next program. It will be related to the animation.py but with a simple maze.
Screen Shot 2014-03-07 at 9.29.25 AM

pygame: Run spritesAndSound.py

Classwork:
Run spritesAndSound.py

On edmodo.com:
1. What is the syntax to load an image?
2. What type of files can be images for pygame?
3. What is the syntax that defines the size of the image?
4. How do you create a pygame.mixer.Sound object?
5. What is the syntax to load the background music?
6. Describe the 3 argumenst in pygame.mixer.music.play(-1, 0.0).

Homework: Read chapter 19 – Sound and Images

Chapter 19 – Sound and Images link
Screen Shot 2014-04-28 at 7.05.14 AM

pygame: mySpritesAndSound.py

Classwork:
Run spritesAndSound.py

Visit edmodo.com to answer 8 questions from chapter 19

Write a python/pygame program, mySpritesAndSound_YI.py similar to spritesAndSound.py. However, in this program there are no cherries and no player but when you click on the black surface an image shows up. Have 10 different images so when you click with the mouse one of those random images is selected for display. The image should disappear when you release the mouse button. Find two different sounds, one for clicking and one for the release of the mouse button. Make sure you use at least one list.

Note: there are libraries of sound files online. Look for the right one for your application.

Homework: Keep on reading chapter 19 – Sound and Images

Chapter 19 – Sound and Images link
Screen Shot 2014-04-28 at 7.05.14 AM

pygame: Snake1_YI.py

Use the skills you learned in this class to write a program, Snake1_YI.py to play “snake” game.

Choose your favorite interpretation of this game.
Here is a link to the online version of snake.

Cryptography

Classwork:
Screen Shot 2015-05-14 at 9.26.24 PM
Caesar Cipher
Create a new file in Idle with the following program: cipher.py

Cryptography

The science of writing secret codes is called cryptography.
220px-Lorenz-SZ42-2
German Lorenz cipher machine, used in World War II to encrypt very-high-level general staff messages

In cryptography, we call the message that we want to be secret the plaintext. The plaintext could look like this:

Hello there! The keys to the house are hidden under the flower pot.

How would encrypt it so it would become a secret message?


You can use Idle to answer some of the questions.

1. What is the ASCII table? What is the range of numbers that is used in the table?
2. What is the first number where the alphabet starts? Is it lower case or upper case?
3. How do you get the ASCII value of any letter or number (alphanumeric) in python?
4. How do you get the alphanumeric value of an integer in the range of the ASCII table?
5. Can you print all of the ASCII values?
6. Explain what a cipher is?
7. Run the cipher program and enter this sentence: “Doubts may not be pleasant, but certainty is absurd.” What is the encrypted sentence?
8. What does this ‘Hello’.isalpha() do in python shell?
9. What is the syntax to check if it is numeric?
10. What does this ‘HELLO’.isupper() do in python shell?
11. Explain what this code snippet does and what the purpose is in cipher.py:

if num > ord('Z'):
   num -= 26
elif num < ord('a'):
   num += 26

12. Explain the function getKey().
13. Explain the function getTranslatedMessage(mode, message, key).

Homework
Explain Brute Force

List: FlashCards1_YI.py

Classwork:
More on spritesAndSound.py

Write a python/pygame program, FlashCards1_YI.py similar to previous program, mySpritesAndSound_YI.py. However, in this program, the user has to click on two matching cards. If the user guesses right, the sound should indicate so and so should the sound indicate when it is wrong.

flashCards

Note: there are libraries of sound files online. Look for the right one for your application.

Homework: Keep on reading chapter 19 – Sound and Images

Chapter 19 – Sound and Images link
Screen Shot 2014-04-28 at 7.05.14 AM