Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
505 views

Summative Assessment Answers - Introduction To Python Programming - Y8

This document contains answers to questions about Python programs. It provides the expected output for each program when executed. For most programs, the expected output is option D, which prints a result like "I live in Leeds". For programs with errors, the expected output is usually option D, which identifies the source of the error. The questions test concepts like variables, operators, input, conditionals, and expected behavior for different code blocks.

Uploaded by

Aisha Anwar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
505 views

Summative Assessment Answers - Introduction To Python Programming - Y8

This document contains answers to questions about Python programs. It provides the expected output for each program when executed. For most programs, the expected output is option D, which prints a result like "I live in Leeds". For programs with errors, the expected output is usually option D, which identifies the source of the error. The questions test concepts like variables, operators, input, conditionals, and expected behavior for different code blocks.

Uploaded by

Aisha Anwar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Year 8 – Intro to Python programming Summative assessment – Answers

Assessment – Answers
Sequence

Q1. Read the Python program below:

1 location = "Leeds"
2 print("I live in", location)

When this program is executed, what will be displayed on the screen?


Note: There may be errors in the program and/or it may not behave as expected.

A. "I live in", location

B. "I live in", "Leeds"

C. I live in location

D. I live in Leeds

Q2. Read the Python program below:

1 print("Where do you live?")


2 location = input()
3 print("I’ve never been to", location)

When this program is executed, what will be displayed on the screen, as a result of
executing line 3?
Note: There may be errors in the program and/or it may not behave as expected.

A. I’ve never been to and whatever the user has typed at the keyboard

B. I’ve never been to location

C. I’ve never been to input()


D. It is not possible to know the output without executing the program.

Q3. Read the Python program below:

1 answer = 3 + 13 * 3
2 print("The Answer is", answer)

Page 1 Last updated: 16-04-21


Year 8 – Intro to Python programming Assessment – Questions

When this program is executed, what will be displayed on the screen?


Note: There may be errors in the program and/or it may not behave as expected.

A. The Answer is 3 + 13 * 3

B. The Answer is 42

C. The Answer is 48

D. The Answer is answer

Q4. Read the Python program below:

1 b = 42
2 a = 13
3 print(a,b)

When this program is executed, what will be displayed on the screen?


Note: There may be errors in the program and/or it may not behave as expected.

A. 13 42

B. 42 13

C. a b

D. There is an error in the program because variables a and b are not assigned
values in the right order.

Q5. Read the Python program below:

1 print(a,b)
2 b = 42
3 a = 13

When this program is executed, what will be displayed on the screen?


Note: There may be errors in the program and/or it may not behave as expected.

A. 13 42

B. 42 13

C. There is an error in the program because variables a and b are not assigned
values in the right order.
D. There is an error in the program because when line 1 is executed, variables
a and b have not been assigned values.

Page 2
Year 8 – Intro to Python programming Assessment – Questions

Q6. Read the Python program below:

1 a = 13
2 a = 42
3 print(a)

When this program is executed, what will be displayed on the screen?


Note: There may be errors in the program and/or it may not behave as expected.

A. 13

B. 42

C. 13 42

D. There is an error in the program because variable a cannot hold two values at
the same time.

Q7. Read the Python program below:

1 a = 13
2 b = 42
3 a = b
4 print(a, b)

When this program is executed, what will be displayed on the screen?


Note: There may be errors in the program and/or it may not behave as expected.

A. 13 42

B. 13 13

C. 42 13

D. 42 42

E. There is an error in the program because when line 4 is executed, variable b


no longer has a value.

Q8. Read the Python program below:

1 a = 13
2 b = a + 1
3 print(a, b)

When this program is executed, what will be displayed on the screen?


Note: There may be errors in the program and/or it may not behave as expected.

Page 3
Year 8 – Intro to Python programming Assessment – Questions

A. 13 14

B. 13 a+1

C. a b

D. There is an error in the program because when line 3 is executed, variable a


no longer has a value.

Q9. Read the Python program below:

1 a = 13
2 a = a + 1
3 print(a)

When this program is executed, what will be displayed on the screen?


Note: There may be errors in the program and/or it may not behave as expected.

A. 13

B. 14

C. 13 14

D. There is an error in the program because there are no values for variable a
that could be used in the equation in line 3.

Q10. Read the Python program below:

1 a = 13
2 b = a + 1
3 a = 42
4 print(b)

