wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Final Exam - Comp Sci

Total questions: 135

Worksheet time: 1hrs 9mins

Name
Class
Date
1.

Provide a short definition or description of the terms or topics below:

Program

a)

An application that combines multiple tools needed to code; Integrated Development Environment

b)

A set of steps that defines how a task is performed

c)

A program that transforms the entire source code into machine language before executing

d)

A set of rules that must be strictly followed when writing code ---> language specific

e)

A representation of an algorithm that a computer can execute

2.

Provide a short definition or description of the terms or topics below:

data types

a)

An application that combines multiple tools needed to code; Integrated Development Environment

b)

A set of steps that defines how a task is performed

c)

A program that transforms the entire source code into machine language before executing

d)

Categories for values in memory (Ex: int, float, str, etc.)

e)

A representation of an algorithm that a computer can execute

3.

Provide a short definition or description of the terms or topics below:

Algorithm

a)

An application that combines multiple tools needed to code; Integrated Development Environment

b)

A set of steps that defines how a task is performed

c)

A program that transforms the entire source code into machine language before executing

d)

A set of rules that must be strictly followed when writing code ---> language specific

e)

A representation of an algorithm that a computer can execute

4.

Provide a short definition or description of the terms or topics below:

Control Structures

a)

An application that combines multiple tools needed to code; Integrated Development Environment

b)

A set of steps that defines how a task is performed

c)

A program that transforms the entire source code into machine language before executing

d)

A set of rules that must be strictly followed when writing code ---> language specific

e)

A logical design that controls the order in which a set of code executes

3 ---> sequence, decision or selection or loops.

5.

Provide a short definition or description of the terms or topics below:

Reference Variables

a)

An application that combines multiple tools needed to code; Integrated Development Environment

b)

A variable that points to a specific location in memory instead of holding a value. Holds and memory address.

c)

A program that transforms the entire source code into machine language before executing

d)

A set of rules that must be strictly followed when writing code ---> language specific

e)

A logical design that controls the order in which a set of code executes

3 ---> sequence, decision or selection or loops.

6.

Provide a short definition or description of the terms or topics below:

Hardware

a)

An application that combines multiple tools needed to code; Integrated Development Environment

b)

Programs

c)

A program that transforms the entire source code into machine language before executing

d)

Equipment; Physical components of a computer

e)

A representation of an algorithm that a computer can execute

7.

Provide a short definition or description of the terms or topics below:

Variable

a)

An application that combines multiple tools needed to code; Integrated Development Environment

b)

A named place in memory where data can be stored and retrieved

c)

A program that transforms the entire source code into machine language before executing

d)

Equipment; Physical components of a computer

e)

A representation of an algorithm that a computer can execute

8.

Provide a short definition or description of the terms or topics below:

Software

a)

An application that combines multiple tools needed to code; Integrated Development Environment

b)

Programs

c)

A program that transforms the entire source code into machine language before executing

d)

Equipment; Physical components of a computer

e)

A representation of an algorithm that a computer can execute

9.

Provide a short definition or description of the terms or topics below:

Compiler

a)

An application that combines multiple tools needed to code; Integrated Development Environment

b)

Programs

c)

A program that transforms the entire source code into machine language before executing

d)

Equipment; Physical components of a computer

e)

A representation of an algorithm that a computer can execute

10.

Provide a short definition or description of the terms or topics below:

Interpreter

a)

An application that combines multiple tools needed to code; Integrated Development Environment

b)

A program that transforms one line of code into machine language and executes, repeating the process until no more code

c)

A program that transforms the entire source code into machine language before executing

d)

A set of rules that must be strictly followed when writing code ---> language specific

e)

A representation of an algorithm that a computer can execute

11.

Provide a short definition or description of the terms or topics below:

IDE

a)

An application that combines multiple tools needed to code; Integrated Development Environment

b)

A program that transforms one line of code into machine language and executes, repeating the process until no more code

c)

A program that transforms the entire source code into machine language before executing

d)

A set of rules that must be strictly followed when writing code ---> language specific

e)

A representation of an algorithm that a computer can execute

12.

Provide a short definition or description of the terms or topics below:

Syntax

a)

An application that combines multiple tools needed to code; Integrated Development Environment

