You are on page 1of 21

Python Challenges

Everything up to if/elif/else

Using AND and OR


1) Create a program that:
• Asks the user to enter a username and password.
• If they get the username AND password are correct, display a “logged in” Otherwise,
display “Incorrect details”.
• Assume correct username= “RushB” and correct password = “CSGO”
Paste your code below:

Created by Mr Suffar
2) Create a program that:
• Ask the user if they play games on pc.
• Ask them if they play on console.
• if pc = yes and console = yes, display Game master
• if pc = yes and console = no, display pc master
• if pc = no and console = yes, display console master
• Display “Error” for any other inputs.
Paste your code below:

Created by Mr Suffar
3) Create a program that:
• Asks for the user’s age.
• If the age is between 13 and 19, display “You are a teenager”.
• If the age is 11 or 12, display “You are a tween.”
• Otherwise display “Invalid age”.
Paste your code below:

Created by Mr Suffar
4) Create a program that:
• Asks the user for current temperature.
• Asks the user if it’s raining outside.
• If temperature is less than 13 and it’s raining, display “Wear a coat and bring an
umbrella”.
• If temperature is less than 13 degrees and it’s not raining, display “Wear a coat”.
• If temperature is 13 or above, and it’s raining, display bring an umbrella.
• Otherwise display “you don’t need a coat or an umbrella”.
Paste your code below:

Created by Mr Suffar
5) Write a program that:
• Asks the user for a temperature
• If the temperature is greater than 28, display “T Shirt weather”.
• If the temperature is between 18 and 28, display “Lovely weather”
• If the temperature is less than 18, output “It’s cold”
Paste your code on the below:

Created by Mr Suffar
6) Create a program that allows the user to convert between different units:
• Ask the user for a number.
• Ask the user what unit is the data currently in.
• Ask the user what unit do they want to convert to.
• Convert between Bits, Bytes and Kilobytes.
There are 8 bits in 1 bye, and 1000 bytes in 1 Kilobytes.
Paste your code on the below:

Created by Mr Suffar
7) Create a program that:
• Asks the user to enter a username and password.
• If they get the username AND password are correct, display a “logged in” Otherwise,
display “Incorrect details”.
• Assume correct username= “RushB” and correct password = “CSGO”
Paste your code below:

Created by Mr Suffar
8) Create a program that:
• Ask the user if they play games on pc.
• Ask them if they play on console.
• if pc = yes and console = yes, display Game master
• if pc = yes and console = no, display pc master
• if pc = no and console = yes, display console master
• Display “Error” for any other inputs.
Paste your code below:

Created by Mr Suffar
9) Create a program that:
• Asks for the user’s age.
• If the age is between 13 and 19, display “You are a teenager”.
• If the age is 11 or 12, display “You are a tween.”
• Otherwise display “Invalid age”.
Paste your code below:

Created by Mr Suffar
10) Create a program that:
• Asks the user for current temperature.
• Asks the user if it’s raining outside.
• If temperature is less than 13 and it’s raining, display “Wear a coat and bring an
umbrella”.
• If temperature is less than 13 degrees and it’s not raining, display “Wear a coat”.
• If temperature is 13 or above, and it’s raining, display bring an umbrella.
• Otherwise display “you don’t need a coat or an umbrella”.
Paste your code below:

Created by Mr Suffar
11) Write a program that:
• Asks the user for a temperature
• If the temperature is greater than 28, display “T Shirt weather”.
• If the temperature is between 18 and 28, display “Lovely weather”
• If the temperature is less than 18, output “It’s cold”
Paste your code on the below:

Created by Mr Suffar
12) Create a program that allows the user to convert between different units:
• Ask the user for a number.
• Ask the user what unit is the data currently in.
• Ask the user what unit do they want to convert to.
• Convert between Bits, Bytes and Kilobytes.
There are 8 bits in 1 bye, and 1000 bytes in 1 Kilobytes.
Paste your code on the below:

Created by Mr Suffar
13) Create a program that:
• Asks the user to enter a username and password.
• If they get the username AND password are correct, display a “logged in” Otherwise,
display “Incorrect details”.
• Assume correct username= “RushB” and correct password = “CSGO”
Paste your code below:

Created by Mr Suffar
14) Create a program that:
• Ask the user if they play games on pc.
• Ask them if they play on console.
• if pc = yes and console = yes, display Game master
• if pc = yes and console = no, display pc master
• if pc = no and console = yes, display console master
• Display “Error” for any other inputs.
Paste your code below:

Created by Mr Suffar
15) Create a program that:
• Asks for the user’s age.
• If the age is between 13 and 19, display “You are a teenager”.
• If the age is 11 or 12, display “You are a tween.”
• Otherwise display “Invalid age”.
Paste your code below:

Created by Mr Suffar
16) Create a program that:
• Asks the user for current temperature.
• Asks the user if it’s raining outside.
• If temperature is less than 13 and it’s raining, display “Wear a coat and bring an
umbrella”.
• If temperature is less than 13 degrees and it’s not raining, display “Wear a coat”.
• If temperature is 13 or above, and it’s raining, display bring an umbrella.
• Otherwise display “you don’t need a coat or an umbrella”.
Paste your code below:

Created by Mr Suffar
17) Write a program that:
• Asks the user for a temperature
• If the temperature is greater than 28, display “T Shirt weather”.
• If the temperature is between 18 and 28, display “Lovely weather”
• If the temperature is less than 18, output “It’s cold”
Paste your code on the below:

Created by Mr Suffar
18) Create a program that allows the user to convert between different units:
• Ask the user for a number.
• Ask the user what unit is the data currently in.
• Ask the user what unit do they want to convert to.
• Convert between Bits, Bytes and Kilobytes.
There are 8 bits in 1 bye, and 1000 bytes in 1 Kilobytes.
Paste your code on the below:

Created by Mr Suffar
Modulus
Modulus in python works out the remainder after a
division sum. For example 10%3 = 1 since 10÷3 is 3 with 1
left over.

What will the answers to the following questions be?


Check by printing each statement in python
12%5
21%2
30%5
91%2

Modulus is a great way to check if a number is odd or


even…
Created by Mr Suffar
19) Create a program that allows the user enter a number and have the program output whether the
number is odd or even.

Created by Mr Suffar

You might also like