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

Introduction to Programming With Python Sample Exam

The document is an examination paper for an Introduction to Programming with Python course, consisting of multiple-choice questions covering various programming concepts. It includes questions on high-level programming languages, output from Python programs, exception handling, and object-oriented programming. The paper assesses students' understanding of programming fundamentals and is structured to evaluate their ability to apply these concepts effectively.

Uploaded by

Elsie Canlas
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)
18 views

Introduction to Programming With Python Sample Exam

The document is an examination paper for an Introduction to Programming with Python course, consisting of multiple-choice questions covering various programming concepts. It includes questions on high-level programming languages, output from Python programs, exception handling, and object-oriented programming. The paper assesses students' understanding of programming fundamentals and is structured to evaluate their ability to apply these concepts effectively.

Uploaded by

Elsie Canlas
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/ 14

Introduction to Programming with Python

[Day] [Month] [Year]

Examination Paper
Answer ALL questions.

Clearly cross out surplus answers.

Time: 1 hour

The maximum mark for this paper is 30.

Any reference material brought into the examination room must be


handed to the invigilator before the start of the examination.
SECTION A - Multiple Choice Question
Circle ONE (1) correct answer from A, B, C, or D for each question.
Each question is worth 1 mark.

Question 1

Which ONE (1) of the following is not a high-level programming language?

A Python B VB.NET

C Binary D Java

1 mark

Question 2

Select the output from this program:

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

Select the program that performs an existence check.

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

Select the commands used for exception handling in Python.

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

Select the example of a logic error.

A Spelling a key word incorrectly


B Using addition instead of multiplication in a calculation
C Attempting to multiply a string with an integer
D Reading from a text file that does not exist

1 mark

Question 6

Which ONE (1) of the following is not a reason for a program using an external text file.

A To load a previous program state


B To store inputs for use in the program
C To store data for future use
D To store data permanently

1 mark

Question 7

Which ONE (1) of the following is a definition of the implementation stage of the software
development lifecycle?

A Writing the program code


B Installing the program in the final place to be used
C Creating a flowchart for part of the system
D Making sure the program meets requirements

1 mark
Question 8

Select the output from this Python program:


theList = [1,2,3,4,5]
print(theList[1])

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

Select the content of


from collections import Counter
theData = [5,5,6,8,4,5,1,2,3,6,5,9,6,3,2,5]
counterObject = Counter(theData)
print(counterObject)

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

Select the contents of theList after this program has run:

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

Which ONE (1) of the following describes the purpose of a variable?

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()

C myFile = open("TheFile.txt", "w")


fileData = theFile.read()
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.

A Using a code editor


B Using print statements
C Using an interpreter
D Using validation

1 mark

Page 8 of 14
Introduction to Programming with Python © NCC Education Limited 2024
Question 16

Select the argument from this program:


def myFunction(theNumber):
newNumber = theNumber – 10
return newNumber
value = int(input())
value = myFunction(value)
print(value)

A value B myFunction

C theNumber D newNumber

1 mark

Question 17

Select the definition of an object in object-oriented programming (OOP)

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.

A If the value is changed, it is only changed in that location


B Values need to be returned from all functions and overwritten in the main program
C The value cannot be accessed from all parts of the program
D Memory is not released after use

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

Select the output from this Python program:


first = 10
second = 20
if first >= second:
print(first + second)
else:
print(first * 10)

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

Which ONE(1) of these constructs is a bounded loop.

A if B for

C repeat D while

1 mark

Question 23

Select the definition of concatenation.

A Join two strings into one string


B Add two values together
Page 10 of 14
Introduction to Programming with Python © NCC Education Limited 2024
C Send a value from one function to another function
D Convert data from one data type to another data type

1 mark

Question 24

Select the program that will output the string "Var".

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

Select the result from this calculation: 51 % 7

A 0.2857 B 2

C 7 D 7.2857

1 mark

Question 26

Select the purpose of abstraction.

A To produce reusable components


B To catch run-time errors
C To validate changes to data
D To remove data and information that is not required

1 mark

Page 11 of 14
Introduction to Programming with Python © NCC Education Limited 2024
Question 27

Select the output from this Python program:


myString = "Python"
print(myString[-1])

A "P" B "ython"

C "n" D "Pytho"

1 mark

Question 28

Select the output from this Python program:


one = 5
two = 10
three = 5
if one == two or two == three:
print(100)
elif one == two and two > 10:
print(200)
else:
print(300)

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

Select the number of times this loop will run:


word = "Computer science"
for count in range(len(word)):
print(count)

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

Question Learning Outcomes Marker can differentiate


assessed between varying levels of
achievement
1 - 30 All Yes

Grade descriptors

Learning Outcome Pass Merit Distinction


Describe and apply Demonstrate Demonstrate sound Demonstrate
a systematic adequate ability to and consistent exceptional ability
approach to the Discuss the ability to to differentiate and
design of programs development of the differentiate and recognise
Digital Computer and recognise components
its characteristics components
Write small Demonstrate Demonstrate robust Demonstrate highly
procedural adequate level of level of comprehensive
programs to understanding understanding level of
perform well- understanding
defined tasks,
following well-
defined
requirements
Test and document Demonstrate Demonstrate robust Demonstrate highly
program code adequate level of level of comprehensive
following the understanding understanding level of
principles of understanding
software
engineering
Describe and apply Demonstrate ability Demonstrate ability Demonstrate ability
the benefits of to perform the task to perform the task to perform the task
modular software consistently well to the highest
design. standard

Page 14 of 14
Introduction to Programming with Python © NCC Education Limited 2024

You might also like