b)

A program that transforms one line of code into machine language and executes, repeating the process until no more code

c)

A program that transforms the entire source code into machine language before executing

d)

A set of rules that must be strictly followed when writing code ---> language specific

e)

A representation of an algorithm that a computer can execute

13.

What is the difference between a high-level and low-level programming language?

High Level (Python) - Select 3

a)

Involves memory management

b)

Feature abstraction

c)

Does not involve memory management

d)

Machine dependent (processor)

e)

Machine independent

14.

What is the difference between a high-level and low-level programming language?

Low Level (Machine Code) - Select 3

a)

Involves memory management

b)

Does not feature abstraction

c)

Does not involve memory management

d)

Machine dependent (processor)

e)

Machine independent

15.

List the major hardware components of a computer:

CPU

a)

Central Processing Unit

b)

Random Access Memory

c)

Secondary Memory

d)

Input Devices

e)

Output Devices

16.

List the major hardware components of a computer:

Main Memory

a)

Central Processing Unit

b)

Random Access Memory

c)

Secondary Memory

d)

Input Devices

e)

Output Devices

17.

List the major hardware components of a computer:

Secondary Memory - Select 2

a)

Hard Drives

b)

Keyboard

c)

USBs

d)

Monitor

e)

Mouse

18.

List the major hardware components of a computer:

Input Devices - Select 3

a)

Headphones

b)

Keyboard

c)

Speaker

d)

Microphone

e)

Mouse

19.

List the major hardware components of a computer:

Output Devices - Select 3

a)

Headphones

b)

Speaker

c)

Monitor

d)

Microphone

e)

Touchscreen

20.

What are the two types of software?

a)
Malware and system tools
b)
Database software and web software
c)
Firmware and utility software
d)
System software and application software
21.

Provide one example for System Software

a)
Operating System
b)
Utility Software
c)

Microsoft Office

d)
Device Driver
22.

Provide one example for Application Software

a)
Operating System
b)
Utility Software
c)

Microsoft Word

d)
Device Driver
23.

Provide information for the following Python topics/commands.

print

a)

Allows users to enter a string

b)

Named place in memory

c)

A sequence of characters; text

d)

Function that displays information to the screen

e)

Function that formats a value when displaying

24.

Provide information for the following Python topics/commands.

format

a)

Allows users to enter a string

b)

Named place in memory

c)

A sequence of characters; text

d)

Function that displays information to the screen

e)

Function that formats a value when displaying

25.

Provide information for the following Python topics/commands.

input

a)

Allows users to enter a string

b)

Named place in memory

c)

A sequence of characters; text

d)

Function that displays information to the screen

e)

Function that formats a value when displaying

26.

Provide information for the following Python topics/commands.

variables

a)

Allows users to enter a string

b)

Named place in memory

c)

A sequence of characters; text

d)

Function that displays information to the screen

e)

Function that formats a value when displaying

27.

Provide information for the following Python topics/commands.

int

a)

Integers, whole numbers

b)

Named place in memory

c)

Real numbers; numbers with a decimal value

d)

Function that displays information to the screen

e)

Function that formats a value when displaying

28.

Provide information for the following Python topics/commands.

float

a)

Integers, whole numbers

b)

Named place in memory

c)

Real numbers; numbers with a decimal value

d)

Function that displays information to the screen

e)

Function that formats a value when displaying

29.

Provide information for the following Python topics/commands.

string

a)

Allows users to enter a string

b)

Named place in memory

c)

A sequence of characters; text

d)

Function that displays information to the screen

e)

Function that formats a value when displaying

30.

Arithmetic Operators: Exponent

a)

**

b)

*

c)

.pow()

d)

.power(x,2)

31.

Arithmetic Operators: Multiplication, Division, Integer

a)

**, //, %

b)

*, /, %

c)

*, %, floor

d)

*, /, floor

32.

Arithmetic Operators: Floor Division, Remainder

a)

floor, %

b)

//, floor

c)

//, %

d)

%, //

33.

Provide information for the following Python topics/commands.

Logical Operators

a)

Check for a given relationship between two values

b)

Execute code if a condition is true

c)

Execute one code block if a condition is true or another block of code if it is false

