Docsity

Starting out With Python Chapter 2 2026/2027 Study Guide 96 Verified Q&A, Exams of Computer Programming

Toggle sidebar
bg1
Starting out With Python Chapter 2
📋
DOCUMENT OVERVIEW
Executive Exam Scope & Core Objectives 96 Questions
This document provides a comprehensive exam preparation pack containing 96 verified questions with
complete correct answers. It is curated to reinforce core syllabus principles, sharpen critical thinking, and support
effective revision, practice, and self-assessment for exam success.
✓
Verified Solutions
✓
100% Exam Ready
✓
Comprehensive Coverage
QUESTION 1
The process of creating a program that works correctly typically requires these five phases
CORRECT ANSWER
1. Design the program
2. Write the code
3. Correct Syntax errors
4. Test the program
5. Correct logic errors
QUESTION 2
Logic Error
CORRECT ANSWER
An error in a program that makes it do something other than what the programmer intended. It does not
prevent the program from running, but causes it to produce incorrect results. Mathematical mistakes are
common causes of logic errors.
QUESTION 3
debugging
CORRECT ANSWER
Finding and fixing problems in your algorithm or program.
QUESTION 4
algorithm
95+ (2026⁄2027 Full Exam Kit) Solved Q&A │ Correct & Verified Answers
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Partial preview of the text

Download Starting out With Python Chapter 2 2026/2027 Study Guide 96 Verified Q&A and more Exams Computer Programming in PDF only on Docsity!

Starting out With Python Chapter 2

📋 DOCUMENT OVERVIEW Executive Exam Scope & Core Objectives 96 Questions

This document provides a comprehensive exam preparation pack containing 96 verified questions with complete correct answers. It is curated to reinforce core syllabus principles, sharpen critical thinking , and support effective revision , practice, and self-assessment for exam success.

✓ Verified Solutions ✓ 100% Exam Ready ✓ Comprehensive Coverage

QUESTION 1 The process of creating a program that works correctly typically requires these five phases

CORRECT ANSWER

  1. Design the program
  2. Write the code
  3. Correct Syntax errors
  4. Test the program
  5. Correct logic errors

QUESTION 2 Logic Error

CORRECT ANSWER

An error in a program that makes it do something other than what the programmer intended. It does not prevent the program from running, but causes it to produce incorrect results. Mathematical mistakes are common causes of logic errors.

QUESTION 3 debugging

CORRECT ANSWER

Finding and fixing problems in your algorithm or program.

QUESTION 4 algorithm

95+ (2026⁄2027 Full Exam Kit) Solved Q&A │ Correct & Verified Answers

CORRECT ANSWER

a set of well-defined logical steps that must be taken to perform a task.

QUESTION 5

pseudocode

CORRECT ANSWER

Shorthand notation for programming which uses a combination of informal programming structures and verbal descriptions of code.

QUESTION 6

Flowcharts

CORRECT ANSWER

A graphical representation of the steps in a process; details all of the elements in a process and the sequence in which these elements occur. This a tool that programmers use to design programs

QUESTION 7

terminal symbols

CORRECT ANSWER

The ovals that appear at the top and bottom of the flowchart. The start terminal marks the starting point, and the End terminal marks the program's ending point.

QUESTION 8

input symbol

CORRECT ANSWER

indicates an input operation and is represented by a parallelogram in flowcharts

QUESTION 9

output symbol

CORRECT ANSWER

indicates an output operation and is represented by a parallelogram in flowcharts

QUESTION 10

Processing Symbols:

CORRECT ANSWER

any data that the program receives while it is running.

QUESTION 17

A function

CORRECT ANSWER

is a piece of pre-written code that performs an operation.

QUESTION 18

Calling a function

CORRECT ANSWER

what programmers say when they execute a function.

QUESTION 19

argument

CORRECT ANSWER

the data that you want displayed on the screen

QUESTION 20

string

CORRECT ANSWER

a sequence of characters that is used as data.

QUESTION 21

string literal

CORRECT ANSWER

