COMPUTER SCIENCE CAFÉ
  • WORKBOOKS
  • BLOCKY GAMES
  • GCSE
    • CAMBRIDGE GCSE
  • IB
  • A LEVEL
  • LEARN TO CODE
  • ROBOTICS ENGINEERING
  • MORE
    • CLASS PROJECTS
    • Classroom Discussions
    • Useful Links
    • SUBSCRIBE
    • ABOUT US
    • CONTACT US
    • PRIVACY POLICY
  • WORKBOOKS
  • BLOCKY GAMES
  • GCSE
    • CAMBRIDGE GCSE
  • IB
  • A LEVEL
  • LEARN TO CODE
  • ROBOTICS ENGINEERING
  • MORE
    • CLASS PROJECTS
    • Classroom Discussions
    • Useful Links
    • SUBSCRIBE
    • ABOUT US
    • CONTACT US
    • PRIVACY POLICY
CODING CHALLENGES | IF STATEMENTS
Enjoy the journey of learning to code, explore and be creative
ON THIS PAGE
CHALLENGE 1 | HOW IS YOUR DAY
CHALLENGE 2 | MY SECOND CALCULATOR
CHALLENGE 3 | GRADE SYSTEM
​CHALLENGE 4 |CHAT BOT IS BACK
CHALLENGE 5 | NUMBER GUESSING GAME
​CHALLENGE 6 | PARCEL DELIVERY
CHALLENGE 7 | DEBUGGING
Picture
SUBSCRIBE FOR SAMPLE SOLUTIONS
ALSO IN THIS TOPIC
LEVEL 1 | GETTING STARTED
 LEVEL 2 | VARIABLES AND USER INTERACTION
LEVEL 3 | DATATYPES AND OPERATORS
YOU ARE HERE | LEVEL 4 | IF STATEMENTS
LEVEL 5 | LOOPS
​LEVEL 6 | ARRAYS / LISTS
LEVEL 7 | FUNCTIONS
LEVEL 8 | ALGORITHM DESIGN
LEVEL 9 | OOP
LEVEL 10 | EXTERNAL DATA HANDLING
TURTLE CHALLENGES
DEBUGGING AND TRACING​
CHALLENGE SOLUTIONS

Picture
WATCH THIS VIDEO TO HELP YOU WITH THIS SECTION
Picture
CHALLENGE 1 | HOW IS YOUR DAY
Create a program to do the following:
A: Ask the user If it is sunny, raining or snowing outside
B: If the user replies ‘sunny’ then output ‘Great, remember your hat’
C: If the user replies ‘raining’ then output ‘Remember your coat’
D: If the user replies ‘snowing’ then output ‘Great, remember your ski’s’
E: if the user replies with any other comment then output ‘ OK, have a good day’
EXAMPLE OUTPUT
What is the weather like today?  Sunny
Great, remember your hat
EXTENSION TASK
Adapt you program to work if the user types in any variation of capital letters or lowercase letters.
HINT: You could use one of the following 3 methods to do this:
.lower()     .upper()   .title()
Picture
Picture
CHALLENGE 2 | MY SECOND CALCULATOR
Create a program to do the following:

1: Ask the use what type of calculation they would like to do 1: Add  2: Subtract  3: Multiply
2: Ask the user to enter a number
​3: Ask the user to enter another number
4: Create a variable to hold the answer and perform the appropriate calculation
​5: Output the answer in a user-friendly sentence.
Picture
CHALLENGE 3 | GRADE SYSTEM
Create a program using a single IF, then, else statement to do the following:
A: Ask the user for a test score 0 - 100:
B: If the test score is greater than 80 the output - Your Grade is: A
C: If the test score is greater than 60 the output - Your Grade is: B
D: If the test score is greater than 50 the output - Your Grade is: C
E: If the test score is greater than 40 the output - Your Grade is: D
F: If the test score is less than 40 the output - Your Grade is: E
EXAMPLE OUTPUT
​Please enter your score : 65
Your Grade is B
Picture
​CHALLENGE 4 |CHAT BOT IS BACK
Create a program to do the following:
A: Ask the user how old they are: How old are you? 
B: Ask the user if the go to school or have a job. Do you go to school or have a job ?
C: IF the user replies school, and IF the user is younger than 19 then ask the user ‘What is your favourite subject’
D: IF the user replies school, and IF the user is older that 18 then output ‘You must be a little old for school’
E: IF the user replies ‘job’ and IF the user is younger than 17 then output ‘ You seem a bit too young to have a job’
F: If the user replies ‘ job’ and IF the user is older than 16 then ask the user ‘Where do you work? ‘
EXAMPLE OUTPUT
How old are you?  24
Do you go to school or have a job school/job? Job
Where do you work? Microsoft
Cool, Microsoft
Picture
CHALLENGE 5 | NUMBER GUESSING GAME
Create a program to do the following:
1: Generate a random number or use the two lines of code below to generate a random number, firstly to import random, secondly to produce a random number and save it in a variable called 'num'.
#FOR PYTHON CODERS
import random
num = random.randint(1,20)
2: Ask the user to guess a number.
​3: IF the user guesses too high then output 'You guess too high, please guess again'.
4: IF the user guesses too low then output 'You guess too low, please guess again'.
​5: IF the user guesses correct then output 'You guess correct, well done!'.
EXAMPLE OUTPUT
Please guess a number between 1 and 20: 14
You guess too low, please guess again: 18
You guess too high, please guess again: 15
You guess correct, well done!
EXTENSION TASK
​A: Add a loop to your program so it gives the user 3 changes to guess the correct number.
B: Add a scoring system to your program.
Picture
Picture
​CHALLENGE 6 | PARCEL DELIVERY
Create a program to calculate the cost of parcel delivery by doing the following:
1: Ask the user to enter the weight of the parcel in kg.
2: Ask the user to enter the height of the parcel in cm.
3: Ask the user to enter the width of the parcel in cm.
4: Ask the user to enter the length of the parcel in cm.
5: IF the height + width + length are greater than 200cm then output ' This parcel is too big, it has been rejected'.
6: IF the parcel is less than 5kg then the cost of delivery is $10.00

7: For every additional 5kg the parcel weighs add an extra $7.00 to the price
​(assign the next price increase when the parcel reaches the next weight increment, 10, 15, 20 etc) 
8: Output the total cost of delivery in a user friendly sentence.
EXAMPLE OUTPUT
Please enter the weight of the parcel in kg: 12
​Please enter the height of the parcel in cm: 50
Please enter the width of the parcel in cm: 40
​Please enter the length of the parcel in cm: 60
The total cost of sending your parcel is: $24.00
Picture
CHALLENGE 7 | DEBUGGING
The code below has 3 syntax error.

    
1: What are the 3 errors and how would you correct them?
Picture
Picture
NAVIGATION
LEVEL 1 | GETTING STARTED
LEVEL 2 | VARIABLES AND USER INTERACTION
LEVEL 3 | DATATYPES AND OPERATORS
LEVEL 4 | IF STATEMENTS
LEVEL 5 | LOOPS
​LEVEL 6 | ARRAYS / LISTS
LEVEL 7 | FUNCTIONS
LEVEL 8 | ALGORITHM DESIGN
LEVEL 9 | OOP
LEVEL 10 | EXTERNAL DATA HANDLING
TURTLE CHALLENGES
DEBUGGING AND TRACING​
CHALLENGE SOLUTIONS
Picture
SUGGESTIONS
We would love to hear from you
SUBSCRIBE 
To enjoy more benefits
We hope you find this site useful. If you notice any errors or would like to contribute material then please contact us.