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:

studio.code.org/sections/WHZNZK

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

 jumpto.cc/python-new

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.

Tinkercad

https://www.tinkercad.com/joinclass/1GLG2Q3SVBR1

Mars: mars7987

Lawrence: lawrence2080

Alan: alan7099


Demo: demo9974

Making websites with Google Sites

We are going to make a simple website with Google sites, like this:
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/python3

We 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.

name = input('What is your name? ')
print(f'Hello {name}.')

Activity 1:

Now try asking their favorite color. Create a new variable color, and call for input asking for their favorite color.
Print a response from the computer, such as I like _____ too!

Activity 2:

This is a piece of code to create a poem. Find the bugs and fix them. The color of the words can help you find the mistakes.
We use \n for line breaks. Add the missing line breaks to make it into a 4 line poem.

Poem1 = input('Type a color: ')
poem2 = input('Type a plural noun: ')
poem3 = input('Type a plural noun: ')
poem4 = input(Type an adjective: )


print(f'Roses are {word1},\n {word2} are blue,{word3} are {word4} and so are you.')

Activity 3:

Here is a madlib story. Can you find and fix the mistakes?
word1 = input('Type a noun: ') word2 = input('Type a plural noun: ') word3 = input('Type a place: ') Word4 =input('Type a time of day: ') word5 = input('Type your name: ') word6 == input('Type a number: ') word7 = input('Type a another number: ') word8 = input('Type a plural noun: ') word9 = input 'Type a verb: ' print("\n) print('Giant {Word1} Attacks {word3}') print(f'By: {word5.') print f'The people of {word3} are confused and afraid after a giant {word1} attacked {word3} yesterday {word4}. {word6} people died and {word7} were badly hurt in the attack. People tried throwing {word2} and fighter jets shot {word8} at the giant {word1}, but it was of no use. Police are advising anyone who sees the giant {word1} to {word9}.'


Part B

A Python Story Generator with lists

Let's go one step further and make a story generator that doesn't require user input. We will create lists of words and then pick them randomly.
First let's create a list and print its contents.
words = ["I", "cat", "you", "am", "dinosaur", "alien", "?", "a"]

We can print list items like so:
Print (words[4])


Activity 1:

Paste both lines of code into Python. Which word does it print? Why that word?

Activity 2:

What does the following code print:
print (f'{words[0]} {words[3]} {words[7]} {words[4]}{words[9]}')

Activity 3:

Change the numbers in the code and try to make your own sentence.

Activity 4:

We can also use randomly generated numbers to choose random words. First we need to tell python to get ready to use random numbers.
Start your code with:
from random import randint

And then try running this code:
words = ["me", "cat", "you", "dinosaur", "alien", "fish", "robot"]
print (f'You are a {words[randint(0,6)]}.')

Run the code several times and see if you get the same answer.

Activity 5

Add four more words to each list and change the range of the random numbers:

from random import randint
nouns = ["cat", "princess", ]
adjectives = ["green", "ugly", ]
places = ["the beach", "Suntek", ]

adj1 = adjectives[randint(0,1)]
noun1 = nouns[randint(0,1)]
noun2 = nouns[randint(0,1)]
place1 = places[randint(0,1)]

print (f' Once upon a time there was a {adj1} {noun1} . The {noun1} lived in a {noun2} in the middle of {place1}.')


Activity 6

Now try to create your own game!

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.')

拔萝卜 Chinese song midi and music sheet

download midi ba luo bo 拔萝卜

I couldn't find the midi file for ba luo bo (拔萝卜) for my daughter, so I made this midi and music sheet quickly.

TEXT FOR ERICS PROJECT

Welcome to Suntek Elementary School

The Octagonal Tower 八角塔
The Church 大禮拜堂
The Christmas Tree 聖誕樹
The Bell Tower 埔頂鐘聲
Rugby Field 橄欖球場
Sun-Tek Kindergarden幼兒園
The Stone Plate House 石板屋
The Coffee Shop 尋根園
The Garden 花園
The Girls' School Building
Our School's Song 校歌