Unit 4 - Worksheet - W1
Unit 4 - Worksheet - W1
Learning Objectives:
Predict the outcome of algorithms and test that they meet those outcomes.
Know how to develop text-based programs using data types, including Integer, Real, String and
Boolean.
Create a Python program that uses the conditional statements IF-ELSE.
Unit
Task:4: Testing conditions: Developing games Topic: Pseudocode/Flowchart, Python programming.
Task 2: Determine whether the following conditions would return TRUE or FALSE.
Page 1
Task3: Write a program in Python that asks the user to enter a username. If the username entered is either
‘User1’ or ‘User2’, the program should display ‘Access granted’; otherwise, ‘Access denied’. Insert a screenshot
of your code.
……………………………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………………………
Page 2
Determine the data types for the different variables and justify your choice.
Task5: A Python program allows two numbers to be entered and their average calculated by adding them
together and dividing the result by 2. If the average is greater than the second number, then it should say ‘The
second number is larger’; otherwise, ‘The first number is larger’.
Page 3
Identify the errors in the code above and rewrite it correctly.
Page 4
Task6: Use the flowchart below to work out the output when the following values are entered into the
algorithm.
Page 5
Task 7: Use following Python program to answer the questions below.
Identify the data types used for each of the following variables and explain your choice.
Determine whether each test passes or fails depending on whether your expected outcome matches what the
program does. Data (Red, Blue, Yellow, Saturday)
Page 6
The following Python program has been developed to allow a user to input a number and input which multiple
of the number they want to find. These are then multiplied together to give the output.
# Input a number
num = int(input("Enter a number: "))
# Input the multiple
multiple = int(input("Enter which multiple you want to find: "))
# Calculate the output
output = num * multiple
7 8
4 7
8 6
3 2
Page 7
Complete the trace table for the given flowchart:
Label the input column.
output
7
4
8
23
Page 8