0% found this document useful (0 votes)
20 views3 pages

Activity CT4

The document outlines activities for Year 10 students focused on computational thinking, specifically input, integers, and debugging in Python. It includes tasks such as writing programs to store user input, calculating area and volume, and handling data types like integers and floats. Additionally, it emphasizes debugging by illustrating common errors, such as attempting to convert a string to a float.

Uploaded by

afomyasm
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)
20 views3 pages

Activity CT4

The document outlines activities for Year 10 students focused on computational thinking, specifically input, integers, and debugging in Python. It includes tasks such as writing programs to store user input, calculating area and volume, and handling data types like integers and floats. Additionally, it emphasizes debugging by illustrating common errors, such as attempting to convert a string to a float.

Uploaded by

afomyasm
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/ 3

TOPIC 1: COMPUTATIONAL THINKING

Input, integers and debugging

ACTIVITIES FOR Y10-01-CT4


Name ____________________________________________ Date __________________

Activity 1
• Write a program that asks for a user’s name and favorite food and stores the values as
variables with sensible and useful names.

• Add code to print out the user’s answers using the variables.

Activity 2
• Copy and run this code.
height = int(input("Enter height: "))
width = int(input("Enter width : "))
area = height * width

• Amend this code to:


o output the result of the area calculation
o ask the user for a value for depth and store the value in an appropriate variable
o calculate the volume of the shape (area * depth) o output the result of the
volume calculation.

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only. This material is not copyright free.
TOPIC 1: COMPUTATIONAL THINKING

Input, integers and debugging

Code

Result

Activity 3
Using Python code, complete these exam-style tasks.
• Create an integer variable called charCounter and assign it the value 0.

• Create a float variable called trackLength. Ask the user to enter a number and convert
it to a real number. Hint: this is done using the code (float()).

• Create a string variable called gender. Ask the user to enter their gender.

• Create an integer variable to represent the height of a person in centimetres (cm). Give it
a sensible name and assign it an appropriate value. Ask the user to enter their height in
cm and convert it to an integer.

Code

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only. This material is not copyright free.
TOPIC 1: COMPUTATIONAL THINKING

Input, integers and debugging

Result

Activity 4
• Add to the program from Activity 3 so that the user’s gender and height are output on the
same line.

• Add to the program so that trackLength is output with a suitable message.

• Add the following line of code:


name = float(input("Enter your name: "))

Run the program and enter your It shows a Value error that says it can’t change
name when prompted. Explain from string to float. This happened because in
what happens when you do this. my code I specifically told the computer that the
value name must be a float.

© Pearson Education Ltd 2020. Copying permitted for purchasing institution only. This material is not copyright free.

You might also like