Intro to Python- CS 1064 Final EXAM with complete verified solutions 2025 (GUARANTEED PASS)

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/405

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

406 Terms

1
New cards

Who developed the Python programming language?

A) Bjarne Stroustrup

B) Guido van Rossum

C) Yukihiro Matsumoto

D) James Gosling

B) Guido van Rossum

2
New cards

Python is a general-purpose programming language, appropriate for solving problems in many areas of computing.

A) True

B) False

A) True

3
New cards

The Python programming language was so named after a snake was discovered in the creator's office.

A) True

B) False

B) False

4
New cards

Python 3 is backwards compatible to Python 2.

A) True

B) False

B) False

5
New cards

Python embodies elements of which programming paradigm?

A) Procedural programming

B) Object-oriented programming

C) Functional programming

D) All of the above

D) All of the above

6
New cards

Which of the following is NOT a principle embraced by the Python programming language?

A) Complex is better than complicated.

B) Explicit is better than implicit.

C) Readability counts.

D) Simple is better than complex.

E) Beautiful is better than ugly.

F) Verbose is better than succinct.

F) Verbose is better than succinct

7
New cards

A Python program must be enclosed in curly braces { } to be executed.

A) True

B) False

B) False

8
New cards

Which of the following statements is true?

A) The print statement is a call to a function.

B) The print statement sends text output to a printer.

C) The print statement sends text output to the editor.

D) A print statement must be the first statement in a Python program

A) The print statement is a call to a function

9
New cards

A Python program must compiled into an executable form before it can be run.

A) True

B) False

B) False

10
New cards

What is syntax coloring?

A) Displaying program output in particular colors

B) Showing certain elements of program code in different colors

C) Wrapping program output in colored boxes

D) Displaying each method of a program in a different color

B) Showing certain elements of program code in different colors

11
New cards

What does the term case sensitive mean?

A) A Python program must be encased in a human-readable comment.

B) The difference between uppercase and lowercase letters matters.

C) A Python program is enclosed in, and executed relative to, a program case.

D) Each case of a Python print statement must be unique.

B) The difference between uppercase and lowercase letters matters

12
New cards

Thonny is best described as which of the following?

A) Debugger

B) Command shell

C) Package manager

D) Text editor

E) Integrated Development Environment (IDE)

E) Integrated Development Environment (IDE)

13
New cards

The output of a Python program run in Thonny appears in the shell window.

A) True

B) False

A) True

14
New cards

Thonny displays code using syntax highlighting.

A) True

B) False

A) True

15
New cards

Running a program that contains errors will cause the Thonny development environment to terminate.

A) True

B) False

B) False

16
New cards

Thonny has a package manager that lets you install and update external Python packages.

A) True

B) False

A) True

17
New cards

Python variables are created using an assignment statement.

A) True

B) False

A) True

18
New cards

The value of a variable can change throughout a program.

A) True

B) False

A) True

19
New cards

Which of the following is NOT a valid Python identifier?

A) FIRST_PLACE

B) 1stPlace

C) first_place

D) place1

B) 1stPlace (identifiers cannot begin w a digit)

20
New cards

Which of the following identifiers follows the convention for naming Python variables?

A) Total_Value

B) TOTAL_VALUE

C) totalValue

D) total_value

D) total_value

21
New cards

In dynamically typed languages, variables are declared to store a specific type of data.

A) True

B) False

B) False

22
New cards

Python variables that represent integers are NOT object reference variables.

A) True

B) False

B) False

23
New cards

The assignment operator has higher precedence than the arithmetic operators.

A) True

B) False

B) False

24
New cards

What value is assigned to the variable num by the following statement if the current value of num is 4? num = num * 2

A) 2

B) 4

C) 6

D) 8

D) 8

25
New cards

The value assigned to a variable must be numeric.

A) True

B) False

B) False

26
New cards

In Python, the assignment statement is also an expression.

A) True

B) False

B) False

27
New cards

The value assigned to a variable could be a floating point number.

A) True

B) False

A) True

28
New cards

What output does the following code produce?print('apple', 'banana')

A) applebanana

B) apple

banana

C) apple banana

D) apple, banana

C) apple banana (The print function separates its output by a space by default)

29
New cards

What output is produced by the following code?print(15 + 30)

