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

Summative assessment – Introduction to Python programming – Y8 (1)

The document contains a series of Python programming questions that assess the reader's understanding of basic programming concepts, such as variable assignment, conditional statements, and loops. Each question presents a code snippet and asks what output will be displayed when executed, highlighting potential errors or unexpected behavior. The questions cover various scenarios to test knowledge of Python syntax and logic.

Uploaded by

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

Summative assessment – Introduction to Python programming – Y8 (1)

The document contains a series of Python programming questions that assess the reader's understanding of basic programming concepts, such as variable assignment, conditional statements, and loops. Each question presents a code snippet and asks what output will be displayed when executed, highlighting potential errors or unexpected behavior. The questions cover various scenarios to test knowledge of Python syntax and logic.

Uploaded by

cicica1955
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Assessment – Questions

Sequence

• 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.

• "I live in", location


• "I live in", "Leeds"
• I live in location
• I live in Leeds

• 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.

• I’ve never been to and whatever the user has typed at the keyboard
• I’ve never been to location
• I’ve never been to input()
• It is not possible to know the output without executing the program.

• Read the Python program below:


1 answer = 3 + 13 * 3
2 print("The Answer is", answer)
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.

• The Answer is 3 + 13 * 3
• The Answer is 42
• The Answer is 48
• The Answer is answer

• 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.

• 13 42
• 42 13
• ab
• There is an error in the program because variables a and b are not assigned values in
the right order.

• 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.

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

• 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.

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

• 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.

• 13 42
• 13 13
• 42 13
• 42 42
• There is an error in the program because when line 4 is executed, variable b no longer
has a value.

• 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.

• 13 14
• 13 a+1
• ab
• There is an error in the program because when line 3 is executed, variable a no longer
has a value.

• 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.

• 13
• 14
• 13 14
• 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.

• 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.

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

• Read the Python program below:


1 a = 13
2 print(2*a)
3 print(a)
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.

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

• 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.

• You should try a little Python too


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

• 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.

• You should try a little Python too


• Hello Pythonista
• You should try a little Python too
Hello Pythonista
• Hello Pythonista
You should try a little Python too
• There is an error in the program, because there should not be any quotes around
"Python" in line 3.
• 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.

• You should try a little Python too


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

• 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.

• You should try a little Python too


• Hello Pythonista
• You should try a little Python too
Hello Pythonista
• Nothing will be displayed on the screen
• There is an error in the program, because there is no else.

• 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?

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

• 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.

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

• 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.

• 30 minutes is 0.5 hours


• 30 minutes is less than an hour
• 30 minutes is less than an hour
30 minutes is 0.5 hours
• There is a syntax error in the condition in line 3.

• 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.

• 90 minutes is 1.5 hours


• 90 minutes is less than an hour
• 90 minutes is less than an hour
90 minutes is 1.5 hours
• There is a syntax error in the condition in line 3.

• 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.

• 90 minutes is 1.5 hours


• 90 minutes is less than an hour
• 90 minutes is less than an hour
90 minutes is 1.5 hours
• There is a syntax error in the condition in line 3.
• 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.

• Nothing will be displayed on the screen.


• zero
• 13
0
• 13
0
zero

• 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.

• Nothing will be displayed on the screen.


• 13
• 13
zero
• 13
zero
0

• 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.

• There is an error in the program because when line 1 is executed, variable number has
not been assigned a value.
• Nothing will be displayed on the screen.
• 13
zero
• 13
zero
0

• 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.

• small
• medium
• medium
large
• large

• 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.

• small
• medium
• medium
large
• large

Iteration

• 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.

• None (the condition in line 2 will be False the first time it is checked)
• 1
• 3
• 4
• Infinitely (the condition in line 2 will never become False)

• 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.
• None (the condition in line 2 will be False the first time it is checked)
• 1
• 3
• 4
• Infinitely (the condition in line 2 will never become False)

• 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.

• None (the condition in line 2 will be False the first time it is checked)
• 1
• 3
• 4
• Infinitely (the condition in line 2 will never become False)

• 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.

• None (the condition in line 2 will be False the first time it is checked)
• 1
• 2
• 3
• Infinitely (the condition in line 2 will never become False)

• 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.

• None (the condition in line 2 will be False the first time it is checked)
• 1
• 10
• It is impossible to determine in advance
• Infinitely (the condition in line 2 will never become False)

• 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.

• 10
• 1
• It is impossible to determine in advance
• There is an error in the program, because line 5 should have been indented

• 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.

• Line 4 will be executed once.


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

• 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 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.

• Line 4 will be executed once.


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

• 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.

• Wrong pin, try again


• Wrong pin, try again
Welcome
• Welcome
• Wrong pin, try again
Enter pin

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

• a computer
• an algorithm
• a program
• an interpreter

• The instructions in an algorithm .

• can be expressed in any language


• can be expressed in any language, as long as they are precise
• can only be expressed using a programming language
• can only be expressed using binary digits

• The instructions in an algorithm, when expressed precisely in English,


.

• can only be carried out by humans


• can only be carried out by computers
• can be carried out by both humans and computers

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

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


• can only be carried out by computers
• can be carried out by computers, as long as an interpreter is available
• can be carried out by humans, as long as they understand Python, and computers, as
long as an interpreter is available
• The instructions in a program .

• can be expressed in any language


• can be expressed in any language, as long as they are precise
• can only be expressed using a programming language
• can only be expressed using binary digits

• A Python program requires to be executed.

• a computer
• a program called ‘the Python translator’
• a program called ‘the Python interpreter’
• 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.

You might also like