Friday 22 April 2016

Python Practice Assignments

Python Practice Assignments

As the test nears, try these assignments.  If you can't do them, you -will- fail the test.
The test will be based on these.  It is open book and you can reference them.  You will not need to hand these in, but I am allowed to ask you to modify the answers to these exercises on the test.  If you don't have the answers, you may not be able to finish the test in time.


Exercise #1
Create a program that asks you to enter a number
·         If the number greater than 10 it says “Too high!”
·         If the number is less than 10 it says “Good!”
This can be done in 5 lines

Exercise #2
The program asks you what you got on the test
·         If you got higher than 80, it says “Great!”
·         If you get lower than 50, it says “Bad!”
·         If you get between 50 and 80 it says “You need to improve!”
This can be done in 7 lines!

Exercise #3
You have $10 in your wallet.  Make a program that looks at what you can buy from a menu.
       There are 3 items you can buy:
o   $5 – chips, $10 – cake, $15 – pizza
       It asks you what you want to buy
       If you can afford it, it says you bought it

Exercise #4
Create a program that asks you what your name is
       It will keep asking you what your name is until you say your name is “Bob”
This can be done in 4 lines

Exercise #5
Make a program that calculates your average mark.
·         It will ask you how many marks you want to enter
·         It will ask you for each mark
·         It will tell you the overall average after you enter the last mark
The output will look like this:

This can be done in 8 lines!

Exercise #6 (need Lesson 6 for this)                                                                                                              
Rewrite the answer to Exercise #5 using For-Loops

Exercise #7 (need Lesson 7 for this)
Create a program that plays Rock-Paper-Scissors with you. 
       The user picks 1, 2, or 3 to represent rock, paper or scissors
       If the user enters a different number, it asks for a number again
       It tells the user if they won, tied or lost, then asks if they want to play again.
       The output should look like this:




This can be done in 45 lines!

No comments:

Post a Comment