COMP 110 Quiz 1 & Exam 2025: While Loops and Boolean Expressions, Exams of Computer Security

A comprehensive set of true/false questions and exercises focused on while loops and boolean expressions in python programming. it tests understanding of loop control, boolean logic, and common programming concepts. The quiz is suitable for students learning introductory programming and includes detailed answers for self-assessment.

Typology: Exams

2024/2025

Available from 05/09/2025

titikshawales
titikshawales 🇺🇸

572 documents

1 / 27

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
COMP 110 - QUIZ 1 EXAM 2025 WITH 100%
ACCURATE SOLUTIONS
True or False: The while statement allows you to repeat a block
of statements in your program. - Precise Answer ✔✔- True
True or False: The while statement is called a loop because the
control of your program jumps back up to a point earlier in the
program than the end of the repeat block. - Precise Answer ✔✔-
True
True or False: You can name a variable while in your program
without Python confusing your variable's name and the while
keyword. - Precise Answer ✔✔- False
True or False: The condition in the while statement's syntax
must be a bool expression. - Precise Answer ✔✔- True
True or False: If the condition in a while statement evaluates to
False, control jumps over the repeat block and onto the next
statement at the same level of indentation as the while keyword.
- Precise Answer ✔✔- True
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b

Partial preview of the text

Download COMP 110 Quiz 1 & Exam 2025: While Loops and Boolean Expressions and more Exams Computer Security in PDF only on Docsity!

COMP 110 - QUIZ 1 EXAM 2025 WITH 100%

ACCURATE SOLUTIONS

True or False: The while statement allows you to repeat a block of statements in your program. - Precise Answer ✔✔- True

True or False: The while statement is called a loop because the control of your program jumps back up to a point earlier in the

program than the end of the repeat block. - Precise Answer ✔✔- True

True or False: You can name a variable while in your program without Python confusing your variable's name and the while

keyword. - Precise Answer ✔✔- False

True or False: The condition in the while statement's syntax must be a bool expression. - Precise Answer ✔✔- True

True or False: If the condition in a while statement evaluates to False, control jumps over the repeat block and onto the next statement at the same level of indentation as the while keyword.

  • Precise Answer ✔✔- True

True or False: If the condition in a while statement evaluates to True, control jumps into the repeat block and evaluates the first

statement of the repeat block. - Precise Answer ✔✔- True

True or False: After the final statement of the repeat block is evaluated, control jumps back up to the condition of the while

statement and evaluates it again. - Precise Answer ✔✔- True

True or False: You can write any statements you'd like inside of the repeat block, such as other print statements, variable declaration and assignment statements, conditional if-else statements, while loop statements, and so on. - Precise Answer ✔✔- True

To avoid an infinite loop which of the following should be true, choose all that apply:

  • Something must change in the repeat block that causes the while loop's condition to change.
  • Forward progress must be made toward the while loop condition becoming True.
  • Forward progress must be made toward the while loop

condition becoming False. - Precise Answer ✔✔- Something must change in the repeat block that causes the while loop's condition to change.

True or False: You can use a while loop to iterate through each item in a collection. For example, a str is a collection of characters, and you can use a while loop to iterate through each

character one-by-one. - Precise Answer ✔✔- True

True or False: The variable i is commonly used as a counter variable when writing while loops. You can choose other variable names instead, though. For example, counter could have been used as the variable name instead. - Precise Answer ✔✔- True

True or False: When iterating through a collection using the index/subscription operator, such as with a string, it is common to use your counter variable as the index operator's int value in order to access individual items in the collection one-by-one. -

Precise Answer ✔✔- True

True or False: The big, valuable idea of a loop is that it allows you to write a fixed number of lines of code that can process arbitrarily sized amounts of data and/or computations. - Precise

Answer ✔✔- True

What is the result of the following boolean expression?

not True

  • True
  • False - Precise Answer ✔✔- False

What is the result of the following boolean expression?

not not True

  • True
  • False - Precise Answer ✔✔- True

What is the result of the following boolean expression?

not True and not True

  • True
  • False - Precise Answer ✔✔- False

What is the result of the following boolean expression?

not True or not False

Which operator evaluates first?

  • and
  • not
  • or - Precise Answer ✔✔- not

Consider the following expression:

True and False or False and not False

Which operator evaluates last?

  • and
  • not
  • or - Precise Answer ✔✔- or

Evaluate the function: not True - Precise Answer ✔✔- False

Evaluate the function: not False - Precise Answer ✔✔- True

Evaluate the function: True and True - Precise Answer ✔✔- True

Evaluate the function: True and False - Precise Answer ✔✔- False

Evaluate the function: False and False - Precise Answer ✔✔- False

Evaluate the function: True or True - Precise Answer ✔✔- True

Evaluate the function: True or False - Precise Answer ✔✔- True

Evaluate the function: False or False - Precise Answer ✔✔- False

