wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CS322 FINAL EXAMINATIONS

Total questions: 100

Worksheet time: 57mins

Name
Class
Date
1.

What is the primary function of a computer's CPU?

a)

To run programs

b)

To display graphics

c)

To store data permanently

d)

To connect to the internet

2.

Which of the following is considered hardware?

a)

Microsoft Word

b)

RAM

c)

Python

d)

Adobe Photoshop

3.

What does RAM stand for?

a)

Random Access Memory

b)

Read Access Memory

c)

Read And Memory

d)

Rapid Access Memory

4.

Which of the following is an example of application software?

a)

Word Processing Software

b)

Device Drivers

c)

Utility Programs

d)

Operating System

5.

What is the purpose of a program?

a)

To manage memory

b)

To connect hardware

c)

To perform tasks as instructed

d)

To store data

6.

What is a byte composed of?

a)

Sixteen bits

b)

Two bits

c)

Eight bits

d)

Four bits

7.

Which of the following is a type of secondary storage?

a)

Motherboard

b)

Hard Drive

c)

CPU

d)

RAM

8.

What is the function of input devices?

a)

To store data

b)

To display output

c)

To collect data

d)

To process information

9.

Which of the following is a programming language?

a)

HTML

b)

CSS

c)

Python

d)

XML

10.

What does the fetch-decode-execute cycle refer to?

a)

The process of executing a program

b)

The process of storing data

c)

The process of writing code

d)

The process of debugging

11.

What is the purpose of a flowchart in programming?

a)

To execute commands

b)

To store data

c)

To write code

d)

To visualize the program's logic

12.

Which of the following is a characteristic of high-level programming languages?

a)

They are machine-dependent

b)

They are difficult to read

c)

They are easier for humans to understand

d)

They use mnemonics

13.

What is the role of a compiler?

a)

To execute code line by line

b)

To manage memory

c)

To translate high-level code into machine code

d)

To debug programs

14.

What is a variable in programming?

a)

A fixed value

b)

A name that represents a value

c)

A type of loop

d)

A function

15.

What is the purpose of comments in code?

a)

To increase performance

b)

To store data

c)

To execute commands

d)

To document the code

16.

What does the input function do in Python?

a)

Executes code

b)

Stores data

c)

Reads user input

d)

Displays output

17.

Which of the following is a logical operator?

a)

AND

b)

ADD

c)

MULTIPLY

d)

SUBTRACT

18.

What is a sentinel in programming?

a)

A special value that marks the end of a sequence

b)

A loop structure

c)

A type of variable

d)

A data type

19.

What is the purpose of a while loop?

a)

To repeat a block of code a specific number of times

b)

To execute code once

c)

To define a function

d)

To repeat a block of code as long as a condition is true

20.

What is the output of the following code: print(2 + 3)?

a)

5

b)

23

c)

Error

d)

None

21.

Which of the following is a characteristic of a for loop?

a)

It runs indefinitely

b)

It requires a condition

c)

It iterates a specific number of times

d)

It cannot be nested

22.

What is the purpose of the range function in Python?

a)

To store data

b)

To create a list of numbers

c)

To execute a loop

d)

To define a variable

23.

What does the term 'input validation' refer to?

a)

Executing commands

b)

Checking if the input is correct before processing

c)

Storing input data

d)

Displaying output

24.

What is a nested loop?

a)

A loop inside another loop

b)

A loop that executes once

c)

A loop that runs indefinitely

d)

A loop that does not execute

25.

What is the correct syntax to define a function in Python?

a)

function myFunction():

b)

def myFunction:

c)

def myFunction():

d)

define myFunction():

26.

What will be the output of the following code?

a)

Hello, World!

b)

Error

c)

my_function

d)

None

27.

What is the correct syntax to call a function named myFunction?

a)

call myFunction()

b)

myFunction()

c)

myFunction(call)

d)

call myFunction

28.

What does the following code output?

a)

2

b)

3

c)

5

d)

error

29.

How can you return multiple values from a function?

a)

By separating them with a comma

b)

By using a list

c)

By using a dictionary

d)

All of the above

30.

What is the output of the following code?

a)

8

b)

12

c)

16

d)

error

31.

What does the following code output?

a)

5

b)

10

c)

15

d)

error

32.

What is the term for a function that calls itself?

a)

Loop function

b)

Recursive function

c)

Lambda function

d)

Anonymous function

33.

What is the output of the following code?

a)

1

b)

3

c)

6

d)

9

34.

How do you specify default values for function parameters?

a)

def func(x=10, y):

b)

def func(x, y=10):

c)

def func(x=10, y=10):

d)

def func(x:10, y:10):

35.

What will be the output of the following code?

a)

7

b)

12

c)

34

d)

error

36.

What is the output of this code?

a)

1

b)

3

c)

6

d)

error

37.

What is a lambda function in Python?

a)

A function that can have any number of arguments

b)