d)

Connect two Boolean expressions (condition)

34.

Provide information for the following Python topics/commands.

Relational Operators

a)

Check for a given relationship between two values

b)

Execute code if a condition is true

c)

Execute one code block if a condition is true or another block of code if it is false

d)

Connect two Boolean expressions (condition)

35.

Provide information for the following Python topics/commands.

if Statement

a)

Check for a given relationship between two values

b)

Execute code if a condition is true

c)

Execute one code block if a condition is true or another block of code if it is false

d)

Connect two Boolean expressions (condition)

36.

Provide information for the following Python topics/commands.

if-else Statement

a)

Check for a given relationship between two values

b)

Execute code if a condition is true

c)

Execute one code block if a condition is true or another block of code if it is false

d)

Connect two Boolean expressions (condition)

37.

Provide information for the following Python topics/commands.

if-elif Statement

a)

A conditional statement inside another conditional statement

b)

Execute code if a condition is true

c)

Execute one code block if a condition is true or another block of code if it is false

d)

Executes a block of code if a condition is true or checks a second condition if the first was false. If the second condition is true, it executes a second block of code

38.

Provide information for the following Python topics/commands.

Nested Conditional Statements

a)

A conditional statement inside another conditional statement

b)

Execute code if a condition is true

c)

Execute one code block if a condition is true or another block of code if it is false

d)

Executes a block of code if a condition is true or checks a second condition if the first was false. If the second condition is true, it executes a second block of code

39.

Provide information for the following Python topics/commands

while Loop

a)

Repeatedly execute a block of code if a condition is true

b)

Executes a block of code over a sequence of data

c)

Creates a sequence of numbers

d)

One loop inside another loop

e)

Check if input given by user is valid

40.

Provide information for the following Python topics/commands

for Loop

a)

Repeatedly execute a block of code if a condition is true

b)

Executes a block of code over a sequence of data

c)

Creates a sequence of numbers

d)

One loop inside another loop

e)

Check if input given by user is valid

41.

Provide information for the following Python topics/commands

range

a)

Repeatedly execute a block of code if a condition is true

b)

Executes a block of code over a sequence of data

c)

Creates a sequence of numbers

d)

One loop inside another loop

e)

Check if input given by user is valid

42.

Provide information for the following Python topics/commands

Nested Loops

a)

When a loop goes on forever

b)

Executes a block of code over a sequence of data

c)

Creates a sequence of numbers

d)

One loop inside another loop

e)

Check if input given by user is valid

43.

Provide information for the following Python topics/commands

Input Validation

a)

When a loop goes on forever

b)

Executes a block of code over a sequence of data

c)

Creates a sequence of numbers

d)

One loop inside another loop

e)

Check if input given by user is valid

44.

Provide information for the following Python topics/commands

Infinite Loops

a)

When a loop goes on forever

b)

Executes a block of code over a sequence of data

c)

Creates a sequence of numbers

d)

One loop inside another loop

e)

Check if input given by user is valid

45.

Provide information for the following Python topics/commands.

clearscreen()

a)

Clears the drawings, sends the turtle to home, sets the pen color to black, and sets the background color to white

b)

Clears the drawings, sets the turtle to home, sets the pen color to black

c)

Clears the drawings

46.

Provide information for the following Python topics/commands.

reset()

a)

Clears the drawings, sends the turtle to home, sets the pen color to black, and sets the background color to white

b)

Clears the drawings, sets the turtle to home, sets the pen color to black

c)

Clears the drawings

47.

Provide information for the following Python topics/commands.

clear()

a)

Clears the drawings, sends the turtle to home, sets the pen color to black, and sets the background color to white

b)

Clears the drawings, sets the turtle to home, sets the pen color to black

c)

Clears the drawings

48.

Provide information for the following Python topics/commands.

forward(int)

a)

Moves the turtle in the direction it's facing; number of steps is given as a parameter

b)

Rotates the turtle counterclockwise; degrees given as a parameter

c)

Rotates the turtle clockwise; degrees given as a parameter

49.

Provide information for the following Python topics/commands.

left(int)

a)

Moves the turtle in the direction it's facing; number of steps is given as a parameter

b)

Rotates the turtle counterclockwise; degrees given as a parameter

