External Exam Download Resources Web Applications Games Recycle Bin

challenges (python 2)


how many of these can you do in Python?
  1. Write a program that asks a user the colour of a traffic light. If it is a “green” light, output “go”. If it is a “yellow” light, output “wait”. If it is a “red” light, output “stop”. use a function / method
  2. try to get your program to simulate a 'pause' for x second(s)..   help
  3. write a program that calculates simple interest. Challenge: put the formula to calculate simple interest into a method
  4. write a program that counts from 0-50, and for each number counted the program tells me if it is an even or odd number
  5. write a program that uses a method to find the area of a rectangle
  6. write a program that adds together all the even numbers from 0 to 100 (use modulo operator: %)
  7. Write a program that adds all the odd numbers together from 1 to n (where n is a number inputted by a user)
  8. Write a program that uses a method to calculate the area of a circle
  9. finish the bank example - so that i can withdraw, deposit, get account balance, and perhaps a list of my last 3 transactions if possible
  10. Write an algorithm and program that inputs 5 numbers into an array, then reads the contents of the array to calculate the average
  11. Write an algorithm that lists prime numbers between 1 and 20
  12. Code the algorithm that lists prime numbers between 1 and 20 (use mod / %)   help
  13. sort a simple array of five integer elements into ascending order (try 4 different types of sort - bubble, merge, insertion and quick sort)
  14. implement a Fisher–Yates shuffle in Python
  15. write a program that finds the max, min and average of an array of 5 integers
  16. try and sort an array of n integers into descending order (where n is a whole integer number inputted by the user)
  17. implement either the nearest neighbour algorithm, or the stable matching algorithm in python
  18. write a multidimensional String array that stores the location of 3 sunken treasures (use the String value "Sunken Treasure" to designate this) at 3 random co-ordinates on an x and y axis to simulate a map of the ocean (you can limit the axis to values between 0 and 10)
  19. right a recursive python program to calculate the factorial of a number, e.g. 5! = 5 * 4 * 3 * 2 * 1 = 120
  20. currency converter: Write a program that converts any integer or floating point value to a currency string, e.g. 4 = “four dollars”
  21. Naughts and crosses: The game board is represented by three lines of text:

    123
    456
    789

    Player “X” goes first:
    X23
    456
    789

    Player “O” goes next:
    X23
    4O6
    789

    The game continues until all 9 squares are filled.
    Challenges: Make Player “O” a computer player (so randomise their move). Make it check for “3 in a row” after each go, and display the winner if there is 3 in a row
  22. card deck: create an OOP class for a deck of cards with the methods shuffle() and drawOneCard(). also create a constructor that populates the deck.
  23. create a Player class (Object Oriented Programming) with a variable healthset to 100 when an object of the class is instantiated (ie created). add the methods gainHealth(int amt) and loseHealth(int amt) to the class. write code for these, where amt is the amount of health i gain / lose when the functions are called.
  24. complete the game of "battleships" using the multidimensional array examples. challenge: do it with methods (so make it modular, which means keep the main method short). epic mlg challenge: do it using object oriented programming techniques