When this program is executed, what will be displayed on the screen?


Note: There may be errors in the program and/or it may not behave as expected.

A. 14

B. 43

C. 14 43

D. There is an error in the program because variable b cannot hold two values at
the same time.

Q11. Read the Python program below:

1 a = 13
2 print(2*a)
3 print(a)

Page 4
Year 8 – Intro to Python programming Assessment – Questions

When this program is executed, what will be displayed on the screen, as a result of
executing line 3?
Note: There may be errors in the program and/or it may not behave as expected.

A. 13

B. 26

C. 13 26

D. Line 3 will not be executed because there is an error in line 2: print cannot
display expressions such as 2*a.

Selection

Q12. Read the Python program below:

1 print("What’s your favourite programming language?")


2 language = input()
3 if language != "Python":
4 print("You should try a little Python too")
5 else:
6 print("Hello Pythonista")

When this program is executed, what will be displayed on the screen, if the user
enters Python at the prompt?
Note: There may be errors in the program and/or it may not behave as expected.

A. You should try a little Python too


B. Hello Pythonista

C. You should try a little Python too


Hello Pythonista
D. Hello Pythonista
You should try a little Python too
E. There is an error in the program, because there should not be any quotes
around "Python" in line 3.

Q13. Read the Python program below:

1 print("What’s your favourite programming language?")


2 language = input()
3 if language == "Python":
4 print("You should try a little Python too")
5 else:
6 print("Hello Pythonista")

Page 5
Year 8 – Intro to Python programming Assessment – Questions

When this program is executed, what will be displayed on the screen, if the user
enters Python at the prompt?
Note: There may be errors in the program and/or it may not behave as expected.

A. You should try a little Python too


B. Hello Pythonista

C. You should try a little Python too


Hello Pythonista
D. Hello Pythonista
You should try a little Python too
E. There is an error in the program, because there should not be any quotes
around "Python" in line 3.

Q14. Read the Python program below:

1 print("What’s your favourite programming language?")


2 language = input()
3 if language != Python:
4 print("You should try a little Python too")
5 else:
6 print("Hello Pythonista")

When this program is executed, what will be displayed on the screen, if the user
enters Python at the prompt?
Note: There may be errors in the program and/or it may not behave as expected.

A. You should try a little Python too


B. Hello Pythonista

C. You should try a little Python too


Hello Pythonista
D. There is an error in the program, because there should be quotes around
Python in line 3.

Q15. Read the Python program below:

1 print("What’s your favourite programming language?")


2 language = input()
3 if language != "Python":
4 print("You should try a little Python too")
5 print("Hello Pythonista")

When this program is executed, what will be displayed on the screen, if the user
enters Python at the prompt?
Note: There may be errors in the program and/or it may not behave as expected.

Page 6
Year 8 – Intro to Python programming Assessment – Questions

A. You should try a little Python too


B. Hello Pythonista

C. You should try a little Python too


Hello Pythonista
D. Nothing will be displayed on the screen
E. There is an error in the program, because there is no else.

Q16. Read the Python program below:

1 print("Enter a number")
2 number = int(input())
3 if number > 0:
4 print(number, "is positive")
5 else:
6 print(number, "is negative")

When this program is executed, what will be displayed on the screen if the user
enters 0 at the prompt?

A. 0 is positive
0 is negative

B. 0 is positive

C. 0 is negative

D. The program will not display anything because 0 is neither positive nor
negative.

Q17. Read the Python program below:

1 print("Enter a number")
2 number = int(input())
3 if number = 0:
4 print(number, "is zero")
5 else:
6 print(number, "is non-zero")

When this program is executed, what will be displayed on the screen, if the user
enters 0 at the prompt?
Note: There may be errors in the program and/or it may not behave as expected.

A. 0 is zero
0 is non-zero

B. 0 is zero

Page 7
Year 8 – Intro to Python programming Assessment – Questions

C. 0 is non-zero
D. There is a syntax error in the condition in line 3.

Q18. Read the Python program below:

1 print("How many minutes?")


2 mins = int(input())
3 if mins <= 60:
4 print(mins, "minutes is less than an hour")
5 else:
6 hrs = mins / 60
7 print(mins, "minutes is", hrs, "hours")

When this program is executed, what will be displayed on the screen, if the user
enters 30 at the prompt?
Note: There may be errors in the program and/or it may not behave as expected.