c)

Rotates the turtle clockwise; degrees given as a parameter

50.

Provide information for the following Python topics/commands.

right(int)

a)

Moves the turtle in the direction it's facing; number of steps is given as a parameter

b)

Rotates the turtle counterclockwise; degrees given as a parameter

c)

Rotates the turtle clockwise; degrees given as a parameter

51.

Provide information for the following Python topics/commands.

fillcolor(str)

a)

Changes the fill color of the turtle to c

b)

Changes the pen color to c and outline of turtle

c)

Change or set the screen color to c

d)

Tells the program a shape will be drawn that should be filled so the program must keep track of path and area needed to be filled

e)

Tells the program shape is done and to fill the area created

52.

Provide information for the following Python topics/commands.

pencolor(str)

a)

Changes the fill color of the turtle to c

b)

Changes the pen color to c and outline of turtle

c)

Change or set the screen color to c

d)

Tells the program a shape will be drawn that should be filled so the program must keep track of path and area needed to be filled

e)

Tells the program shape is done and to fill the area created

53.

Provide information for the following Python topics/commands.

bgcolor(str)

a)

Changes the fill color of the turtle to c

b)

Changes the pen color to c and outline of turtle

c)

Change or set the screen color to c

d)

Tells the program a shape will be drawn that should be filled so the program must keep track of path and area needed to be filled

e)

Tells the program shape is done and to fill the area created

54.

Provide information for the following Python topics/commands.

begin_fill()

a)

Changes the fill color of the turtle to c

b)

Changes the pen color to c and outline of turtle

c)

Change or set the screen color to c

d)

Tells the program a shape will be drawn that should be filled so the program must keep track of path and area needed to be filled

e)

Tells the program shape is done and to fill the area created

55.

Provide information for the following Python topics/commands.

end_fill()

a)

Changes the fill color of the turtle to c

b)

Changes the pen color to c and outline of turtle

c)

Change or set the screen color to c

d)

Tells the program a shape will be drawn that should be filled so the program must keep track of path and area needed to be filled

e)

Tells the program shape is done and to fill the area created

56.

Provide information for the following Python topics/commands.

xcor()

a)

returns the x-coordinate of the turtle's current location

b)

returns the y-coordinate of the turtle's current location

c)

Returns the turtle's current location in the format (x,y)

d)

Tells the program a shape will be drawn that should be filled so the program must keep track of path and area needed to be filled

e)

Tells the program shape is done and to fill the area created

57.

Provide information for the following Python topics/commands.

ycor()

a)

returns the x-coordinate of the turtle's current location

b)

returns the y-coordinate of the turtle's current location

c)

Returns the turtle's current location in the format (x,y)

d)

Tells the program a shape will be drawn that should be filled so the program must keep track of path and area needed to be filled

e)

Tells the program shape is done and to fill the area created

58.

Provide information for the following Python topics/commands.

pos()

a)

returns the x-coordinate of the turtle's current location

b)

returns the y-coordinate of the turtle's current location

c)

Returns the turtle's current location in the format (x,y)

d)

Tells the program a shape will be drawn that should be filled so the program must keep track of path and area needed to be filled

e)

Tells the program shape is done and to fill the area created

59.

Which of the following describes the reason for the error that occurs when the code segment executed?

a)

The print function cannot print a number, only strings.

b)

The print function cannot print multiple values, only one.

c)

The multiplication cannot be performed because base and height are strings.

d)

The multiplication cannot be performed because the incorrect operator is used

60.

What is the output of the following code segment if red is entered for color1 and color2?

a)

Red

b)

Error: Incorrect color(s)

c)

Orange

d)

Purple

61.

What segment of code should go in line 11 and 12?

a)

b)

c)

d)

62.

Which of the following shows the location of the turtle after running the code segment?

a)

b)

c)

d)

63.

Which of the following symbols marks the beginning of a single-line comment in Python?

a)

**

b)

*

c)

#

d)

&

64.

A ____ is a sequence of characters.

a)

Character collection

b)

Char sequence

c)

Text Block

d)

String

65.


A ____________ is a name that references a value in the computer's memory.

a)

Register

b)

Variable

c)

RAM slot

d)

