0% found this document useful (0 votes)
9 views8 pages

Unit 4 - Worksheet - W1

Hi

Uploaded by

hareemkhalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views8 pages

Unit 4 - Worksheet - W1

Hi

Uploaded by

hareemkhalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

AY 2023-2024

Subject: Computing Worksheet

Name: _________________________Year: 8 Section: ____ Date: _________________

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.

Task1: Write a python program for the given scenario.


 You have been shopping and bought three items.
 The first item is a T-shirt that cost $4.
 The second item is a jumper that cost $12.
 The final item is a hat that cost $5.
 How much did you spend in total?
……………………………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………………………

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.

……………………………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………………………………………………………………………

Task4: A local swimming centre offers the following discounts.


• Members who are aged 13, 14 or 15 receive a 30% discount.
• Members who are aged 16 or 17 receive a 20% discount.
• Members who are aged 50 and over receive a 40% discount.
 All other members pay the full price.

# Input member's age


age = int(input("Enter member's age: "))

# Input the original price


cost = float(input("Enter the original price: "))

# Check the discount based on age


if age >= 13 and age <= 15:
discount = 0.3
elif age >= 16 and age <= 17:
discount = 0.2
elif age >= 50:
discount = 0.4
else:
discount = 0 # No discount for other members
# Calculate the discounted price
finalCost = cost - (cost * discount)
# Print the discounted price
print("Discounted price: $" ,finalCost)

Page 2
Determine the data types for the different variables and justify your choice.

Predict the output based on the following inputs.

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

# Print the output


print("The result of", num, "times", multiple, "is:", output)

Complete the table below using the python program.

num multiple output

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

You might also like