A function that can only have one argument

c)

An anonymous function defined with the lambda keyword

d)

A function that returns another function

38.

What does the following code output?

a)

5

b)

10

c)

15

d)

error

39.

How can you define a function with variable-length arguments?

a)

def func(*args):

b)

def func(*varargs):

c)

def func(**args):

d)

def func(varargs*):

40.

What does the following code output?

a)

{'a': 1, 'b': 2}

b)

[1, 2]

c)

(1, 2)

d)

Error

41.

What is the output of the following code?

a)

5

b)

6

c)

32

d)

error

42.

What does the following code output?

a)

2

b)

3

c)

-2

d)

error

43.

What will the following code output?

a)

Hello from outer

b)

Hello from inner

c)

Error

d)

None

44.

What does the following code output?

a)

9

b)

11

c)

13

d)

error

45.
What is python named after
a)
The snake
b)
Television show called Monty Python
46.
What will the output be from the following code?
print(Hello world!)
a)
Hello world!
b)
SyntaxError
c)
Hello world
d)
print(Hello world!)
47.
Python identifies blocks of code by
a)
BEGIN and END keywords
b)
{ and }
c)
aligning up the starts of lines (indentation)
d)
guessing
48.
What will the output be from the following code?
print("Hello world!" * 2)
a)
TypeError
b)
Hello world world!
c)
Hello world!Hello world!
d)
Hello world! * 2
49.

people = ["John", "Rob", "Bob"]

print (people[-1])

what would this result be?

a)
John
b)
Rob
c)
Bob
50.
To create a newline at the end of prompt, you can use which of the following expressions?
a)
\new
b)
\n
c)
\break
d)
\return
51.
What is a variable?
a)
A box(memory location) where you store values
b)
a type of graphics
c)
Data type
d)
a type of memory
52.
What letter will be printed on the screen after running this code:
a)
e
b)
x
c)
t
d)
Nothing prints
53.
What extension must you add to the end of a file when saving?
a)
.xlsx
b)
.pptx
c)
.docx
d)
.py
54.
What will the output be from the following code?
print(3*4+5)
a)
27
b)
17
c)
12
d)
SyntaxError
55.

Which of the following is the correct way to write a nested if statement?

a)

b)

c)

d)

56.

What will be the output of the following code?

a)

True

b)

False

c)

Error

d)

None

57.

What does the following code output if a = 3 and b = 5?

a)

a is greater

b)

a is equal to b

c)

a is smaller

d)

Error

58.

What is the output of the following code?

a)

True

b)

False

c)

Error

d)

None

59.

What does the following code output if 'y = 0'?

a)

True

b)

False

c)

Error

d)

None

60.

What will the following code output if value = 100?

a)

Non-zero value

b)

Zero value

c)

Error

d)

None

61.

What will the following code output if num = 5?

a)

Less than 10

b)

Greater than 0

c)

Less than 10 and Greater than 0

d)

10 or more

62.

What will be the output of the following code?

a)

Over 40

b)

20 to 40

c)

20 or less

d)

None

63.

What does the following code output if n = 10?

a)

Divisible by 2 and 5

b)

Divisible by 2

c)

Divisible by 5

d)

Not divisible by 2 or 5

64.

What does the following code output if var = 'Python'?

a)

Variable is not empty

b)

Variable is empty

c)

Error

d)

None

65.

Which of the following will correctly execute if x is less than y?

a)

if x < y:

b)

if x > y:

c)

if x <= y:

d)

if x >= y:

66.

What is the correct syntax to check if a is not equal to b?

a)

if a <> b:

b)

if a != b:

c)

if a =! b:

d)

if a ^= b:

67.

How can you test if 'x' is both greater than 10 and less than 20?

a)

if x > 10 and < 20:

b)

if 10 < x < 20:

c)

if x > 10 and x < 20:

d)

if (10 < x < 20):

68.

What will be the output of the following code?

a)

Even

b)

Odd

c)

Error

d)

None

69.

What does the following code output?

a)

Greater

b)

Equal

c)

Smaller

d)

None

70.

What will be the output of the following code?

a)

Greater than 20

b)

Between 10 and 20

c)

10 or less

d)

None

71.

What is the output of the following code?

a)

Odd

b)

Even

c)

Error

d)

None

72.

Which of the following statements is correct for checking if a variable x is an even number?

a)

if x // 2 == 0:

b)

if x % 2 == 0:

c)

if x / 2 == 0:

d)

if x % 2 == 1:

73.

Who created Python?

a)

Guido van Rossum

b)

Tim Berners-Lee

c)

Larry Page

d)

Mark Zuckerberg

74.

What is Python known for?

a)

High-level programming language

b)

Low-level programming language

c)

Assembly language

d)

Hardware programming language

75.

What is the purpose of the print() function in Python?

a)

Display something in the console

b)

Read user input

c)

Perform mathematical calculations

d)

Create a loop

76.