Byte

66.

What is the output of the code segment when the value 3 is given as an input?

a)

Area = 28.26

Circumference = 28.26

b)

Nothing will be printed since the code segment will result in an error.

c)

Area = 28.26

Circumference = 18.84

d)

Area = 18.84

Circumference = 18.84

67.

Suppose the following statement is in a program: price = 99.0.

After this statement executes, what will be the data type of the variable price?

a)

float

b)

currency

c)

int

d)

str

68.

What is the output of the code segment when given the following inputs: Yessenia15.367, and 36?

a)

Nothing will be printed since the code will result in an error.

b)

Salary: $ 553.21

c)

Salary: $553.212

d)

Salary: $553.21

69.

number = 1234567.456

Which of the following statements will display the variable number formatted as 1,234,567.5

a)

print(format(number, ',.1'))

b)

print(format(',.1f', number))

c)

print(format(number, ',.1f'))

d)

print(format(',.1', number))

70.

Which of the following statements will cause an error?

a)

x = 99999

b)

17 = x

c)

a = 17

d)

x = '17'

71.

Which of the following operators is not an arithmetic (mathematical) operator in Python?

a)

%

b)

\\

c)

+

d)

**

72.

What would the output of the code segment be?

a)

31

b)

11

c)

1

d)

21

73.

A(n) ______________ expression has a value of either True or False.

a)

binary

b)

decision

c)

unconditional

d)

Boolean

74.

What is the output of the code segment?

a)

37 1

b)

18 37

c)

2 3

d)

1 18

75.

and, or, and not are ___________ operators.

a)

logical

b)

conditional

c)

relational

d)

ternary

76.

Which of the following best describes the syntax error that is found in the code segment provided?

a)

The colon is missing at the end of the if statements.

b)

The number of books is obtained incorrectly because of the int before the input function.

c)

The wrong type of quotes were used when printing text. Single quotes is used for strings in Python. For example, it should be print('Points Awarded:', points).

d)

No syntax error is found in the code segment.

77.

Which of the following best describes the logic error that is found when the code segment is executed, assuming there are no syntax errors?

a)

All the conditional statements except the first one should be elif statements, not if statements.

b)

The incorrect relational operators were used in all four conditions. The relational operator used should have been <=, not >=.

c)

Logical operators should have been used for the last three conditions to check for the two numbers needed. Not doing so causes the points to be awarded incorrectly.

d)

No logic error is found when the code segment is executed.

78.

A(n) _____________ structure tests a condition and then takes one path if the condition is true, or nothing if the condition is false.

a)

if-else statement

b)

if-elif statement

c)

if statement

d)

sequence

79.

A(n) _____________ structure tests a condition and then takes one path if the condition is true, or another path if the condition is false.

a)

if-else statement

b)

if-elif statement

c)

if statement

d)

sequence

80.

Which of the following code segments will properly update the variable grade based on a student's perfomance on the bonus questions?

a)

b)

c)

d)

81.

The symbols >, <, and == are all ____________ operators.

a)

Ternary

b)

Relational

c)

Conditional

d)

Logical

82.

Which Python statement would best replace ''' Missing Code ''' for the code to work as intended?

a)

max < n < min

b)

max > n and n > min

c)

max > n > min

d)

max > n or n > min

83.

What is the difference between a while loop and a for loop?

a)

A while loop iterates over a sequence of data while a for loop iterates if a test expression (condition) is True.

b)

A while loop iterates if a test expression (condition) is True while a for loop iterates over a sequence of data

c)

A while loop has a variable that gets updated after every iteration and a for loop does not

d)

A for loop has a variable tha gets updated after every iteration and a while loop does not.

84.

Which of the following types of loops does not exist in Python

a)

All exist in Python

b)

while loop

c)

do-while loop

d)

for loop

85.

A ______ controlled loop uses a true/false condition to control the number of times that it repeats

a)

Boolean

b)

condition

c)

decision

d)

count

86.

A ______ controlled loop repeats a specific number of times.

a)

Boolean

b)

condition

c)

decision

d)

count

87.

A(n) _______ loop has no way of ending until the program is interrupted.

a)

indeterminate

b)

infinite

c)

timeless

d)

interminable

