Grade 7 - Python Grade - : DT Assessment Development Unit

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

DT Assessment Development Unit

Grade 7 - Python

Grade -
Student Name –
Student ID No. -

Task 1:
Complete the flowchart below to print the largest of two numbers:
1.1. Draw the missing shape for the decision statement. 1 mark
1.2. Draw the two missing arrows. 2 marks
1.3. Label the decision arrows with YES or NO. 2 marks
1.4. Complete the two output boxes with appropriate statements. 2 marks

Start

Read a and b

If a > b?

Stop

DT – Summative Assessment – G3 – Term 1(2018 – 19) Page 1 of 5


DT Assessment Development Unit

1d. Complete the following code in a new Python file to print the largest
of two numbers. Use the flowchart you have completed in 1c.
Save the program as “Task No – Student Name – Grade”.

1 #To find the largest of two numbers


2 a = input ("Enter first number:")
3 print ("a = ", a)
4 b = input ("Enter second number:")
5 print ("b = ", b)
4 marks
6

1e. Run the code you have written in 1d. What is your output? 1 mark

DT – Summative Assessment – G3 – Term 1(2018 – 19) Page 2 of 5


DT Assessment Development Unit

Task 2:

The following program uses a for loop to calculate and print the age and year of the
user for the next 5 years.
1 #Ask the user for their age
2 age = input ("Enter your age:")
3 #Convert this to an integer
4 age = int(age)
5 #Ask the user for the current year
6 year = input ("Enter the current year:")
7 #Convert this to an integer
8 year = int(year)

10 for num in range(1, 6, 1):


11 age = age + 1
12 year = year + 1
13 print("For year ", year, " the age is ", age)

2.1. Write the above code in a new Python file, save and run the code.
Did it work correctly? Answer “Yes” or “No”.
2 marks

2.2. Write a suitable comment in line number 9 for the for loop statement
used in the program above. 1 mark

Line 9:

DT – Summative Assessment – G3 – Term 1(2018 – 19) Page 3 of 5


DT Assessment Development Unit

Task 3: 5 marks
The program in Task 2 can also be written using a while loop.

1 #Ask the user for their age


2 age = input ("Enter your age:")
3 #Convert this to an integer
4 age = int(age)
5 #Ask the user for their year
6 year = input ("Enter the current year:")
7 #Convert this to an integer
8 year = int(year)
9 count = 1
10 #While loop starts
11 while():
12 age + age + 1
13 year = year + 1;
14 print "For year ", year, " the age is ", age
15 count : count + 1

DT – Summative Assessment – G3 – Term 1(2018 – 19) Page 4 of 5


DT Assessment Development Unit

The code above has errors in line numbers 11 - 15.

Rewrite the following lines of the code with no errors.

Line 11: 1 Mark

Line 12: 1 Mark

Line 13: 1 Mark

Line 14: 1 Mark

Line 15: 1 Mark

Task 1 Task 2 Task 3


/ 12 /3 /5
Summative Assessment Total / 20

DT – Summative Assessment – G3 – Term 1(2018 – 19) Page 5 of 5

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy