A3 Worksheet - Mini Data Collection Program
A3 Worksheet - Mini Data Collection Program
Lesson 4 - Input
Predict .
Take a look at the code below. Read it carefully and try to make a prediction about what might happen when this code is executed.
Run .
Open and run the file with this code. Here’s a copy of the code (ncce.io/ks4-minidatacollect), if needed.
Was your prediction correct? Did anything unexpected happen? Write down your thoughts below:
Investigate .
Questions/activities Your answers ▿
String
What data type is being collected at line 2?
Because I stored all the characters under the variable “initial”. So it will
Why do you think this is?
add it
Okay
Does Python have a function for char? Take a look at this link and read
the documentation carefully: ncce.io/pythonfunctions
Division
On line 10, the forward slash / is being used between the variable age
and the number 10. What arithmetic operation is the forward slash
performing?
It is printed it as 0
On line 10, change the word float to int. Run the code and type in 9
as your age. What happens?
It printed it out as 2.
Keeping line 10 as int. Run the code and type in 28 as your age. What
happens?
Explorer task .
Create a new program for a gym membership. Try to use all of the techniques used in this activity in your new program.
Resources are updated regularly — the latest version is available at: ncce.io/tcc.
This resource is licensed under the Open Government Licence, version 3. For more information on this licence, see ncce.io/ogl.