88.

Which of the following Python statements creates a sequence of numbers that are multiples of 4 and between 1 and 80 inclusive?

a)

range(4,80)

b)

range(80,4)

c)

range(4,80,4)

d)

range(4,81,4)

e)

None of the range function calls provided creates the desired sequence.

89.

Which of the following best describes the syntax error that is found in the code segment provided?

a)

Every statement is missing a semicolon at the end. Python requires a semicolon at the end of each individual statement.

b)

The incorrect operator was used when calculating the result. It should be *=not=*.

c)

The wrong type of quotes were used when working with string literals. Double quotes are used for strings in Python. For example, it should be input("Enter number: ").

d)

No syntax error is found in the code segment.

90.

Which of the following best describes the logic error that is found when the code segment is executed, assuming there are no syntax errors?

a)

The range function should start at 1, not 0. Thus, the code should be range(1, power).

b)

The for loop was defined incorrectly. It should use of and not in. The code should be for p of range(power).

c)

The calculation for the variable result uses the wrong variable. It should use p and not num. The statement should be result *= p.

d)

No logic error is found in the code segment

91.

Which of the following best describes the logic error that is found when the code segment is executed, assuming there are no syntax errors?

a)

For the condition of the while loop, the logical operator or should have been used and not and

b)

The relational operators used are incorrect. They should be = and not ==.

c)

Line 6 should not be indented. This causes it to print something repeatedly when it is not supposed to.

d)

No logic error is found when the code segment is executed.

92.

Which of the following best describes the syntax error that is found in the code segment provided?

a)

The wrong type of quotes were used when working with string literals. Single quotes are used for strings in Python

b)

The colon is missing at the end of the while loop statement

c)

The variables num1 and num2 should not be converted to int since the function input does that automatically.

d)

No syntax error is found when the code segment is executed.

93.

Provide information for the following Python topics/commands.

Function Header

a)

1st line in function - def name_fun(parameters):

b)

A special local variable that receives a copy of values given to a function - def n(x,y):

c)

Exits the function and may return a value - return value_exp

d)

Executes the function - name_fun(arguments)

e)

Actual values given to a function when its called - n(x,y)

94.

Provide information for the following Python topics/commands.

Parameters

a)

1st line in function - def name_fun(parameters):

b)

A special local variable that receives a copy of values given to a function - def n(x,y):

c)

Exits the function and may return a value - return value_exp

d)

Executes the function - name_fun(arguments)

e)

Actual values given to a function when its called - n(x,y)

95.

Provide information for the following Python topics/commands.

return Statement

a)

1st line in function - def name_fun(parameters):

b)

A special local variable that receives a copy of values given to a function - def n(x,y):

c)

Exits the function and may return a value - return value_exp

d)

Executes the function - name_fun(arguments)

e)

Actual values given to a function when its called - n(x,y)

96.

Provide information for the following Python topics/commands.

Function Call

a)

1st line in function - def name_fun(parameters):

b)

A special local variable that receives a copy of values given to a function - def n(x,y):

c)

Exits the function and may return a value - return value_exp

d)

Executes the function - name_fun(arguments)

e)

Actual values given to a function when its called - n(x,y)

97.

Provide information for the following Python topics/commands.

Arguments

a)

1st line in function - def name_fun(parameters):

b)

A special local variable that receives a copy of values given to a function - def n(x,y):

c)

Exits the function and may return a value - return value_exp

d)

Executes the function - name_fun(arguments)

e)

Actual values given to a function when its called - n(x,y)

98.

Provide information for the following Python topics/commands.

Modules

a)

Another python file that just contains function definitions

b)

A special local variable that receives a copy of values given to a function - def n(x,y):

c)

Exits the function and may return a value - return value_exp

d)

Executes the function - name_fun(arguments)

e)

Actual values given to a function when its called - n(x,y)

99.

Provide information for the following Python topics/commands.

math module

a)

Another python file that just contains function definitions

b)

module that contains math functions

c)

Exits the function and may return a value - return value_exp

d)

Executes the function - name_fun(arguments)

e)

Actual values given to a function when its called - n(x,y)

100.

Provide information for the following Python topics/commands.

random module

a)

Another python file that just contains function definitions

