Python mission

Introduction

Mission.png

Challenges can be done in the Dojo and / or at home

Work alone & with your neighbour &/or a group. The more the merrier!


Resources include the eBook, the sites in the “Websites & Other Resources” doc, fellow Pythoners and Mentors, & the InterWeb.

Google is your Friend. Or your favourite search engine.

If you like, think up some challenges – to share with otherDojoers. (#opensource #crowdsourcing #sharingiscaring)


1. Tell me a story…

Level You will need to understand the “Hello World” program (Chapter 3)

Challenge Write a program to ask me questions and then tell me a story like this “A long time ago in a Galaxy far far away, lived a brave handsome & brilliant Jedi Knight called Shaun Gon Ninja. He looked ageless and ever youthful but was in fact 42 years old. For breakfast every morning he had KitKats & High Caffeine Coffee. He always followed this by going to the park and rescuing kittens…” etc etc etc

2. Guess the Maths

Level You will need to have understood the “Guess the Number” game (Chapter 4)

Challenge

Design a game that

Gives the player a number Asks for a maths expression that will give that number Tells them that it is correct/incorrect Allows a certain number of guesses

Extra Credit (????)

Modify/extend the game so that

It specifies +, -, x, or / than asks for the two numbers to left & right of the operator Reverses the game and gives a maths expression and asks for the answer?


Progression

You will need to have understood Chapter 6 and beyond (but you can give it a go anyway – play with it!)

Allow the player to keep guessing until the they get it right or ending the game by putting in a word or letter answer that then ends the game (Intermediate/Advanced) Let player choose +, -, x or / versions of the game (quite Advanced)

3. Hello World – PyGame

Level

Beginner/Intermediate. Good introduction to Pygame module. Challenge

See the “pygame HelloWorld” Python script in the Dropbox repo and see what you can follow.

Can you modify/reuse the script to: Ask for and display the user name in the response Ask them what colours/shapes etc. they like and display Move the elements (using a defined function?)

4. Boids

Challenge

See the “boids” Python script http://code.activestate.com/recipes/576959/ and see what you can follow.

Can you modify and reuse the code to make it into a game? e.g.

A version of an avoidance game – can you avoid the “boids” Two person (one computer player?) – controls the boids vector – points for collisions OR avoiding collisions. Two person (one computer player?) – one chaser one follower Reuse the graphics (modify the sprites) for an Asteroids type game?

5. GAA TV Scorecard

Level

Quite Advanced

Challenge

Design a TV style score header like we see for games today, to include graphics (via Pygame or built in Python Modules) showing:

Time Played Time remaining (maybe?) Cards awarded, number of, Red, Yellow, whatever? Score for each side. For GAA, Goals & Points with total point score beneath.

Extra Credit

Modify for Rugby (Try, conversion, penalty, drop goal) and even cricket (runs scores, wickets lost, score for each batsman, score for wides, no-balls)

Progression

Include graphics (via Pygame or built in Python Modules) showing: Colours for each team. Colour codes should be variable depending on the teams, Team logos. Graphic representation of red/yellow cards below the individual team scores.

6. Birthday Paradox

Reference data for the problem:- http://en.wikipedia.org/wiki/Birthday_problem Challenge

What is the probability of any two people in a group sharing the same birthday?

Can you write some code that will take an input of the number of people in the room (the Python Group, the whole classroom, everyone at the Dojo) and calculate the probability of two of them sharing a birthday?

You can then test this by checking the birthdays in the group! Plus!! You may annoy people by finding out their birthdays! Don’t ask their ages though!!!! Big trouble may happen! 

Progression

Is it possible to check the probability of someone having a birthday on a particular day of the year?

Two people having a birthday on a particular day of the year?

7. Bob the Builder

Challenge

I install frames for doors and windows. The price I pay for doors and windows depends on timber price (which changes daily) plus some fixed costs.

Can you write me a programme that takes as an input the timber price (in linear metres) and works out for me the price of :

Door frame – 4m of timber plus 25% of timber price Window Frame – 6m of timber plus 27% of timber price Double door frame – 7.5 m of timber plus 20% of timber price

Extra Credit

I get discounts on the volume of products I buy. Can you modify your code to take an input of the number of each product and give me a price if the discounts are:

  • 5% discount if I buy 6 or more
  • 10% discount if I buy 10 or more
  • 15% discount if I buy 15 or more