A) 45

B) 45.0

C) "1530"

D) 1530

A) 45

30
New cards

What output does the following code produce?print('Ready', end=' ') print('Set', end='') print('Go')

A) Ready

SetGo

B) Ready SetGo

C) Ready

Set Go

D) Ready Set Go

B) Ready SetGo (The end argument is a space in the first call and the empty string in the second call)

31
New cards

What output is produced by the following code?print('Jan', 'Feb', 'Mar', sep='-')

A) Jan-Feb-Mar

B) Jan- Feb- Mar-

C) Jan - Feb - Mar

D) Jan-Feb-Mar-

A) Jan-Feb-Mar (Each value printed is separated by a dash)

32
New cards

What output is produced by the following code?print('oak', 'elm', 'pine', end='!', sep='#')

A) oak#elm#pine!

B) oak#! elm#! pine#!

C) oak#!elm#!pine!

D) oak!elm!pine#

A) oak#elm#pine! (Each value printed is separated by a # and the output ends with a !)

33
New cards

What is the Python shell?

A) An integrated development environment for developing Python programs.

B) An alternative to IDLE or Thonny.

C) A window in which Python statements and expressions are executed immediately.

D) A help system for Python programming.

C) A window in which Python statements and expressions are executed immediately

34
New cards

The Python shell is great for exploring Python language features.

A) True

B) False

A) True

35
New cards

You must use a print statement to display the result of an expression in the Python shell.

A) True

B) False

B) False

36
New cards

You can store a value in a variable in the Python shell.

A) True

B) False

A) True

37
New cards

The Python shell has an integrated help system.

A) True

B) False

A) True

38
New cards

What operator is used to perform string concatenation in Python?

A) *

B) &

C) @

D) +

D) +

39
New cards

What output does the following code produce?print('Total: ' + 100 + 20)

A) Total: 120

B) Total: 10020

C) Total: 1000200

D) No output. This line would produce an error.

D) No output. This line would produce an error (You can't concatenate a string and an integer in Python)

40
New cards

What issue must be addressed when printing a long character string?

A) The string must be subdivided into sections of 50 characters or less.

B) A regular string literal cannot span across multiple lines.

C) The print method has a maximum number of characters it can accept.

D) The print method cannot print character strings.

B) A regular string literal cannot span across multiple lines

41
New cards

If a variable called pioneer refers to the string 'Grace Murray Hopper', what is the result of the expression len(pioneer)?

A) 17

B) 18

C) 19

D) 20

C) 19 ( The len built-in function returns the number of characters in the string)

42
New cards

If a variable called business refers to the string 'Time Warner', what is the result of the expression business[6]?

A) ' '

B) 'r'

C) 'a'

D) 'W'

C) 'a' (string indexes start at 0)

43
New cards

If a variable called son refers to the string 'Justin', what is the result of the expression son[-3]?

A) 'tin'

B) 's'

C) 't'

D) The expression will generate an interpreter error

C) 't'

44
New cards

You cannot change the contents of Python character string once it has been created.

A) True

B) False

A) True (python strings are immutable)

45
New cards

If a variable called jedi refers to the string 'Yoda', what is the result of the expression jedi * 3?

A) YodaYodaYoda

B) YYYooodddaaa

C) 12

D) The expression will generate an interpreter error.

A) YodaYodaYoda

46
New cards

What is the Python Standard Library?

A) A set of officially sanctioned books about Python.

B) The set of documents that define the Python language.

C) A collection of software tools that support the development of Python programs.

D) A collection of programming components that can be used in any Python program.

D) A collection of programming components that can be used in any Python program

47
New cards

Using components from the Python Standard Library is a rare occurrence.

A) True

B) False

B) False

48
New cards

Built-in functions of the Python Standard Library can be used without being imported.

A) True

B) False

A) True

49
New cards

Full documentation about the Python Standard Library can be found online.

A) True

B) False

A) True

50
New cards

The Python turtle graphics module is based on the programming language Logo developed in the 1960s.

A) True

B) False

A) True

51
New cards

If the turtle is currently facing up (north), which way would it be facing after executing the command turtle.right(45)?

A) left (west)

B) up and left (northwest)

C) down and right (southeast)

D) right (east)

E) down and left (southwest)