What is the purpose of a code editor in an Integrated Development Environment (IDE)?

a)

To write and edit code

b)

To debug code

c)

To compile code

d)

To run code

77.

What is the main advantage of using Python over Java?

a)

More libraries

b)

Better for system programming

c)

Easier learning curve

d)

Faster performance

78.

What is the purpose of the PyCharm IDE?

a)

General-purpose IDE

b)

Specifically designed for Python development

c)

Primarily for mobile app development

d)

Focused on web development

79.

What is the significance of indentation in Python programming?

a)

Not required in Python

b)

Used for decorative purposes

c)

Optional for code execution

d)

Very important for code readability

80.

Which mode of using the Python interpreter allows for immediate code execution?

a)

Script mode

b)

Compile mode

c)

Interactive mode

d)

Debug mode

81.

What type of language is Python?

a)

Structured, declarative, mid-level

b)

Functional, imperative, assembly

c)

Compiled, procedural, low-level

d)

Interpreted, object-oriented, high-level

82.

Why Python is in demand?

a)

Simple syntax

b)

Useful in embedded and cross platforms

c)

It is the fastest performing programming language

d)

It has fewer libraries.

83.

In programming, what is iteration/looping?

a)

The repetition of steps within a program

b)

The order in which instructions are carried out

c)

A decision point in a program

84.
Why is iteration important?
a)
It determines the order in which instructions are carried out
b)
It allows code to be simplified by removing duplicated steps
c)
It allows multiple paths through a program
85.
What is iteration known as?
a)
Looping
b)
Crashing
c)
Repeating
86.

numbers = [5, 14, 9, 17]

for number in numbers:

if number % 3 == 0:

print(number)


The output will be?

a)

17

b)

9

c)

14

9

17

d)

14

17

87.

numbers = [5, 14 ,9, 17]

for number in numbers:

if number >= 9:

print (number)


The output will be?

a)

17

b)

9

c)

14

9

17

d)

14

17

88.
Which of the following will print:
a)
for i in range(1, 5):   
print(str(i) * 5)
b)
for i in range(1, 5):   
print("i" * i)
c)
for i in range(1, 6):   
print("i" * i)
d)
for i in range(1, 6):   
print(str(i) * i)
89.
What will be printed after running this FOR loop:

for number in range(6):
 
    print(number)
a)
The number 6 
b)
The numbers 0 - 5
c)
The number 5
d)
The numbers 1 - 6
90.
How many times does the following program print the word ‘computer’:

word= "computer"  
for num in range(1,6):
 
    print(word)
a)
5
b)
6
c)
1
d)
0
91.

Which of the following programs prints ten lines?

a)

for i in range(10):

print("hi")

b)

for i = 1 to 10:

print("hi")

c)

for i in 1 - 10:

print("hi")

d)

for i from 0 to 9:

print("hi")

92.

Which of the following best describes the purpose of a for loop?

a)

A for loop is for doing something an indeterminate number of times.

b)

A for loop is doing something an infinite number of times.

c)

A for loop is for doing something a fixed number of times.

d)

A for loop is for doing something three times.

93.

Which of the following for loops would print the following numbers?

3

5

7

9

a)

for i in range(3, 10, 2):

print(i)

b)

for i in range(3, 9, 2):

print(i)

c)

for i in range(9):

print(i)

d)

for i in range(3,9):

print(i)

94.

What is the value of num when this loop completes?


num = 0

for i in range(2, 8, 2):

num += i

a)

2

b)

8

c)

12

d)

20

95.

Three of the for loops below will provide identical values for i. Which for loop will provide values that do not match the others?

a)

for i in range(0, 5):

b)

for i in range(5):

c)

for i in range(0, 5, 1):

d)

for i in range(5, 0, 1):

96.

What would be the output of the following code:

for i in range(3):

print(i)

a)

1 2 3

b)

i i i i

c)

i i i

d)

0 1 2

97.

drink_choices = ["coffee", "tea", "water", "juice", "soda"]

for drink in drink_choices:

print(drink)

a)

"coffee"

b)

["coffee", "tea", "water", "juice", "soda"]

c)

drink

d)

"coffee tea water juice soda"

98.

What would be the output of the following code:

for i in range(3):

print(5)

a)

0 1 2

b)

3 3 3 3 3

c)

5 5 5

d)

0 1 2 3 4

99.

numbers = [2, 4, 6, 8]

for number in numbers:

print("hello!")

a)

2 hello! 4 hello! 6 hello! 8 hello!

b)

hello!

c)

2 4 6 8

d)

hello! hello! hello! hello!

100.

You have a dictionary called student_scores that stores students' names as keys and their test scores as values. You want to find the student with the highest score. Which Python code snippet accomplishes this task?

a)

max_score = max(student_scores.values())

b)

max_score = max(student_scores)

c)

max_score = student_scores.max_value()

d)

max_score = max(student_scores.keys())