When a string appears in the actual code of a program.

QUESTION 22

single or double quotation marks

CORRECT ANSWER

In Python, string literals must be enclosed in ________________________

QUESTION 23

double-quote marks

CORRECT ANSWER

If you want a string literal to contain either a single-quote or apostrophe as part of the string, can can enclose the string literal in

QUESTION 24

triple quotes

CORRECT ANSWER

Python also allows you to enclose string literal in ________ __________, why? If the string contains both single- quote marks and double-quote marks.

QUESTION 25

comments

CORRECT ANSWER

short notes placed in different parts of a program, explaining how those parts of the program work. They are intended for any person reading a program's code, not the computer.

QUESTION 26

# character

CORRECT ANSWER

In Python you begin a comment with this character. When the interpreter sees it, it ignores everything from that character to the end of the line.

QUESTION 27

end-line comment

CORRECT ANSWER

a comment that appears at the end of a line of code

QUESTION 28

In an assignment statement, the variable that is receiving the assignment must appear on the

CORRECT ANSWER

left side of the = operator

QUESTION 35

You cannot use a variable until you have

CORRECT ANSWER

assigned a value to it.

QUESTION 36

Variable Naming Rules

CORRECT ANSWER

  1. You cannot use one of Python's key words.
  2. It cannot contain spaces.
  3. The first character must be one of the letters a through z, A through Z, or an underscore character ( _ )
  4. After the first character you may use the letters a through z or A through Z, the digits 0 through 9, or underscores.
  5. Uppercase and lowercase characters are distinct; they matter.

QUESTION 37

garbage collection

CORRECT ANSWER

Releases memory that was used for a variable's value once the variable is no longer to be used by a program.

QUESTION 38

variable reassignment

CORRECT ANSWER

to change the value of a variable based on its current value

QUESTION 39

data types

CORRECT ANSWER

Python uses _________ to categorize values in memory.

QUESTION 40

int

CORRECT ANSWER

In Python, when an integer is stored in memory, it is classified as this

QUESTION 41

float

CORRECT ANSWER

In python, when a real number is stored in memory, it is classified as this

QUESTION 42

numeric literal

CORRECT ANSWER

A number that is written into a program's code.

QUESTION 43

You cannot write _________,___________,___________in numeric literals

CORRECT ANSWER

currency symbols, spaces, or commas

QUESTION 44

str

CORRECT ANSWER

A Python data type that holds a string of characters. (used for storing strings in memory)

QUESTION 45

variable

CORRECT ANSWER

Keep in mind that in Python, a ___________ is just a name that refers to a piece of data When a program reads data from the keyboard, usually it stores that data in a ___________ so it can be used later by the program (same answer)

CORRECT ANSWER

A string value that has no characters, represented in code as "".

QUESTION 52

variable

CORRECT ANSWER

A location in memory used for storing data and given a name in a computer program is called a _________ because the data in the location can be changed.

QUESTION 53

foreground = "red"

CORRECT ANSWER

Associate the variable foreground with the value "red".

QUESTION 54

method invocation

CORRECT ANSWER

the line of code that causes a method to be executed

QUESTION 55

price%

CORRECT ANSWER

Assume that price is an integer variable whose value is the price (in US currency) in cents of an item. Assuming the item is paid for with a minimum amount of change and just single dollars, write an expression for the amount of change (in cents) that would have to be paid.

QUESTION 56

x%

CORRECT ANSWER

Assume that a variable x has been assigned a integer value,. Write an expression whose value is the last (rightmost) digit of x.

QUESTION 57

*n*

CORRECT ANSWER

The character escape sequence to force the cursor to go to the next line is

QUESTION 58

values

CORRECT ANSWER

Variables are called "variable" because they can reference different values while a program is running - when you assign a value; it will reference that value until you assign it a different value.

QUESTION 59

whole number

CORRECT ANSWER

A numeric literal that is written as a _____________ ______________ with no decimal point is considered an int

QUESTION 60

decimal point

CORRECT ANSWER