F) up and right (northeast)

F) up and right (northeast). (The command turns the turtle 45 degrees to the right)

52
New cards

The pen color and size determines the color and width of the lines drawn.

A) True

B) False

A) True

53
New cards

The effect of the setheading depends on the current heading of the turtle.

A) True

B) False

B) False (When setting the heading explicitly, the current heading doesn't matter.)

54
New cards

Which way would the turtle be facing after executing the command turtle.setheading(135)?

A) down and left (southwest)

B) up and left (northwest)

C) left (west)

D) right (east)

E) down and right (southeast)

F) up and right (northeast)

B) up and left (northwest). (The heading angle is based on 0 degrees, which is to the right (east).)

55
New cards

Which way would the turtle be facing after executing the following code?turtle.setheading(270) turtle.right(20) turtle.left(65)

A) down and left (southwest)

B) down (south)

C) down and right (southeast)

D) up and left (northwest)

E) up and right (northeast)

F) up (north)

C) down and right (southeast). (after facing down, it turns to the southwest slightly, then back to southeast)

56
New cards

The position of a circle depends on the current heading of the turtle.

A) True

B) False

A) True

57
New cards

The turtle circle command can be used to draw a regular polygon.

A) True

B) False

A) True (The optional parameter steps determines how many sides the approximating polygon will have.)

58
New cards

The origin point (0, 0) of the turtle coordinate system is in the upper left corner of the graphic screen.

A) True

B) False

B) False (origin point is in center of screen)

59
New cards

The goto command moves the turtle without drawing a line.

A) True

B) False

B) False (It will draw a line if the turtle's pen is lowered.)

60
New cards

A turtle draws a filled circle using the fill_circle command.

A) True

B) False

B) False

61
New cards

The stroke color of a filled turtle shape must be the same as the fill color.

A) True

B) False

B) False

62
New cards

If a filled shape drawn by a turtle is not fully enclosed, Python fills the shape as if the starting point is connected to the end point.

A) True

B) False

A) True

63
New cards

Setting the turtle's speed to 0 turns off the animation of the turtle movement completely.

A) True

B) False

A) True

64
New cards

If either or both operands to the division operator (//) are floating-point values, then the result will be a floating-point value.

A) True

B) False

A) True

65
New cards

If both operands to the remainder operator (%) are positive, a divisor of n will produce a result in the range 1 to n.

A) True

B) False

B) False. (It will produce a result in the range 0 to n-1)

66
New cards

The expression x ^ y raises the value x to the power y.

A) True

B) False

B) False (The Python exponentiation operator is **)

67
New cards

The math module contains a constant that represents the value pi to several digits.

A) True

B) False

A) True

68
New cards

What is the result of the expression 7 // 2?

A) 0

B) 1

C) 3

D) 3.5

C) 3

69
New cards

What is the result of the expression 43 % 5?

1) 3

2) 4

3) 8

4) 8.6

A) 3 (remainder of 3)

70
New cards

If the variable num contains a positive integer, what are the only two possible results of the expression num % 2?

A) 1 and 2

B) 0 and 2

C) -1 and 1

D) 0 and 1

D) 0 and 1. (2 either divides the number evenly or there is 1 left over)

71
New cards

Suppose the integer variable hours contains a value that represents a number of hours. Which of the following expressions will compute how many 24-hour periods are represented by that value, without worrying about any leftover hours.

A) hours / 24 + 1

B) hours / 24

C) hours // 24

D) hours % 24

C) hours // 24

72
New cards

If the current value of the variable num is 4, what value will be stored in num after the following line of code is executed?

num += 2

A) 2

B) 4

C) 6

D) 8

C) 6

73
New cards

If the current value of the variable size is 2, what value will be stored in size after the following line of code is executed?

size *= 3

A) 2

B) 3

C) 5

D) 6

D) 6

74
New cards

If the current value of the variable count is 2, what value will be stored in count after the following line of code is executed?

count += count * 3

A) 2

B) 3

C) 6

D) 8

D) 8

75
New cards

If the current value of the variable num1 is 2 and the current value of the variable num2 is 3, what value will be stored in num2 after the following line of code is executed?

num2 /= num1 * num2

A) 0.0

B) 0.5

C) 1.0

D) 1.5

