Little Big Data

1 Re-introduction to Python

Research It

  • Click here and choose a "joke". Open IDLE and get the computer to output your joke.

Code It

  • Now add your joke.
  • Stuck?
  • print ("message here")


2 Perfunctory Steps

Learn It

  • Perfunctory(click link for definition)
  • Let's wrap our joke in a function so we can use it again and again.
  • A function is a piece of code that we may want to use again and again.
  • This makes for less code and more efficient testing.

Code It

  • Add the below code:

def joke1(): your print statements here

joke1() # this will call the joke

  • Stuck?


  • Add two more 'jokes' to your program as functions joke2 and joke3

3 Choices

Learn It

  • Currently our joke is static, we need to get active and responsive.
  • We use variables to store data, so let's ask a question.

Code It

  • Add the code below to add a variable so we can response to the answer.


Learn It

  • Now we have an answer; we can respond. The keywords for choice are if / elif / else. There should always be one if and one else. If you need more decisions just add more elif inbetween the if and else. This allows us to make branching programs that are able to interactive with the user. For if and elif statements we need to compare.
  • We can use several symbols to compare answers in different ways - choice making choices?
  • < Less than
  • > More than
  • == same as
  • != or <> not the same as
  • For the else statement we do not need a comparator as it is just everything else.

Code It

  • Add the code below so we can response to the answer.


  • Expand it!: Now get your code to call all three functions based on your response to the first question.
  • Stuck? It should look like this.


Badge It - Silver

  • Upload a screenshot/screen clip of your code with 3 jokes in functions,input variable and conditionals.

4 Let's go round again

  • We want our user to be able to choose several times to 'enjoy' all of our witty jokes.
  • Action Point: Add the following code.


  • Debug Time!
  • What's wrong with the code? (6 to find)


Badge It - Gold

  • Add screenshots of debugging and use of libraries in our code.

5 Comedy is all about timing

  • Add this to your first line import time, datetime.
  • This will bring a whole series of commands involving time and date.
  • Now add the extra code:


  • Yeah… much funnier…

6 Accessing more comedy

  • A text file has been added with some of the best jokes…
  • I want to import them into Python and then choose a random joke each time.
  • Start a new file - CTRL + N.
  • Save as 'accessing the'
  • Open and save the following text file.
  • Click here to open the jokes text file.

Code It

  • Use the code below to get python to open and read the file.


  • Now let's add a search facility.


Badge It - Platinum

  • Add a screenshot showing you using the code provided to access and use a text file using Python's ability to read and search.