Introduction to Programming With Python Sample Exam
Introduction to Programming With Python Sample Exam
Examination Paper
Answer ALL questions.
Time: 1 hour
Question 1
A Python B VB.NET
C Binary D Java
1 mark
Question 2
value1 = 100
while(value1 > 90):
print(value1 + 1)
value1 = value1 - 2
A 101 99 97 95 93 B 100 98 96 94 92
C 92 94 96 98 100 D 93 95 97 99 101
1 mark
Page 2 of 12
Introduction to Programming with Python © NCC Education Limited 2024
Question 3
A choice = input()
if(len(choice) > 20):
print("Invalid")
B choice = input()
if(choice < 3):
print("Invalid")
C choice = input()
if(choice <> ""):
print("Invalid")
D choice = input()
if(choice <> "yes" and choice <> "no"):
print("Invalid")
1 mark
Question 4
A try:
except:
B try:
catch:
C test:
except:
D test:
catch:
1 mark
Page 3 of 14
Introduction to Programming with Python © NCC Education Limited 2024
Question 5
1 mark
Question 6
Which ONE (1) of the following is not a reason for a program using an external text file.
1 mark
Question 7
Which ONE (1) of the following is a definition of the implementation stage of the software
development lifecycle?
1 mark
Question 8
A1
B2
C3
D4
1 mark
Page 4 of 14
Introduction to Programming with Python © NCC Education Limited 2024
Question 9
Select the program that will output the 3 times table from 1 to 12 (inclusive)
A multiplier = 3
count = 0
while count < 13:
print(multiplier * count)
count = count + 1
B multiplier = 3
count = 1
while count <= 13:
print(multiplier * count)
count = count + 1
C multiplier = 12
count = 1
while count < 13:
print(multiplier * count)
count = count + 1
D multiplier = 3
count = 1
while count < 13:
print(multiplier * count)
count = count + 1
1 mark
Page 5 of 14
Introduction to Programming with Python © NCC Education Limited 2024
-Question 10
A theData([5,5,6,8,4,5,1,2,3,6,5,9,6,3,2,5])
B theData = ({5: 5, 6: 3, 2: 2, 3: 2, 8: 1, 4: 1, 1: 1, 9:
1})
C Counter({5: 5, 6: 3, 2: 2, 3: 2, 8: 1, 4: 1, 1: 1, 9: 1})
D Counter = [1,2,2,3,3,4,5,5,5,5,5,6,6,6,8,9]
1 mark
Question 11
theList = [1, 5, 1, 2, 3, 6, 5, 8, 9, 6, 3]
for number in theList:
if number >4:
theList.pop()
print(theList)
A [1, 1, 2, 3, 3]
B [3, 6, 5, 8, 9, 6, 3]
C [1, 5, 1, 2, 3, 6, 5]
D [1, 1, 3, 5, 9, 3]
1 mark
Page 6 of 14
Introduction to Programming with Python © NCC Education Limited 2024
Question 12
A To store a set of values under one identifier that can be changed whilst the program
is running
B To store a single value that cannot be changed whilst the program is running
C To store a single value that can be changed whilst the program is running.
D To store a set of values under one identifier that cannot be changed whilst the
program is running
1 mark
Question 13
Select the program that reads data from an external file into a list.
A myFile = open("TheFile.txt")
fileData = theFile.read()
myFile.close()
B myFile = open("TheFile.txt",)
fileData = theFile.readline()
myFile.close()
D myFile = open("TheFile.txt","a")
fileData = theFile.readline()
myFile.close()
count = count + 1
1 mark
Page 7 of 14
Introduction to Programming with Python © NCC Education Limited 2024
Question 14
Select the object-oriented program that creates a class and has the correct syntax for the
constructor.
A class animal():
def __create__(self):
animalType = "horse"
B class animal():
def constructor(self):
animalType = "horse"
C class animal():
def __init__(self):
animalType = "horse"
D class animal():
def new():
animalType = "horse"
1 mark
Question 15
Select a method of debugging a program.
1 mark
Page 8 of 14
Introduction to Programming with Python © NCC Education Limited 2024
Question 16
A value B myFunction
C theNumber D newNumber
1 mark
Question 17
A A template
B An instance of a class
C A subroutine
D A value
1 mark
Question 18
Select the drawback of using global variables over local variables in a program.
1 mark
Question 19
Select the module that needs to be imported into Python to delete an external text file.
A random B os
C math D file
Page 9 of 14
Introduction to Programming with Python © NCC Education Limited 2024
1 mark
Question 20
A 10 B 20
C 30 D 100
1 mark
Question 21
Select the most appropriate data type to store data for a flag that can be only two values.
A String B Boolean
C Char D Integer
1 mark
Question 22
A if B for
C repeat D while
1 mark
Question 23
1 mark
Question 24
A myString = "Variable"
print(myString[:3])
A myString = "Variable"
print(myString[:-3])
A myString = "Variable"
print(myString[3:])
A myString = "Variable"
print(myString[3])
1 mark
Question 25
A 0.2857 B 2
C 7 D 7.2857
1 mark
Question 26
1 mark
Page 11 of 14
Introduction to Programming with Python © NCC Education Limited 2024
Question 27
A "P" B "ython"
C "n" D "Pytho"
1 mark
Question 28
A 100 B 200
C 300 D 400
1 mark
Page 12 of 14
Introduction to Programming with Python © NCC Education Limited 2024
Question 29
A 13 B 14
C 15 D 16
1 mark
Question 30
Select the type of data that will be returned from the function isalpha()
A Char B Boolean
C String D Float
1 mark
End of paper
Page 13 of 14
Introduction to Programming with Python © NCC Education Limited 2024
Learning Outcomes matrix
Grade descriptors
Page 14 of 14
Introduction to Programming with Python © NCC Education Limited 2024