b)

module that contains math functions

c)

module that contains functions for randomization

d)

Executes the function - name_fun(arguments)

e)

Actual values given to a function when its called - n(x,y)

101.

Provide information for the following Python topics/commands.

Files

a)

file = open("name","mode") #1

...... #2 -> process file

file.close() #3

b)

'r' - read only

'w' - write only

'a' - append only

c)

Only use the with 'w' and 'a' mode.

d)

Reads everything into one string

e)

Reads one line including '\n'

102.

Provide information for the following Python topics/commands.

File Modes

a)

file = open("name","mode") #1

...... #2 -> process file

file.close() #3

b)

'r' - read only

'w' - write only

'a' - append only

c)

Only use the with 'w' and 'a' mode.

d)

Reads everything into one string

e)

Reads one line including '\n'

103.

Provide information for the following Python topics/commands.

write Function

a)

file = open("name","mode") #1

...... #2 -> process file

file.close() #3

b)

'r' - read only

'w' - write only

'a' - append only

c)

Only use the with 'w' and 'a' mode.

d)

Reads everything into one string

e)

Reads one line including '\n'

104.

Provide information for the following Python topics/commands.

read Function

a)

file = open("name","mode") #1

...... #2 -> process file

file.close() #3

b)

'r' - read only

'w' - write only

'a' - append only

c)

Only use the with 'w' and 'a' mode.

d)

Reads everything into one string

e)

Reads one line including '\n'

105.

Provide information for the following Python topics/commands.

readline Function

a)

file = open("name","mode") #1

...... #2 -> process file

file.close() #3

b)

'r' - read only

'w' - write only

'a' - append only

c)

Only use the with 'w' and 'a' mode.

d)

Reads everything into one string

e)

Reads one line including '\n'

106.

Provide information for the following Python topics/commands.

try/except

a)

a structure to handle specific errors known as exceptions

b)

'r' - read only

'w' - write only

'a' - append only

c)

Only use the with 'w' and 'a' mode.

d)

Reads everything into one string

e)

Reads one line including '\n'

107.

Provide information for the following Python topics/commands.

Exceptions

a)

a structure to handle specific errors known as exceptions

b)

Value Error, NameError, TypeError, ZeroDivisionError

c)

Only use the with 'w' and 'a' mode.

d)

Reads everything into one string

e)

Reads one line including '\n'

108.

Provide information for the following Python topics/commands.

Lists

a)

An object that contains multiple values, enclosed in brackets []

b)

The asterisk with sequence operand repeats that sequence x times

c)

Return a portion or size of the list with only specialized elements

d)

Determines if an item is in a sequence

109.

Provide information for the following Python topics/commands.

Relational Operator

a)

An object that contains multiple values, enclosed in brackets []

b)

The asterisk with sequence operand repeats that sequence x times

c)

Return a portion or size of the list with only specialized elements

d)

Determines if an item is in a sequence

110.

Provide information for the following Python topics/commands.

List Slicing

a)

An object that contains multiple values, enclosed in brackets []

b)

The asterisk with sequence operand repeats that sequence x times

c)

Return a portion or size of the list with only specialized elements

d)

Determines if an item is in a sequence

111.

Provide information for the following Python topics/commands.

in Operator

a)

An object that contains multiple values, enclosed in brackets []

b)

The asterisk with sequence operand repeats that sequence x times

c)

Return a portion or size of the list with only specialized elements

d)

Determines if an item is in a sequence

112.

List Methods - append(item)

a)

Adds item to the end of list

b)

Return index of 1st occurrence of value item

c)

Insert item at specified index, shifting other elements to the right

d)

Sort items in ascending order

e)

Remove 1st occurrence of value item

113.

List Methods - index(item)

a)

Adds item to the end of list

b)

Return index of 1st occurrence of value item

c)

Insert item at specified index, shifting other elements to the right

d)

Sort items in ascending order

e)

Remove 1st occurrence of value item

114.

List Methods - insert(index,item)

a)

Adds item to the end of list

b)

Return index of 1st occurrence of value item

c)

Insert item at specified index, shifting other elements to the right

d)

Sort items in ascending order

e)

Remove 1st occurrence of value item

115.

List Methods - sort()