B) 0.5

76
New cards

Which line of code is equivalent to the following?

depth += 50 * offset

A) depth = depth + (50 * offset)

B) depth = (depth + 50) * offset

C) offset = depth + (50 * offset)

D) offset = depth + 50 * offset

A) depth = depth + (50 * offset)

77
New cards

All mathematical functions in Python are part of the math module.

A) True

B) False

B) False

78
New cards

The math.pi constant represents pi to 15 decimal places.

A) True

B) False

A) True

79
New cards

What is the result of the expression max(6, 17)?

A) 0

B) 6

C) 17

D) 23

C) 17

80
New cards

What is the result of the expression math.pow(3, 3)?

A) 0

B) 6

C) 9

D) 27

D) 27 (3 to the power 3 is 27)

81
New cards

What is the result of the expression math.floor(12.843)?

A) 0

B) 10

C) 12

D) 13

C) 12

82
New cards

Which of the following does the input function NOT do when it is called?

A) Wait for the user to type information and press Enter.

B) Convert the user input to an integer.

C) Return the value typed by the user.

D) Print a message if provided.

B) Convert the user input to an interger

83
New cards

What is text that requests user input called?

A) cue

B) poll

C) prompt

D) solicitation

C) prompt

84
New cards

The input function always returns the read data as a character string.

A) True

B) False

A) True

85
New cards

The input, int, and float functions are all built-in functions.

A) True

B) False

A) True

86
New cards

The input function will produce an error if the value read is not numeric.

A) True

B) False

B) False. (It's type conversion functions such as int and float that produce an error if necessary.)

87
New cards

What will happen if the variable total has the value 5 when the following code is executed?

if total > 8:

print('collywobbles')

A) The word collywobbles is not printed and an exception is thrown.

B) The word collywobbles is not printed, but an error message is.

C) The word collywobbles is not printed and processing continues.

D) The word collywobbles is printed and then processing continues.

C) The word collywobbles is not printed and processing continues

88
New cards

Which value of num will cause the print statement in the following code to be executed?

if num < 15:

if num + 7 >= 20:

print('There you go!')

A) 5

B) 10

C) 13

D) 18

C) 13

89
New cards

What output is printed by the following code if it is executed when appetizer is 3 and entree is 12?

if appetizer > 1:

if entree < 7:

print('ketchup')

else:

print('mustard')

else:

if appetizer < 0:

print('mayonnaise')

else:

print('relish')

A) ketchup

B) mustard

C) mayonnaise

D) relish

E) salsa

F) None of the above

B) mustard

90
New cards

Which of the following statements is true?

A) An if statement must contain an else clause.

B) An if statement is an example of a repetition statement.

C) The statements in the body of an if must be indented.

D) The body of an if statement must be enclosed in braces.

C) The statements in the body of an if must be indented

91
New cards

Of the options given, what values of the variables height, size, and width would cause the following code to set the variable weight to 100?

if height < size:

weight = 50

if width < 20:

print('short')

else:

if width > 100:

weight = 100

println('tall')

A) height = 12, size = 20, width = 200

B) height = 20, size = 12, width = 90

C) height = 15, size = 10, width = 110

D) height = 15, size = 25, width = 50

C) height = 15, size = 10, width = 110

92
New cards

An if statement cannot have both an elif and an else clause.

A) True

B) False

B) False

93
New cards

The relational operators all return boolean results.

A) True

B) False

A) True

94
New cards

The result of a relational operator can be assigned to a variable.

A) True

B) False

A) True

95
New cards

The arithmetic operators have a lower precedence than the relational operators.

A) True

B) False

B) False

96
New cards

Which of the following is a relational operator?

A) not

B) <=

C) /

D) and

B) <=

97
New cards

Which of the following expressions could be used to determine if a is not less than b?

A) a >= b

B) a < b

C) a > b

D) a !< b

A) a >= b

98
New cards

In Python, the relational operators can be used to put character strings in alphabetical order.

A) True

B) False

A) True

99
New cards

The less than operator (<) should not be used to compare floating point values.

A) True

B) False

B) False (There's no problem using < or > to compare floating point values. The danger comes from comparing them for equality)

100
New cards

A character string can be used as the condition of an if statement.

A) True

B) False

A) True