Rank these relational operators in terms of precedence, from first to last.

  • and
  • or
  • not - Precise Answer ✔✔- not
  • and
  • or
  • True
  • False - Precise Answer ✔✔- True

What does the following expression evaluate too?

"C" > "A"

  • True
  • False - Precise Answer ✔✔- True

True or False: The reason why the answer for the previous two questions are the same is because when you compare two strings the ordinal (ord) values of each character are compared. -

Precise Answer ✔✔- True

What is the result of evaluating chr(129313)?

  • cowboy emoji
  • clown emoji
  • peace emoji
  • laughing emoji - Precise Answer ✔✔- clown emoji

How many digits are there in hexadecimal ("hex") numbers?

  • 16 - Precise Answer ✔✔- 16

The largest hex digit is F. What is its value in the decimal system?

  • 16 - Precise Answer ✔✔- 15

True or False: The following string uses an escape sequence that causes it to span multiple lines when printed?

"Hello\nworld\n!!!" - Precise Answer ✔✔- True

True or False: Function calls are expressions that evaluate to a specific data type. - Precise Answer ✔✔- True

True or False: When you define a function you are invoking its call. - Precise Answer ✔✔- False

True or False: A function definition can be thought of as a sub- program that specifies the instructions which will be carried out

when the function definition is called. - Precise Answer ✔✔- True

Function definitions are found in which of the following ways:

  • Built-in functions automatically available
  • Imported from libraries
  • Defined in the same python file/module - Precise Answer ✔✔- Built-in functions automatically available
  • Imported from libraries
  • Defined in the same python file/module

True or False: Functions in programming are exactly equivalent to algebraic functions. - Precise Answer ✔✔- False

What are the syntax requirements of a valid function call expression?

  • the def keyword
  • the name of the function
  • an argument list
  • a parameter list
  • a function body - Precise Answer ✔✔- the name of the function
  • an argument list

True or False: Each argument is an expression. - Precise Answer ✔✔- True

A function definition is made of which of the following high- level elements?

  • Signature/"Contact" Line
  • Docstring for documentation purposes
  • Function Body Block
  • Argument list - Precise Answer ✔✔- Signature/"Contact" Line
  • Docstring for documentation purposes

True or False: Parameters are found in function definitions.

Arguments are found in function calls. - Precise Answer ✔✔- True

True or False: A parameter list is made of a pair of matching parentheses with a list of "variable declaration" statements separated by commas found between them, which specify the

parameters of the function. - Precise Answer ✔✔- True

When tracing a program to produce a memory diagram, much like the Python interpreter processes a program, and a function definition statement is encountered, what happens in our memory diagram? Choose all that apply.

  • The name of the function is entered into the current (for now Globals) frame of the stack.
  • A function object, represented as a box with the line numbers in which the function definition is found, is added to the heap.
  • An arrow binds the name of the function on the stack to the definition on the heap.
  • The statements inside the function definition body are evaluated immediately.
  • A value is returned. - Precise Answer ✔✔- The name of the function is entered into the current (for now Globals) frame of the stack.
  • A function object, represented as a box with the line numbers in which the function definition is found, is added to the heap.
  • An arrow binds the name of the function on the stack to the definition on the heap.

What steps are needed to prepare for a function call when tracing a program?

  • Check for the name of the function being defined.
  • Fully evaluate the argument expressions of the function call.
  • Ensure agreement between arguments of call and parameters of

definition. - Precise Answer ✔✔- Check for the name of the function being defined.

  • Fully evaluate the argument expressions of the function call.
  • Ensure agreement between arguments of call and parameters of definition.

When function call expressions are evaluated, new frames are added to which area of the memory diagram?

  • Stack
  • Heap
  • Output - Precise Answer ✔✔- Stack
  • The parameters of the function definition are established as variable names within the stack frame.
  • The fully evaluated values of argument expressions are assigned to the parameters in the function call frame.

True or False: The current frame of evaluation is the lowest

frame on the stack that has yet to return. - Precise Answer ✔✔- True

True or False: When determining the value of a variable access expression you must first look in the current frame of evaluation

on the stack. - Precise Answer ✔✔- True

What happens when a return statement is evaluated while tracing through a call to a function definition?

  • The expression following the return keyword is fully evaluated.
  • The Return Value ("RV") is recorded in the current frame on the stack.
  • Jump back to the origination of the function call found in Return Address ("RA") of frame and evaluate the function call expression to the return value stored in RV.
  • Establish another new frame on the stack. - Precise Answer ✔✔- The expression following the return keyword is fully evaluated.
  • The Return Value ("RV") is recorded in the current frame on the stack.
  • Jump back to the origination of the function call found in Return Address ("RA") of frame and evaluate the function call expression to the return value stored in RV.

True or False: The expression following the return keyword must evaluate to a value whose data type matches the return type specified in the signature line of its function definition. - Precise

Answer ✔✔- True

What is improper about the following function definition?

def hello)n(n: int) -> int:

"""A silly example function.""" return "hello " + str(n)

print(hello_n(3))

  • The parameter list is invalid.