0% found this document useful (0 votes)
61 views23 pages

Full Unit-7.1 Worksheets - Copy 1

The document consists of a series of worksheets focused on programming concepts, particularly using Python. It includes exercises on tree planting calculations, identifying errors in code, understanding data types, and creating flowcharts for various scenarios. The worksheets also cover input/output operations, casting data types, and calculating outputs based on given inputs.

Uploaded by

hi
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)
61 views23 pages

Full Unit-7.1 Worksheets - Copy 1

The document consists of a series of worksheets focused on programming concepts, particularly using Python. It includes exercises on tree planting calculations, identifying errors in code, understanding data types, and creating flowcharts for various scenarios. The worksheets also cover input/output operations, casting data types, and calculating outputs based on given inputs.

Uploaded by

hi
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/ 23

Worksheet 1

7.1.1
Use a highlighter to identify the important bits of information in the text
that help you to answer the questions below.

There are 13 Ashoka trees currently in the park. Park workers will plant 28 more
Ashoka trees today and 36 more Ashoka trees tomorrow. It will take 10 workers 8
hours to finish the project.

Using the information that you have highlighted, answer the following
questions. Make sure you show your working.

1 How many Ashoka trees will the park have when the workers are finished?

2 How many trees were planted in 1 hour?

3 6 of the workers planted 8 trees each. The other workers each planted an equal number
of trees. How many trees did each of the other 4 workers plant?
IDLE programming environment

Look at the Scratch and IDLE programming environments above. Write the similarities and differences between
them in the table below.

When looking for similarities and differences, think about:


• Is there a specific area in which to do the programming?
• Do both provide you with areas to select the code you need?
• What happens when you run a program?
• What can you do if you get stuck?
Similarities Differences
Worksheet 5
7.1.2
1 Write the Python code that would display the following outputs.

Output Code
print("Good afternoon")

print("What is 10 – 2?")
print("8")

2 What is wrong with the following code?

Code What’s wrong?