A. 30 minutes is 0.5 hours

B. 30 minutes is less than an hour

C. 30 minutes is less than an hour


30 minutes is 0.5 hours
D. There is a syntax error in the condition in line 3.

Q19. Read the Python program below:

1 print("How many minutes?")


2 mins = int(input())
3 if mins <= 60:
4 print(mins, "minutes is less than an hour")
5 else:
6 hrs = mins / 60
7 print(mins, "minutes is", hrs, "hours")

When this program is executed, what will be displayed on the screen, if the user
enters 90 at the prompt?
Note: There may be errors in the program and/or it may not behave as expected.

A. 90 minutes is 1.5 hours

B. 90 minutes is less than an hour

C. 90 minutes is less than an hour


90 minutes is 1.5 hours
D. There is a syntax error in the condition in line 3.

Page 8
Year 8 – Intro to Python programming Assessment – Questions

Q20. Read the Python program below:

1 print("How many minutes?")


2 mins = int(input())
3 if mins > 60:
4 print(mins, "minutes is less than an hour")
5 else:
6 hrs = mins / 60
7 print(mins, "minutes is", hrs, "hours")

When this program is executed, what will be displayed on the screen, if the user
enters 90 at the prompt?
Note: There may be errors in the program and/or it may not behave as expected.

A. 90 minutes is 1.5 hours

B. 90 minutes is less than an hour

C. 90 minutes is less than an hour


90 minutes is 1.5 hours
D. There is a syntax error in the condition in line 3.

Q21. Read the Python program below:

1 number = 13
2 if number == 0:
3 print("zero")
4 number = 0

When this program is executed, what will be displayed on the screen?


Note: There may be errors in the program and/or it may not behave as expected.

A. Nothing will be displayed on the screen.


B. zero

C. 13
0

D. 13
0
zero

Page 9
Year 8 – Intro to Python programming Assessment – Questions

Q22. Read the Python program below:

1 number = 13
2 if number == 0:
3 print("zero")
4 else:
5 print(number)
6 number = 0

When this program is executed, what will be displayed on the screen?


Note: There may be errors in the program and/or it may not behave as expected.

A. Nothing will be displayed on the screen.


B. 13

C. 13
zero

D. 13
zero
0

Q23. Read the Python program below:

1 if number == 0:
2 print("zero")
3 else:
4 print(number)
5 number = 13
6 number = 0

When this program is executed, what will be displayed on the screen?


Note: There may be errors in the program and/or it may not behave as expected.

A. There is an error in the program because when line 1 is executed, variable


number has not been assigned a value.
B. Nothing will be displayed on the screen.
C. 13
zero

D. 13
zero
0

Page 10
Year 8 – Intro to Python programming Assessment – Questions

Q24. Read the Python program below:

1 number = 13
2 if number < 10:
3 print("small")
4 elif number < 100:
5 print("medium")
6 elif number < 1000:
7 print("large")

When this program is executed, what will be displayed on the screen?


Note: There may be errors in the program and/or it may not behave as expected.

A. small

B. medium

C. medium
large

D. large

Q25. Read the Python program below:

1 number = 13
2 if number < 10:
3 print("small")
4 if number < 100:
5 print("medium")
6 if number < 1000:
7 print("large")

When this program is executed, what will be displayed on the screen?


Note: There may be errors in the program and/or it may not behave as expected.

A. small

B. medium

C. medium
large

D. large

Page 11
Year 8 – Intro to Python programming Assessment – Questions

Iteration

Q26. Read the Python program below:

1 count = 3
2 while count > 0:
3 print(count)
4 count = count-1

How many times will line 3 be executed?


Note: There may be errors in the program and/or it may not behave as expected.

A. None (the condition in line 2 will be False the first time it is checked)
B. 1
C. 3
D. 4
E. Infinitely (the condition in line 2 will never become False)

Q27. Read the Python program below:

1 count = 3
2 while count > 0:
3 print(count)

How many times will line 3 be executed?


Note: There may be errors in the program and/or it may not behave as expected.

A. None (the condition in line 2 will be False the first time it is checked)
B. 1
C. 3
D. 4
E. Infinitely (the condition in line 2 will never become False)

Q28. Read the Python program below:

1 count = 3
2 while count >= 0:
3 print(count)
4 count = count-1

How many times will line 3 be executed?