a)

Adds item to the end of list

b)

Return index of 1st occurrence of value item

c)

Insert item at specified index, shifting other elements to the right

d)

Sort items in ascending order

e)

Remove 1st occurrence of value item

116.

List Methods - remove(item)

a)

Adds item to the end of list

b)

Return index of 1st occurrence of value item

c)

Insert item at specified index, shifting other elements to the right

d)

Sort items in ascending order

e)

Remove 1st occurrence of value item

117.

List Methods - reverse()

a)

Reverse the current order of elements

b)

Return index of 1st occurrence of value item

c)

Insert item at specified index, shifting other elements to the right

d)

Sort items in ascending order

e)

Remove 1st occurrence of value item

118.

Built-in Functions - len(list)

a)

Returns length of sequence (number of elements)

b)

Returns minimum value in sequence

c)

Returns maximum value in sequence

d)

Deletes an element in the list based on given index

119.

Built-in Functions - min(list)

a)

Returns length of sequence (number of elements)

b)

Returns minimum value in sequence

c)

Returns maximum value in sequence

d)

Deletes an element in the list based on given index

120.

Built-in Functions - max(list)

a)

Returns length of sequence (number of elements)

b)

Returns minimum value in sequence

c)

Returns maximum value in sequence

d)

Deletes an element in the list based on given index

121.

del Statement

a)

Returns length of sequence (number of elements)

b)

Returns minimum value in sequence

c)

Returns maximum value in sequence

d)

Deletes an element in the list based on given index

122.

Consider the following code segment.

Which of the following best describes the error found in the code segment?

a)

The * operator is used for multiplication between two values only, not with lists.

b)

The print function cannot print a list since it is multiple values.

c)

The list function only accepts sequences, not an int like 0.

d)

No error is found in the code segment.

123.

Consider the following code segment.

What is the output of the following code segment?

a)

pro

b)

prob

c)

lem

d)

blem

124.

The code provided below is a python program that generates a random list of numbers and prints the original list and the list of numbers with no duplicates.

What segment of code should go in line 13?

a)

if numbers[c] not in no_rep:

b)

if c not in no_rep:

c)

if numbers.get(c) not in no_rep:

d)

if numbers.c not in no_rep:

125.

A group of statements that exist within a program for the purpose of performing a specific task is a(n) _________

a)

block

b)

parameter

c)

function

d)

expression

126.

The first line of a function definition is known as the _______

a)

Body

b)

Introduction

c)

Initialization

d)

Header

127.

You _____ a function to execute it.

a)

Define

b)

Call

c)

Import

d)

Export

128.

A(n) _______ is a special variable that receives a piece of data when a function is called.

a)

Argument

b)

Parameter

c)

Header

d)

Packet

129.

A(n) ______ is a piece of data that is sent into a function

a)

Argument

b)

Parameter

c)

Header

d)

Packet

130.

A(n) _______ is a variable that is created inside a function and is only visible to that function.

a)

Local variable

b)

Hidden variable

c)

Function-wide variable

d)

Global variable

131.

A(n) __________ is a variable that is visible to every function in a program file.

a)

Local variable

b)

Universal Variable

c)

Program-wide variable

d)

Global variable

132.

What Python statement causes a function to end and sends a value back to the part of the program that called the function

a)

end

b)

send

c)

exit

d)

return

133.

Consider the following code segment.

What will the following code display

a)

1 3.4

0 0

1 3.4

b)

1 3.4

0 0

0 0

c)

1 3. 4

1 3. 4

1 3. 4

d)

0 0

0 0

0 0

134.

Which of the following function definitions creates a function that accepts an argument and displays it 10 times

a)

def ten_times(n):

print(n*10)

b)

def ten_times(n):

for i in range(10):

print(n)

c)

def ten_times(n):

for i in range(10+1):

print(n)

d)

def ten_times(n):

print(n ** 10)

135.

Consider the following function definition below.

def my_function(a, b, c):

d = (a+c) / b

print(d)

Which of the following statements calls this function, pass 6 into c, 4 into b, and 2 into a?

a)

my_function(2,4,6)

b)

my_function(6,4,2)

c)

my_function(4,2,6)

d)

my_function(4,6,2)