0% found this document useful (0 votes)
12 views

A3 Worksheet - Mini Data Collection Program

Uploaded by

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

A3 Worksheet - Mini Data Collection Program

Uploaded by

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

KS4 - Programming Activity sheet

Lesson 4 - Input

Mini data collection program

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.

1 print("What is your first initial?")


2 initial = input()
3 print("What is your surname")
4 surname = input()
5 print("What is your age?")
6 age = int(input())
7 print("True or False - you like marmite")
8 likes_marmite = input()
9 marmite = "True"
10 decades = float((age / 10))
11 print("Well hello",initial, surname)
12 print("It is", likes_marmite==marmite, "that you like marmite.")
13 print("This is probably because you are", decades, " decades old")

Page 1 Last updated: 14-05-21


KS4 - Programming Activity sheet
Lesson 4 - Input

Write your prediction in the box below:

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:

Page 2 Last updated: 14-05-21


KS4 - Programming Activity sheet
Lesson 4 - Input

Investigate .
Questions/activities Your answers ▿

String
What data type is being collected at line 2?

It adds the characters i added to my initial name


Run the program and type more than 1 character when asked for your
first initial.
What happens?

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

It shows error in that line(line 6)


Run the program and type in some string (text) when you are asked
for your age. What happens?

Because it is asking for a integer and a string is being inputted


Why do you think this happens?

It shows false that you don't marmite


Run the program and type in all lower case true when asked if you like
marmite. What happens to the marmite message?

Page 3 Last updated: 14-05-21


KS4 - Programming Activity sheet
Lesson 4 - Input

It shows true you like marmite.


Run the program and type in True when asked if you like marmite.
What happens to the marmite message?

It printed out false


Run the program and type in hello when asked if you like marmite.
What happens to the marmite message?

Line 12 contains the following piece of code likes_marmite ==


marmite". What do you think might be happening here?

It printed out 0.9 decades


Run the program and type 9 when you are asked for your age. What
happens?

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?

As a integer it gives it out as a whole number but as foat it gives it out as


What do you think is happening when the number is held as an integer
a decimal
and compared to a float?

Page 4 Last updated: 14-05-21


KS4 - Programming Activity sheet
Lesson 4 - Input

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.

Page 5 Last updated: 14-05-21

You might also like