Skip to content
Learnearn.uk » Python Unit Home » Python Topic 2 – If Statements

Python Topic 2 – If Statements

Video 1 - The Basics

Video 2 - Advanced

Example

Challenge 5

Advice generator

Video won’t load? Click here for the Google Drive Version

Get the computer to ask the user is they want some advice. If they do, give them some!

Bronze

  • Ask the user to input and if they respond with yes then give them advice

 Silver

  • Use an else statement to give them a response if they don’t say yes.

 Gold

  • Use an if / elif combo to respond to all yes/no answers and an else to give a response to all other input.
  • Use the .lower() method to change all input to lowercase.

6

Days of the week nursery rythme

Can’t access Youtube? Click here.

 Bronze

  • Ask the user to enter they day of the week they were born. Print out a suitable response, based on the nursery rhyme.

 Silver

  • Add an else: statement if they input an invalid response.

Gold

  • Use the .lower() method to convert their input to lowercase.

The nursery rhyme text in full:

Mondays child is fair of face,
Tuesdays child is full of grace,
Wednesdays child is full of woe,
Thursdays child has far to go,
Fridays child is loving and giving,
Saturdays child works hard for his living,
And the child that is born on the Sabbath day
Is bonny and blithe, and good and gay.

 

7

Password Program

Can’t access YouTube? Watch the Google Drive version instead

 Bronze

  • Ask the user to enter their password. Check if the password is correct or not and print out a suitable response.

 Silver

  • Ask the user to enter both a username and password and check both, printing out a suitable response as necessary.

Gold

  • If the user enters an invalid username, print out ‘username not found’, otherwise print out ‘invalid username / password combination if anything is incorrect.

8

Mini Quiz Program

Make a  general knowledge quiz using your python knowledge from the last 2 weeks!

Can’t access YouTube? Watch the Google Drive version instead

 Bronze

  • Make a 3 question quiz that checks the user’s input against the correct answer.

 Silver

  • Make a 5 question quiz that uses .lower() to allow for capital letters or lowercase

Gold

  • Make a 10 question quiz that clears the screen in between each question.

Cheat Sheet