Note: There may be errors in the program and/or it may not behave as expected.

Page 12
Year 8 – Intro to Python programming Assessment – Questions

A. None (the condition in line 2 will be False the first time it is checked)
B. 1
C. 3
D. 4
E. Infinitely (the condition in line 2 will never become False)

Q29. Read the Python program below:

1 count = 3
2 while count >= 0:
3 print(count)
4 count = count-2

How many times will line 3 be executed?


Note: There may be errors in the program and/or it may not behave as expected.

A. None (the condition in line 2 will be False the first time it is checked)
B. 1
C. 2
D. 3
E. Infinitely (the condition in line 2 will never become False)

Q30. Read the Python program below:

1 from random import randint


2 number = randint(1,10)
3 while number != 10:
4 print(number)
5 number = randint(1,10)

How many times will line 4 be executed?


Note: There may be errors in the program and/or it may not behave as expected.

A. None (the condition in line 2 will be False the first time it is checked)
B. 1
C. 10
D. It is impossible to determine in advance
E. Infinitely (the condition in line 2 will never become False)

Page 13
Year 8 – Intro to Python programming Assessment – Questions

Q31. Read the Python program below:

1 from random import randint


2 number = randint(1,10)
3 while number != 10:
4 number = randint(1,10)
5 print(number)

When this program is executed, what will be displayed on the screen, as a result of
executing line 5?
Note: There may be errors in the program and/or it may not behave as expected.

A. 10

B. 1
C. It is impossible to determine in advance
D. There is an error in the program, because line 5 should have been indented

Q32. Read the Python program below:

1 pin = "1357"
2 correct = False
3 while correct == False:
4 print("Enter pin")
5 user = input()
6 if user == pin:
7 correct = True
8 print("Welcome")

When this program is executed, how many times will line 4 be executed?
Note: There may be errors in the program and/or it may not behave as expected.

A. Line 4 will be executed once.


B. Line 4 will be executed at least once.
C. Line 4 will be executed 1357 times.
D. Line 4 will be executed an infinite number of times (the while loop will never
terminate).

Q33. Read the Python program below:

1 pin = "1357"
2 correct = False
3 while correct == False:
4 print("Enter pin")

Page 14
Year 8 – Intro to Python programming Assessment – Questions

5 user = input()
6 if user == pin:
7 print("Welcome")

When this program is executed, how many times will line 4 be executed?
Note: There may be errors in the program and/or it may not behave as expected.

A. Line 4 will be executed once.


B. Line 4 will be executed at least once.
C. Line 4 will be executed 1357 times.
D. Line 4 will be executed an infinite number of times (the while loop will
never terminate).

Q34. Read the Python program below:

1 pin = "1357"
2 print("Enter pin")
3 user = input()
4 while user != pin:
5 print("Enter pin")
6 user = input()
7 print("Wrong pin, try again")
8 print("Welcome")

When this program is executed, what will be displayed on the screen after line 6 is
executed and the user types 1357 on the keyboard?
Note: There may be errors in the program and/or it may not behave as expected.

A. Wrong pin, try again

B. Wrong pin, try again


Welcome

C. Welcome

D. Wrong pin, try again


Enter pin

Q35. A set of precise instructions that is meant to solve a problem is .

A. a computer
B. an algorithm
C. a program
D. an interpreter

Page 15
Year 8 – Intro to Python programming Assessment – Questions

Q36. The instructions in an algorithm .

A. can be expressed in any language


B. can be expressed in any language, as long as they are precise
C. can only be expressed using a programming language
D. can only be expressed using binary digits

Q37. The instructions in an algorithm, when expressed precisely in English,


.

A. can only be carried out by humans


B. can only be carried out by computers
C. can be carried out by both humans and computers

Q38. The instructions in a program, when expressed in Python, .

A. can only be carried out by humans, as long as they understand Python


B. can only be carried out by computers
C. can be carried out by computers, as long as an interpreter is available
D. can be carried out by humans, as long as they understand Python, and
computers, as long as an interpreter is available

Q39. The instructions in a program .

A. can be expressed in any language


B. can be expressed in any language, as long as they are precise
C. can only be expressed using a programming language
D. can only be expressed using binary digits

Q40. A Python program requires to be executed.

A. a computer
B. a program called ‘the Python translator’
C. a program called ‘the Python interpreter’
D. a program called ‘a development environment’

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 16

You might also like