CS125 Quiz 9 Questions
At least how many times must a post-test loop execute the body of a loop? A. once B. twice C. three times D. four times E. as many as the programmer commands
A
Continuing to reprompt an incorrect value until a correct one in inputted is called. A. Input validation B. Interactive loops C. Nested loops D. Decision structure E. All of the above
A
GUI programs are generally... A. Event driven. B. Time driven. C. Input driven. D. Both B and C. E. All of the above.
A
The statement while is a/an... A. Indefinite Loop B. Definite Loop C. Nested Loop D. File Loop E. Sentinel Loop
A
What are file loops? A. When you type all of the numbers into a file. B. When the exit is in the middle of the body. C. Priming read is part of the pattern. D. A loop pattern that asks the user whether to continue on each interaction. E. A loop that handles input until a special input is required.
A
What code "exits" out of a while loop? A. break B. return C. end D. exit E. None of the above.
A
What do boolean statements represent? A. True and False B. Sum and Multiplication C. Conditions & Statements D. All of the above E. None of the above
A
What does range do? a) returns a sequence of numbers starting at 0 and stops at a number you set. b) sorts your strings numbers. c) returns the average of user input numbers. d) return the average of string numbers.
A
What is a Python for loop? A. A definite loop that iterates through a sequence. B. An indefinite loop that doesn't iterate through a sequence. C. A definite loop that doesn't iterate through a sequence. D. A loop that repeats itself. E. All of the above.
A
What is a pattern that asks the user whether to continue on iteration? A. Interactive loop B. Infinite loop C. Sentinel loop D. end-of-file loop E. None of the above.
A
What is an indefinite loop? A. A loop that keeps iterating until certain conditions are met B. A loop that iterates a set amount of times determined when the loop starts C. A loop that is undefined under a certain set of conditions D. A loop that is always nested inside of an if statement E. All of the Above
A
What is python's standard precedence rules for Boolean operators, ordered from high to low? A. not, and, or. B. or, and, not. C. and, or, not. D. and, not, or. E. or, not, and.
A
What is the easiest way to read lines from a file one at a time? A. 'for line in infile' B. 'for every line in the file' C. 'while every line in the file' D. 'if line = infile' E. 'infile = line'
A
What is the first item that is retrieved before a loop starts? A. priming read B. pre-test read C. test statement D. variable E. All of the above
A
What is the processed called when a loop keeps asking for an input until it receives a valid value? A. Input validation B. Validation C. Input accuracy D. Actual data value E. Reprompting
A
What is the result of this example interaction: >>> bool("hi") A. True B. true C. false D. False E. error
A
What process askes to continue on each itteration? A. interactive loop B. sentinel loop C. end-of-file loop D. infinite loop E. none of the above
A
When a loop continues creating output without an end that is called which sort of loop? A. Infinite loop B. Endless loop C. Repeating Loop D. Indefinite E. None of the above
A
Which execution will cause Python to end immediately? A. break B. _break C. end D. pressing command q E. any of the above will work
A
Which loop is an interactive loop that allows portions of a program to be repeated according to the wishes of the user? A. Interactive loop. B. Sentinel loop. C. Infinite loop. D. End-of-file loop. E. None of the above.
A
Which value would end a sentinal loop A. -67 B. 0 C. 1 D. 14 E. 32
A
Who created Boolean Algebra? A. George Boole B. Booley Einstein C. John Koch D. Ryan Boolean E. John Zelle
A
not is a _____ operator, as it operates on a single expression. A. unary B. binary C. trinary D. sole E. None of the above.
A
A loop pattern that asks the user whether to continue on each iteration is called A. continual loop B. Interactive loop C. sentinel loop D. definite loop E. none of the above
B
A loop that never ends is known as? A. busy loop B. infinite loop C. indefinite loop D. never ending loop E. termination loop
B
A sentinel loop is when the loop continues to process data until: A. The user performs the quit command B. It reaches a value called the sentinel C. The loop crashes the program D. The try and except commands are used E. None of the above
B
Algebraic laws that Boolean expressions follow are known as Boolean ____ or ____. A. math, science B. logic, algebra C. laws, orders D. code, script E. None of the above.
B
Boolean expressions can be either ____ or _____. A. Out of Bounds, Incorrect B. True, False C. Specified, Unspecified D. Invaluable, Worthless E. None of the above.
B
Using a while loop, the loop will keep going as long as? A. The condition is false B. The condition is true C. The condition is less than zero D. The condition is greater than zero E. None of the above
B
What are the three Boolean operators? A. +, -, = B. "and" , "or" and "not" C. "and", "or" and "yes" D. "true", "false" and "equal" E. "True" , "False" and "Equal"
B
What does .format do? a) formats the entirety of the code. b) allows you format string in any way you want. c) formats all the strings. d) formats all your functions.
B
What is a "nested loop" ? A. an infinite loop. B. a loop inside a loop. C. a boolean loop. D. a sentinel loop. E. all of the above.
B
What is a nested loop? A. A loop that resides towards the beginning of a program. B. A loop inside a loop. C. A loop that is separated from the rest of the program. D. All of the above. E. None of the above.
B
What is a sentinel loop? A. A loop that continuously sends values to functions. B. A loop that continues forever until a special value is entered, which ends the loop. C. A program that stands guard against viruses. D. A program that runs forever with no stopping. E. A loop that checks the other lines of a program for errors.
B
What is an event loop? A. a loop that handles input until a special input is required. B. program responds by processing an event. C. a loop pattern that asks the user whether to continue on each interaction. D. A loop structure that tests the loop condition after executing the loop body. E. Priming read is part of the pattern
B
What is an interactive loop? A. A loop that isn't controlled by the user. B. A loop that allows for portions of a program to be repeated according to the user. C. A loop that kills portions of a program according to the user. D. A loop that repeats a defined portion of a program according to the programmer. E. None of the Above.
B
What is it called when a loop has an exit in the middle of the body? A. Nested loop B. Loop and a half C. Pre-test loop D. while loop E. Post-test loop
B
What is one good use for the indefinite loop? A. while loop B. Interactive loop C. for D. elif E. sentinel loop
B
What loop style are modern graphics programs written in? A. Loop and a half B. Event loop C. Nested loop D. If elif loop E. None of the above
B
What sort of loop keeps iterating until certain conditions are met? A. Loop-dee-loop B. Indefinite C. Infinite D. Definite E. None of the above
B
What starts a class definition? a) def b) class c)__init__ d) object
B
What statement implements an indefinite loop? A. loop B. while C. if D. else E. all of the above
B
Which loop is a loop that handles input until a special value is encountered? A. Interactive loop. B. Sentinel loop. C. Infinite loop. D. End-of-file loop. E. None of the above.
B
Which of the following is a binary operator? A. while B. or C. not D. True E. All of the above.
B
Which of the following is a sential loop? A. for n in range(11): <body> B. while userString != "": <body> C. if n >= 2: <body> D. if n == 2: <body>, else: <body> E. All of the Above
B
Which of the following is the correct way to write a for loop? A. for <sequence> in <var>: <body> B. for <var> in <sequence>: <body> C. for <sequence>: <body> D. for <if <condition>>: <body> E. None of the Above
B
What causes an indefinite loop? A. The loop can never be entered. B. The condition to exit or ask for another input is met, so it continues to repeat the loop. C. The condition to exit or ask for another input is never met, so it continues to repeat the loop. D. You must guess the input that it is looking for in order to stop it. E. No conditions are created within the loop.
C
What is a "priming read?" A. Reading the last number outside of a loop before carrying it out B. Reading the second number outside of a loop before carrying it out C. Reading the first number outside of a loop before carrying it out D. Python checking your loop for any errors before the program runs E. Python specifically running your loop as a separate program
C
What is a sentinel loop. A. A loop that lets other loops handle input. B. A loop that handles input indefinitely. C. A loop that handles input until a special value is encountered. D. A loop that can't handle input. E. All of the Above.
C
What is a sentinel loop? A. continued loop pattern B. Definite loop C. a loop that handles input until a special input is required. D. uses a while loop E. boolean loop
C
What is another name for a conditional loop? A. definite loop B. develop loop C. indefinite loop D. indirect loop E. none of the above
C
What is input validation? A. The program checks to make sure the input is a positive number B. The program checks to make sure the input is a string C. The program reprompts until the user enters a valid value for the input D. The program reprompts until the user enters an invalid value for the input E. None of the Above
C
What is the easiest way to read lines from a file at a time? A. using a text document. B. using ReadAPP. C. using for line in infile. D. using Python_4.5. E. none of the above.
C
What kind of loop continues to process data until reaching a special value that signals the end? A. conditional loop B. indirect loop C. sentinel loop D. direct loop E. moderate loop
C
What type of loop is a for loop? A. Indefinite that goes until a condition is met B. Definite and multi-way decision based C. Definite that iterates through a sequence D. Definite and makes a two way decision E. None of the above
C
A Python ___ loop is a definite loop that iterates through a sequence? A. interactive B. conditional C. modal D. for E. All of the above
D
A loop that never terminates is called? A. Indefinite. B. Busy. C. Tight. D. Infinite. E. None of the above.
D
An empty string is represented in python as? A. $ B. !! C. (): D. "" E. All of the above
D
If the program: def main(): n = 5 while n != 6: n -= 1 print(n) main() is ran what would happen? A. Program will repeat until it reaches the value of 5 B. Program will repeat until it reaches the value of 1 C. Program will repeat until it reaches the value of 6 D. Program will never stop repeating E. Program will print "n"
D
The number/numbers in between the parentheses of range() determines... A. The value that the range is being found for B. An amount the range will be multiplied by C. A set of numbers that the range will be determined for D. The length that the program will find range in-between E. None of the above
D
The term for using a loop within another loop is _____. A. Combining B. Sequencing C. Verifying D. Nesting E. All of the above.
D
Using the rules of Algebra, what is the correct way to write a + 0 = a in Boolean Algebra? A. a and b == c B. a and false == false C. a and true == a D. a or false == a E. None of the above
D
What do you use to make a string span multiple lines? a) " b) ' c) """ d) \
D
What is a Python while loop? A. A definite loop that iterates through a sequence. B. An indefinite loop that doesn't iterate through a sequence. C. A definite loop that doesn't iterate through a sequence. D. An indefinite loop that continues to iterate for as long as the loop conditions are true. E. All of the above.
D
What is a for loop also called? A. Infinite loop B. Regular loop C. Complicated loop D. Definite loop E. None of the above
D
What is the easiest way to read lines from a file one line at a time? A. while line != "": B. for infile in line: C. while line == "": D. for line in infile: E. There is no way to read lines from a file one line at a time in Python.
D
What is the output of the following code: >>> list = ([1, 2, 3], [4, 5, 6]) >>> print(list[1][1]) A. 1 B. 2 C. 4 D. 5 E. 6
D
What is the term for a loop where the exit is in the middle of the loop body? A. Indefinite. B. Definite. C. Conditional. D. Loop and a half. E. None of the above.
D
What is true about Boolean algebra? A. a and false == true B. a and true == b C. a or false == ! D. a or false == a E. none of the above.
D
What statement causes a loop to end? A. break B. quit C. stop D. exit E. false
D
What statement will indicate the usage of a "loop and a half?" A. quit() B. end() C. while D. break E. if
D
What type of loop continues until a certain condition is met? A. if loops B. if else loops C. if elif else loops D. while loops E. None of the above
D
When the first item is retrieved before the loop starts it is called A. proof read B. base read C. first read D. prime read E. all of the above
D
Which of the following loops will keep iterating until certain conditions are met? A. definite loop B. interactive loop C. validation loop D. indefinitely loop E. none of the above
D
Which of these is the term used to describe the parts of a program in which the user is in control of how to interact? A. Modal. B. Bimodal. C. Not modal. D. Nonmodal. E. Quasimodal.
D
Within a sentinel loop, what is the value called that ends the loop? A. Actual data value B. Argument C. Variable D. Sentinel E. Condition
D
what does math.pi do? a) imports pythons built-in math functions. b) returns random numbers. c) returns an infinite number. d) returns the value of Pi.
D
If a user types an incorrect value into a program, the program will ask for another value. What is the name of this process? A. input check B. validation check C. system check D. event check E. none of the above
E
In python, the expression True + True + True will evaluate to which of the following outputs? A. TrueTrueTrue. B. 0. C. True True True. D. False. E. 3.
E
Using DeMorgan's Law, we can convert the complex statement "not(ch >= 'a' and ch <= 'z')" into a simpler statement by distributing a unary operator. Which of the following statements is simplified? A. not(ch < 'a' or ch > 'z') B. (ch < 'a' and ch > 'z') C. (ch >= 'a' or ch <= 'z') D. not(ch < 'a' and ch > 'z') E. (ch < 'a' or ch > 'z')
E
Using a loop and a half can avoid doing what? A. using a post-test loop B. using a boolean expression C. using a indefinite loop D. using a file loop E. using a sentinel loop
E
What are the uses of loops? A. Reading a file. B. Traversing a list, or string, or array. C. Repeatedly executing a condition. D. Shortens repetitive typing. E. All of the Above.
E
What does the break statement do? A. Does not allow for the program to be run again. B. A way to just close the program window. C. Fixes programming errors D. Breaks the program E Causes the loop to immediately close.
E
What is a loop called when the exit is in the middle of the body? A. Sentinel loop B. Interactive loop C. Infinite loop D. end-of-file loop E. Loop and a half
E
What is an indefinite loop? A. A loop that is not exact. B. A loop that is not sure what it is doing. C. A nested loop. D. Not really a loop. E. A loop implemented when using the while statement.
E
What is the error with the following code: n = 10 i = 6 while i < n: print(i) A. i should be 0 B. n should be less than i C. There should be an exception for the while loop adding 1 to i D. The while loop should be an if statement E. After print, there should be a definition of i where it is increased by 1, otherwise it will be a sentinel loop
E
Which of the following is a Boolean operator? A. for B. of C. the D. if E. and
E
Which of the following lists ALL of the Boolean operators? A. and, or, not, either B. and, not, C. and, or D. and, or, not, next E. and, or, not
E
Which statement is an example of an indefinite loop? A. If. B. If-else. C. If-else-elif. D. When. E. Where.
E
A Python _____ statement is an example of an indefinite loop? A. print B. constant C. while D. staggered E. All of the above
C
A for loop is an example of what type of loop structure? A. Indefinite. B. Conditional. C. Definite D. End of file. E. None of the above.
C
A loop with the exit in the middle of the loop body is called: A. Early exit B. Mid exit C. Loop and a half D. Premature loop E. None of the above
C
A sentinel loop continues to process data until reaching a what? A. answer B. break C. sentinel D. command E. None of the above.
C
An indefinite loop ends when... A. The value equals 0 B. The value equals 1 C. The condition is no longer met D. The condition is met E. At the end of the set amount
C
An operator that operates on single expression is called a: A. Unity operator B. Unify operator C. Unary operator D. Singular operator E. None of the above
C
If the condition is true, the while loop A. produces an error message. B. will stop. C. will keep going. D. will be skipped. E. pauses.
C
In GUI applications when a dialog box pops up and forces a user to interact to dismiss the dialog before using the application it is known as A. model dialog B. entry dialog C. modal dialog D. open dialog E. door dialog
C
Indefinite loops are good for writing? A. variables B. iterations C. interactive loops D. loops E. All of the above
C
What can be done to escape an infinite loop? A. Type "stop." B. Press Control-q C. Press Control-c D. Press Control-d E. Press enter.
C
What can happen if the condition of a while loop is not changed at all within the loop when it repeats? A. The program will continue forward without looping. B. The program will crash. C. The program will get stuck in an infinite loop and never end. D. The program will immediately stop and print out an error message. E. The entire computer will explode.
C