A numeric literal that is written as a ______________ _____________ is considered a float

QUESTION 61

input function

CORRECT ANSWER

reads a piece of data that has been entered at the keyboard and returns that piece of data, as a string, back to the program - you normally us this function in an assignment statement

QUESTION 62

prompt

CORRECT ANSWER

In the general format, _____________ is a string that is displayed on the screen.

QUESTION 63

CORRECT ANSWER

Python Integer division operator that divides one number by another and gives the result as a whole number

QUESTION 70

%

CORRECT ANSWER

Python remainder operator that divides one number by another and gives the remainder

QUESTION 71

CORRECT ANSWER

Python exponent operator that raises a number to a power

QUESTION 72

operands

CORRECT ANSWER

values that the + operator add together

QUESTION 73

mixed-type expression

CORRECT ANSWER

An expression that contains operands of different data types; also called mixed mode expression

QUESTION 74

line continuation character

CORRECT ANSWER

Python allows you to break a statement into multiple lines by using this; which is a backslash ( \ ) You simply type the backslash character (no parentheses) where you want to break the statement, then press the Enter key.

QUESTION 75

parentheses

CORRECT ANSWER

Python also allows you to break any part of a statement that is enclosed in ________________ without using the line continuation character.

QUESTION 76

newline character

CORRECT ANSWER

You can think of this as a special command that causes the computer to start a new line of output (you do not see it , but when it is displayed, it causes the output to advance to the next line)

QUESTION 77

end=' '

CORRECT ANSWER

A keyword parameter for the print() function that causes the function to NOT add a newline at the end of the string. (there is a space between the quotes)

QUESTION 78

end=''

CORRECT ANSWER

A keyword parameter for the print() function that causes the function to NOT add a newline at the end of the string and NOT add a space (there is not space between the quotes.

QUESTION 79

sep=''

CORRECT ANSWER

When multiple arguments are passed to the print function, they are automatically separated by a space when they are displayed on the screen, if you do NOT want a space printed between the items; you can pass this argument to the print function ie: OneTwoThree

QUESTION 80

sep=''*

CORRECT ANSWER

Causes a double quotation mark to be printed in Python ie: print("Your assignment is to read "Hamlet" by tomorrow.") -instead of print('Your assignment is to read"Hamlet" by tomorrow.') both work in Python

QUESTION 86

\

CORRECT ANSWER

Causes a backslash character to be printed; in Python ie: print('The path is C:\temp\data.') required when you want to print a backslash; a single one will not work in Python.

QUESTION 87

string concatenation

CORRECT ANSWER

This means that when using the plus sign + between string; itappeand one string to another ie: print('This is ' + 'one string.') will print: This is one string. It is useful for breaking up a string literal so a lengthy call to the print function can span multiple lines.

QUESTION 88

format function

CORRECT ANSWER

When you call the built-in format function, you pass two arguments to the function: a numeric value and a format specifier. Python has built-in format function that allow decimal places to be rounded a more. format( )

QUESTION 89

format specifier

CORRECT ANSWER

is a string that contains special characters specifying how the numeric value should be formatted

QUESTION 90

'.2f'

CORRECT ANSWER

A format specifier in Python that prints 2 decimal spaces; you can change the number to any number of decimal spaces

QUESTION 91

e

CORRECT ANSWER

If you prefer to display floating-point numbers in scientific notation, you can use this letter (either capitalized or not) instead of f ie: print(format(12345.6789, 'e')) will print: 1.234568= ie: print(format(12345.6789, '.2e')) will print: 1.23e+

QUESTION 92

Format specifier Minimum Field Width

CORRECT ANSWER

the minimum number of spaces that should be allowed to display the value ie: print('The number is, format(12345.6789, '12.2f)) The number is 12,345. This is for 12 spaces with 2 decimal points; this is for when numbers need to be printed in columns; it will be right justified (their decimal points will be aligned.

QUESTION 93

Formatting a Floating-Point Number as a Percentage

CORRECT ANSWER

Instead of using f as the type designator , use the % symbol