Activity CT4
Activity CT4
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
© Pearson Education Ltd 2020. Copying permitted for purchasing institution only. This material is not copyright free.
TOPIC 1: COMPUTATIONAL THINKING
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
Result
Activity 4
• Add to the program from Activity 3 so that the user’s gender and height are output on the
same line.
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.