• Homework
  • Thirds
  • Upper Thirds
  • Fourth
  • Divisions
    • ICT
    • Computer Science
  • Fifth
  • Lower Sixth
  • Upper Sixth
    • Upper Sixth Theory
  • Blog
  • Careers
  • Unity
  • Networking
computinglesson.com
Python part two names and types from grahamwell

Fourth Form Computing Programming Challenges in Python

Section 1.  Input and Output


1

Picture
Write a program that will display a joke.

Don't display the punchline until the reader hits the enter key.

Can you extend this so that the computer tells you a Knock Knock joke?

You'll need to use the print command



2

Picture
Write a program that will ask you your name.
It will then display 'Hello Name' when 'Name' is the name you have entered.

You'll need to use the raw_input command and assign it to a variable.
For more help with input, click here


3

Picture
Write a program that will work out the areas of a rectangle.

Collect the width and height of the rectangle from the keyboard.
For help using input, click here

Calculate the area and display the result.

You'll need two variables this time, use the multiplication operator *


Section 2 - Using the timer library

For the challenges below you'll need to import the time library into your code.  This is easy, on the first line of your program write:
import time

4

Picture
Write a program that will test the users reaction time.
Start with a message to get ready, use time.sleep(2) to give them two seconds.  Then say 'NOW'
Measure the time with myvariablename = time.time()
Use raw_input() to get the user to press the enter key
Measure the time again
Subtract the start time from the end time and display the result


5

Picture
Write a program that will find out how quickly the user can type all the letters of the alphabet in order.
Wait and measure the time as in the example above.
Check that the letters entered are correct, by comparing the raw_input() with the correct input.
Complain if the letters are not right or in order.

Powered by Create your own unique website with customizable templates.
Photos from bertknot, heliosphan, Luigi Rosa, Filter Forge, Matt McGee