print(Hello how are you")

print("15+5")

Print("Hello World")

print(10+"2")

print("What a lovely day"


Worksheet 6
7.1.2
Draw lines to match the code to the output.
Worksheet 7
7.1.3
1 Identify the errors in the program below that prevents it from displaying
the output shown.

Current code with errors:

What the program should do:

2 For each error rewrite the correct code.

Line number 1

Corrected code

Line number 2

Corrected code

Line number 4

Corrected code

Line number 5

Corrected code

Line number 6

Corrected code
Worksheet 8
7.1.3
Using the example code below, decide whether each variable is a string, an
integer or real and then given an explanation of why it is that data type.

Variable name Variable Data type Explanation


name
Name on bank name
card
Bank card cardNumber
number
Bank account balance
balance

Address address

Age age
Worksheet 9
7.1.3
1 Fill in the gaps with the correct Python code so that the program runs
correctly. Use the code in the box below.
An example has been done for you.

input name birthMonth print


print birthYear ") "Ahmed"

name = "Ahmed"
__________ = __________("Enter your birth month:__________
__________ = input("Enter the year you were born:")
__________("Hi",__________,"thank you for telling me you were
born in",birthMonth)
__________("The year you were born in was",birthYear)

2 What is the data type of the name variable? __________

3 What is the command to ask the user to enter data into the program?
__________
Worksheet 10
7.1.3
1 Complete the table to explain what each line of Python code does.

Code What does it do?


print("Hello World")

name = input("Enter your name: ")

number = 15

2 Provide definitions for each of the data types listed below and give an
example.

Data type Definition Example

String

Integer

Real
Worksheet 11
7.1.4
1 Identify the errors in the program below that would prevent it from
running. The code below should allow the name of the player to be
input and then output their highest score and average score. Write the
corrected code. An example has been done for you.

Current code with errors:

Line number 1

Corrected code name = input("Enter your name: ")

Line number 2

Corrected code

Line number 4

Corrected code

Line number 6

Corrected code

2 Which data type would each of these variables be?

Variable name Data type


name

highScore

averageScore
Worksheet 12
7.1.4
The table below shows the Python code used to cast data to different data
types.

Data type Code to cast

string str()

integer int()

real / float float()

1 Rewrite the Python code below so that each input is cast to the correct
data type. An example has been completed for you.

Current code Code with the correct casting applied


number = input("Enter a whole number = int(input("Enter a
number:") whole number:"))

city = input("Enter a city: ")

height = input("Enter your


height in metres e.g. 1.76: ")

year = input("Enter the year you


were born: ")

month = input("Enter a month:")

km = input("Enter the number of


kilometres:")
2 Identify the names of the different flowchart symbols and state what
they are used for.

Name: Name: Name:


Use: Use: Use:
Worksheet 13
7.1.4
Read the following scenario:

Amir wants to know how many guests are attending an event so that he can calculate
how many sandwiches to make. He also needs to know how many of the guests are
vegetarian.

If they are vegetarian, they will get a cheese sandwich; if not, they will get a chicken
sandwich.

The program should output the number of cheese sandwiches required and the number
of chicken sandwiches required.

Create a flowchart for this scenario. Below is a reminder of the different


symbols you should use:

Symbol Purpose

Used at the start and end of a flowchart to


signify the start and end

Used when data needs to be input and/or


output from a program, e.g. input number 1

Used when something needs to happen,


e.g. add two numbers together
Worksheet 14
7.1.5
Identify the output for each set of values provided for each flowchart.
You may wish to use a calculator to help you to calculate your answers.

Flowchart 1 Flowchart 2

Complete the table below using the flowchart Complete the table below using the flowchart
above: above:

num1 num2 output score1 score2 output

15 21 75 85

19 41 43 72

16 23 85 60

67 58 32 28
Worksheet 15
7.1.5
Using the interactive mode in Python, enter the following calculations and
record the answers.

Then apply BIDMAS to give the desired answer and record the calculation
you need to get this answer.

Calculation Answer Desired Answer Calculation to get


desired answer
5*8+6 46 70 5 * (8 + 6)
35 – 10 + 15 10
9+3*5 60
9 * 8 – 20 / 5 10.4
60 * 40 – 3 * 4 8880
18 * 6 – 2 / 8 9
Worksheet 16
7.1.5
The program below should ask the user to enter the cost per DVD and the
number of DVDs bought. It should then work out the total cost and
subtract the discount. Finally, it should output the discount and the total
cost.

Rewrite the code below, correcting the errors that are preventing the
program from running. There are five errors in the code.

Line number Correct code

1 discount = 15

5
Worksheet 17
7.1.6
Identify the output for each set of values provided for the flowchart below.

Complete the table.

,
score1 score2 Output

25 45

70 90

55 45

40 100
Worksheet 18
7.1.6
Read the following scenario:

A student completes three tests in school. Each test is scored out of 100.

The teacher wants to input all three scores and get the program to calculate the mean
average score.

If the average is greater than 60, then the program should say that the student has
passed.

If the average is less than 60, then the program should check whether it is greater than
40. If it is, then the program should say that the student can re-sit the tests.

If the average is below 40, then the program should say that they have failed.

Create a flowchart for this scenario. Below is a reminder of the different


symbols you can use.

Symbol Purpose

Used at the start and end of a flowchart to


signify the start and end

Used when data needs to be input and/or


output from the program, e.g. input number
1

Used when something needs to happen,


e.g. add two numbers together

Used when a decision has to be made and


there are two possible outcomes; the
decision should be written inside the
diamond
Worksheet 19
7.1.7
Examine this flowchart.
Use the flowchart to identify what the output would be for each of the
following inputs.

number1 number2 operation Output


25 19 2
52 23 1
6 9 3
15 78 1
Worksheet 20
7.1.7

Using the flowchart above, calculate the output for each of the values in
the table below.
Age Mark Output

13 40

14 15

15 50

16 90

17 30

You might also like