https://studio.code.org/projects/applab/DRKUGdMc_Ts1kIvH7Ir003VQeTj4CEDPx7L9OL6ZqsM
Pokemon Python Game Week 2
https://repl.it/languages/python3
From last week:
######################################
pokemon = ["Bulbasaur", "Squirtle", "Charmander", "Pikachu"]
print("A wild Mewtwo appears!")
input("Do you want to fight or run away?")
print("The Mewtwo attacks you!")
for number in range (4):
#######################################
Continue the project and finish it off.
Your output should look like this:
A wild Mewtwo appears!
Do you want to fight or run away?
The Mewtwo attacks you!
Go! Bulbasaur!
Mewtwo has defeated Bulbasaur!
Press enter to send out your next Pokemon
Go! Squirtle!
Mewtwo has defeated Squirtle!
Press enter to send out your next Pokemon
Go! Charmander!
Mewtwo has defeated Charmander!
Press enter to send out your next Pokemon
Go! Pikachu!
Mewtwo has defeated Pikachu!
Press enter to send out your next Pokemon
You have no more Pokemon.
You have been defeated!
-------------------------------
Level 2
Did you finish the project?
If you finished, try the next two challenges.
1) Add an if clause to allow for the player to run away. Create alternative text for this scenario. Your text might look something like this:
A wild Mewtwo appears!
Do you want to fight(f) or run away(r)?r
You are very boring.
THE END
2) Give Mewtwo a set number of HP and allow the players to characters to do semi random levels damage to Mewtwo with each round. Your final code might look something like this:
A wild Mewtwo appears!
Do you want to fight(f) or run away(r)?f
The Mewtwo attacks you!
Mewtwo has 5000 hp.
Go! Bulbasaur!
Bulbasaur attacks Mewtwo!
Bulbasaur does 79 damage to Mewtwo.
Mewtwo has 4921 hp.
Mewtwo attacks Bulbasaur
Mewtwo has defeated Bulbasaur!
Press enter to send out your next Pokemon
Go! Squirtle!
Squirtle attacks Mewtwo!
Squirtle does 74 damage to Mewtwo.
Mewtwo has 4847 hp.
Mewtwo attacks Squirtle
Mewtwo has defeated Squirtle!
Press enter to send out your next Pokemon
Go! Charmander!
Charmander attacks Mewtwo!
Charmander does 36 damage to Mewtwo.
Mewtwo has 4811 hp.
Mewtwo attacks Charmander
Mewtwo has defeated Charmander!
Press enter to send out your next Pokemon
Go! Pikachu!
Pikachu attacks Mewtwo!
Pikachu does 80 damage to Mewtwo.
Mewtwo has 4731 hp.
Mewtwo attacks Pikachu
Mewtwo has defeated Pikachu!
Press enter to send out your next Pokemon
You have no more Pokemon.
You have been defeated!
After you finish the pokemon project, log onto code.org here:
Pokemon Python Project
Go to this website: https://repl.it/languages/python3
Before we start, let's learn about an easier way to put variables inside text strings (this only works in Python 3 and won't work in Trinket).
If we type:
x = 'y'
print(f"Hello {x}!")
What is the output?
What happens if we take away the f?
Can you remember how to change the code so it produces this output?
What is your name?Superman
Hello Superman!
Python Pokemon Game
Try to code a simple Pokemon game like the example below using for loops:
A wild Mewtwo appears!
Do you want to fight or run away?
The Mewtwo attacks you!
Go! Bulbasaur!
Mewtwo has defeated Bulbasaur!
Press enter to send out your next Pokemon
Go! Squirtle!
Mewtwo has defeated Squirtle!
Press enter to send out your next Pokemon
Go! Charmander!
Mewtwo has defeated Charmander!
Press enter to send out your next Pokemon
Go! Pikachu!
Mewtwo has defeated Pikachu!
Press enter to send out your next Pokemon
You have no more Pokemon.
You have been defeated!
-------------------------------
Level 2
Did you finish the project?
If you finished, try the next two challenges.
1) Add an if clause to allow for the player to run away. Create alternative text for this scenario. Your text might look something like this:
A wild Mewtwo appears!
Do you want to fight(f) or run away(r)?r
You are very boring.
THE END
2) Give Mewtwo a set number of HP and allow the players to characters to do semi random levels damage to Mewtwo with each round. Your final code might look something like this:
A wild Mewtwo appears!
Do you want to fight(f) or run away(r)?f
The Mewtwo attacks you!
Mewtwo has 5000 hp.
Go! Bulbasaur!
Bulbasaur attacks Mewtwo!
Bulbasaur does 79 damage to Mewtwo.
Mewtwo has 4921 hp.
Mewtwo attacks Bulbasaur
Mewtwo has defeated Bulbasaur!
Press enter to send out your next Pokemon
Go! Squirtle!
Squirtle attacks Mewtwo!
Squirtle does 74 damage to Mewtwo.
Mewtwo has 4847 hp.
Mewtwo attacks Squirtle
Mewtwo has defeated Squirtle!
Press enter to send out your next Pokemon
Go! Charmander!
Charmander attacks Mewtwo!
Charmander does 36 damage to Mewtwo.
Mewtwo has 4811 hp.
Mewtwo attacks Charmander
Mewtwo has defeated Charmander!
Press enter to send out your next Pokemon
Go! Pikachu!
Pikachu attacks Mewtwo!
Pikachu does 80 damage to Mewtwo.
Mewtwo has 4731 hp.
Mewtwo attacks Pikachu
Mewtwo has defeated Pikachu!
Press enter to send out your next Pokemon
You have no more Pokemon.
You have been defeated!
Python project 2
We can use this code:
for number in range (10):
print(number)
To list the numbers 1-10
How can we get our computers to count to 1000? *this might take a long time
We can also do more complicated things, can you get it to list every multiple of 3 up to 300? (we use * to multiply)
Can you create code to complete this list: 0, 1, 4, 9, 16, 25, 36...
We can also combine math with words.
Can you figure out how to print something like this:
Hello!
Helloo!
Hellooo!
Helloooo!
Hellooooo!
Helloooooo!
Hellooooooo!
Helloooooooo!
Hellooooooooo!
Helloooooooooo!
Next we can try to outline a simple game event using a list of Pokemon, we will rerun the code for each Pokemon to get something like this:
A wild Mewtwo appears!
Do you want to fight or run away? fight
The Mewtwo attacks you!
Go! Bulbasaur!
Mewtwo has defeated Bulbasaur!
Press enter to send out your next Pokemon
Go! Squirtle!
Mewtwo has defeated Squirtle!
Press enter to send out your next Pokemon
Go! Charmander!
Mewtwo has defeated Charmander!
Press enter to send out your next Pokemon
Go! Pikachu!
Mewtwo has defeated Pikachu!
Press enter to send out your next Pokemon
You have no more Pokemon.
You have been defeated!
Week 12 Code
Start here: jumpto.cc/rps-go
#!/bin/python3
from random import randint
#player choice
player = input('rock (r), paper (p) or scissors (s)?')
print(player, 'vs', end=' ')
# Computer choice
chosen = randint(1,3)
#print(chosen)
if chosen == 1:
computer = 'r'
elif chosen == 2:
computer = 'p'
else:
computer = 's'
print(computer)
# Now teach the computer how to tell us who is the winner
# Now make a new game for fire, grass and water or Bulbasaur, Charmander, Squirtle or something similar.
Programming Club Python Projects
Start here: jumpto.cc/rps-go
https://projects.raspberrypi.org/en/codeclub
Easy
Medium
Secret Messages (hard)
Shakespearean insult generator
Pride and Prejudice and zombies
https://projects.raspberrypi.org/en/projects/pride-prejudice-zombies
Sense HAT
Tinkercad
Mars: mars7987
Lawrence: lawrence2080
Alan: alan7099
Demo: demo9974
Making websites with Google Sites
Awesome Alan's Computer Art
Go to sites.google.com
Enter your username:
Number@suntek.tksh.ntpc.edu.tw
Lawrence 4054
Mars 4058
Alan: 4055
@suntek.tksh.ntpc.edu.tw
Enter your password:
password: suntekYYMMDD
Use Photos of your work from the shared USB and the links below:
Photos:
2019-20: https://photos.app.goo.gl/ZgjGxwGWS74kT5qA8
2018-19 s2: https://photos.app.goo.gl/PBRevea1Ccorq34ZA
All of 2018-19: https://www.computerart.club/p/cac-photos-2018-2019.html
CAC favs: https://photos.app.goo.gl/nTtcKVwEJqAr6F1R2
Final websites:
Lawrence
Python Madlibs and story generators for kids
Part ACrazy text Madlibs in Python with User Input
To start with, we are going to use this website to run Python 3: https://repl.it/languages/python3We can create variables in Python from user input. Print is used to show text. In Python 3, we put f before a string if it has a variable inside.
Try running the example.
Activity 1:
Activity 2:
Activity 3:
Part B
A Python Story Generator with lists
We can print list items like so:
Activity 1:
Paste both lines of code into Python. Which word does it print? Why that word?Activity 2:
Activity 3:
Activity 4:
Activity 5
Activity 6
from random import randint #wild pokemon wpok = ["Pikachu", "Charmander", "Bulbasaur", "Squirtle", "Mew", "Mewtwo" ] game = "on"
def pokfight(): fightmon = wpok[randint(0,5)] outcome = [ "You caught it!", f"The wild {fightmon} escaped", "The pokemon defeats you. You go to the Pokecenter to heal and then continue your search for Pokemon.", ]
print(f'You have encountered a wild {fightmon}.') q1 = input('Do you want to fight or run? ') if q1 == 'fight': print(outcome[randint(0,2)]) print('Welcome to Pokemon Safari. Try to catch as many pokemon as you can!') print('You walk for a bit and then finally see something.') while game != 'over': pokfight() print('You continue to search for Pokemon.') print(f'The Pokemon kills you.')
Animation Basics with Pixar in a Box
Introduction to animation (animating a ball):
https://www.khanacademy.org/partner-content/pixar/animate/ball/a/start-here-animation
Animating a character with bezier curves:
https://www.khanacademy.org/partner-content/pixar/pixar-rigging/code-character/pi/project-2-animate-your-character
Rigging a face:
https://www.khanacademy.org/partner-content/pixar/pixar-rigging/intro-to-rigging/pi/rigging-knicks-face
Combinatorix:
https://www.khanacademy.org/partner-content/pixar/crowds/crowds-1/v/intro-crowds?ref=Pixar_Recommended_videos
https://www.khanacademy.org/partner-content/pixar/crowds/crowds-1/a/hands-on-activity
Hour of code
Step 2: https://hourofcode.com/codehsturtle (python)
Chatbot: https://app.codemonkey.com/hour-of-code/trivia-chatbot/course#1
Roboblockly: https://www.roboblockly.org/curriculum/coding/hourOfCode/1.php
Pixar in a box:
https://www.khanacademy.org/partner-content/pixar/pixar-rigging/code-character/a/rig2-start
Computerart: Pixar in a box
Introduction to animation:
https://www.khanacademy.org/partner-content/pixar/animate/ball/a/start-here-animation
Combinatorix:
https://www.khanacademy.org/partner-content/pixar/crowds/crowds-1/v/intro-crowds?ref=Pixar_Recommended_videos
https://www.khanacademy.org/partner-content/pixar/crowds/crowds-1/a/hands-on-activity
Rigging a face:
https://www.khanacademy.org/partner-content/pixar/pixar-rigging/intro-to-rigging/pi/rigging-knicks-face
Animating:
https://www.khanacademy.org/partner-content/pixar/pixar-rigging/code-character/pi/project-2-animate-your-character