CS125 Quiz 8 Questions

¡Supera tus tareas y exámenes ahora con Quizwiz!

Else in if-else statements does what in Python? A. Executes a statement if none of the if conditions are true. B. Executes a statement if all of the if conditions are true. C. Keeps repeating the loop until a condition is met. D. Stops the loop unless a condition is met. E. None of the above.

A

Exception handling is for catching errors in the code, and is done with which of the following commands: A. try and except B. if and except C. try and unless D. do or do not, there is no try E. None of the above

A

Statements that allow a program to execute different sequences of instructions for different cases are known as A. decision structure B. chaos structure C. body structure D. flow structure E. none of the above

A

The best structure for implementing a multi-way decision in python is? a.) if-elif-else b.) if c.) if-else d.) try e.) else

A

Things such as "<, >, =" etc. are called: A. relational operators B. mass operators C. comparative operators D. alligators and bridges E. None of the above

A

To avoid the redundant tests of the previous algorithm, we can use: A. A decision tree. B. Two-way decision. C. A sequential processing. D. A simple decision. E. Max of three.

A

A method used to avoid redundant testing of an algorithm is by using a A. trial and error approach B. redundant test approach C. decision tree approach D. multi processing approach E. none of the above

C

Which is not a strategy when presented with a decision problem? A. Compare each to all B. Decision tree C. Sequential processing D. Step by step processing E. All of the above

D

Which of the following is defined as a statement that allows a program to execute different sequences of instructions for different cases? A. Boolean Expressions. B. Compound Conditions. C. Control Structures D. Decision Structures. E. None of the above.

D

elif is used in what type of decisions? A. One way decisions B. Two way decisions C. Zero way decision D. Multi way decisions E. All of the above

D

A Boolean expression is: A. Always True and False. B. Just True. C. Either True or False. D. Just False. E. Not all of the above.

C

To write a program that gives a warning for when temperature is equal to or over 90 how would you write it? A. if temp >= 90 else print("Warning") B. if temp >= 90 else print(Warning) C. if temp = 90 else print("Warning") D. if temp => 90 else print("Warning") E. if 90 >= temp else print("Warning")

A

What are Decision structures? A. Control structures that allow a program to execute different sequences of instructions for different cases. B. Control structures that do a specific thing. C. Instructions to control structures. D. A program reader. E. None of the above.

A

What are python modules that can be imported called? A. Libraries B. Settings C. Scripts D. Programs E. Extensions

A

What can be implemented to use a multi-way decision? A. if-elif-else B. if-else-elif C. try-except D. try-if D. none of the above

A

What does Python look for after a try statement? A. an except clause B. an if statement C. a boolean expression D. a second try statement E. none of the above

A

What does lexicographic means when ordering strings? A. Strings are put into alphabetical order. B. loop. C. Strings lowercase letters comes before uppercase letters. D. Starts script E. Starts print

A

What error message do you receive when your program comes across a ValueError? A. ValueError: math domain error B. ValueError C. ValueError: unavailable value entered D. Incorrect input received E. DomainError: value error

A

What happens in a two-way decision? A. the inputs are fed through two expressions B. there are two inputs C. the computer makes two decisions D. the computer makes two outputs for you to decide on E. you have to decide on your own two inputs

A

What is the result of the following condition? >>> "John" < "bob" A. True B. False C. SyntaxError D. ValueError E. NameError

A

What is wrong with the following code? color = input("Enter a color name: ") if color = 'green': print("green is a lovely color!") A. The if statement operand should be ==, not just = B. The definition of color should use ==, not = C. There shouldn't be quotations around green D. The print statement doesn't need quotations E. The if statement should actually be a while loop

A

Which of the following are the dedicated literals for the bool data type in Python? A. True, False B. Yes, No C. 0, 1 D. Positive, Negative E. All of the Above

A

Which of the following is a relational operator? A. ==. B. =. C. ++. D. ^. E. None of the above.

A

Which of the listed below is the structure of an if statement A. if <condition> <body> B. if <condition><body> C. if <body> <condition> D. if <body><condition> E. if <body> (<condition>)

A

Which of these are for a two-way decision programming pattern? A. if-else statement B. if statement C. if-elif-else statement D. try-except statement E. None of the Above.

A

Statements that allow a program to execute different sequences of instructions for different cases are called A. control structures B. decision structures C. control statements D. decision statements E. none of the above

B

What are the six relational operators in Python? A. +, -, <,>, ?, } B. <, >, <=, >=, ==, != C. <, >, = , >=, ==, != D. <, >, + , -, ==, != E. none of the above.

B

A statement that branches into multiple other options is called what? A. branch statement B. decision tree C. tree statement D. web decision E. simple decision

B

In all if-elif-else decision structures, how many statements will be executed? A. zero B. one C. two D. three E. all of them

B

Lexigraphic ordering sorts by A. ASCII values. B. Unicode. C. Alphabetizing. D. String length. E. None of the above.

B

Placing a decision inside of another decision is indicated by? a.) parentheses b.) indentation c.) curly braces d.) a colon e.) None of the above

B

Python has a built-in function called______that returns the largest of its parameters. A. Network. B. Max. C. Tree D. Script. E. Value.

B

Special statements that allow programs to execute different sequences of instructions for different cases are called: A. control structures B. decision structure C. turns D. choice structures E. None of the above

B

What are the three strategies for writing a program to compare more than two values? A. Design, Implementation, and Debugging. B. Comparing them all, Decision Tree, and Sequential Processing. C. Decision Tree, Decision Bush, and Decision Flower. D. Compare/contrast, Addition, and Subtraction. E. None of the above.

B

What does it mean that strings are lexicographic? A. Lowercase letters are sorted before uppercase by Unicode standards B. Uppercase letters are sorted before lowercase by Unicode standards C. All letters are sorted before numbers by Unicode standards D. Special characters are sorted before letters by Unicode standards E. None of the above

B

What happens when a Boolean expression is evaluated? A. the command loops B. it produces a value of true or false C. it calculates a value D. it is only evaluated if the condition is met E. none of the above

B

What is <relop> short for? A. conditional operator. B. relational operator. C. operator. D. reloop statement. E. None of the above.

B

What is an example of a two way decision? A. if else B. if-elif-else C. if-elif else D. if elif-else E. None of the above

B

What is the body of an if statement? A. A collection of variables for use in the program. B. A sequence of one or more statements indented under the if statement. C. The condition of the if statement. D. A collection of further if statements. E. None of the above.

B

What is the body portion of a condition? A. The result of a conditional statement. B. Sequence of one more statement indented under the if heading. C. The list of possible answers of an if statement. D. The middle section of a boolean statement. E. None of the above.

B

What kind of exception handling does Python use? A. except-handle B. try-except C. try-else D. try-if-except E. none of the above

B

What kind of expression is a condition? A. complex. B. Boolean. C. simple. D. one-way. E. two-way.

B

What statement is used to set a maximum value? A. max B. maxval C. maxvalue D. maximum E. top

B

What symbol or symbols are used to represent "equal to" A. = B. == C. === D. != E. =!

B

When a program is being run directly the value of the __name__ is? A. __Main__ B. __main__ C. main D. Main E. script

B

When you are working with loops, how are you able to gain access to the loop? A. If it's in the code, you are able to access it. B. The statement must be true in order to gain access. C. Loops are always run, you don't need to gain access. D. You have to guess to figure out what you need to input, in order to gain access. E. You don't gain access, the loop does nothing special, just an organizational method.

B

Which Rational Operator refers to " equal to"? A. = B. == C. != D. >= E. <=

B

Which of the following is NOT a relational operator in Python? A. < B. =! C. == D. >= E. None of the Above

B

Which of the following is not an example of a relational operator in Python? A. < B. === C. >= D. != E. <=

B

Which of the following python keywords allows you to test multiple conditions? A. or. B. and. C. elif D. try. E. else.

B

Which of these if statements are multi-way decisions? A. if B. if-elif-else C. else if D. if-else E. true-false

B

Which of these if statements are multi-way decisions? A. if B. if-elif-else C. if-else D. else if E. None of the Above

B

A Boolean expression is one that returns values of: A. negative or positive B. greater than or less than C. true or false D. 0 and 1 E. None of the above

C

According to the following program, which set of statements will be executed? x = -5 if x >= 0: print("Happy Halloween!") else: print("Merry Christmas!") A. Both statements will be executed. B. The if statement will be executed. C. The else statement will be executed. D. Neither statement will be executed. E. The program will not run and an error message will be printed.

C

Conditions are actually a type of expressions called ____ , named after George Boole. A. Goorgie expressions. B. Boole expressions. C. Boolean expressions. D. Baboolean expressions. E. GooBoo expressions.

C

Decisions are based on the evaluation of? A. functions B. operators C. conditions D. algorithms E. mechanisms

C

How can you create a conditional program that will execute when run directly, but not when imported? A. Use a try statement to see if the special variable __name__ does not exist. If true, the program runs main(). B. Use an if statement to check the special variable __name__ and see if it equals the scripts name. If true, the program runs main(). C. Use an if statement to check the special variable __name__ and see if it equals __main__. If true, the program runs main(). D. Use a try statement to see if the special variable __name__ exists. If true, an except statement tells the program to run main(). E. None of the Above

C

Mathematical concepts like " less than" or "equal to" are known as what in python? A. Operators. B. Mathematical operators. C. Rational Operators. D. Imaginary Operators. E. None of the above.

C

Statements that allow a program to execute different sequences of instructions for different cases are known as A. control structures B. choose structures C. decision structures D. flow structures E. none of the above

C

Two-way decisions can be implemented by attaching an ____ clause onto an if clause. A. extra. B. second. C. else. D. other. E. None of the above.

C

What are all the relational operators that conditions are formed? A. = B. <, >, and = C. <, <=, !=, ==, >, and >=. D. =, !=, and ==. E. None of the Above.

C

What are decision structures? A. Guides that assist in decision-making. B. Structures constructed by many decisions. C. Statements that allow a program to execute different sequences of instructions for different cases. D. A piece of code that is made up of many different inputs from a user. E. None of the above.

C

What does "nesting" mean in the Python language? A. combining strings and numbers. B. doing a concatenation using plus signs. C. putting one compound statement inside another. D. multiplication or repetition. E. none of the above.

C

What does lexicographic ordering entail? A. Strings are put in alphabetical order according to only the first Unicode value of the string B. Strings are put in alphabetical order according to only the first letter C. Strings are put in alphabetical order according to the underlying Unicode values of the string D. Strings are put in order from Z to A according to the underlying Unicode values of the string E. Strings are put in order from Z to A according to only the first Unicode value of the string

C

What happens when the condition of a simple decision structure is false? A. The body text is executed normally. B. A syntax error occurs. C. The body text is skipped. D. The program completely stops. E. All of the above

C

What is a Boolean expression? A. An expression that can only be done using an elif statement. B. A scary ghost that leans to the side. C. A conditional expression that concludes if the value is true or false. D. All of the above. E. None of the above.

C

What is a relational operator in Python? A. Determines the relationships between two variables. B. <relop> C. Just a fancy name for the mathematical concepts like "less than" or "equal to". D. Just an extra word placed in front of operator, to mean math concept. E. Refers to any of the math concepts within Python.

C

What is an if-else statement an example of? A. multi-way decision B. an error C. two-way decision D. simple decision E. None of the above

C

What is the term for when an input is completely wrong and there is a stop in the program for it? A. multi-way decision B. decision tree C. an exception handler D. false statement E. error statement

C

What operator Python program uses to represent equality? A. = B. =! C. == D. <=> E. =+

C

What statement is used for multi-way decision programs? A. if statements B. if-else statements C. if-elif-else statements D. while statements E. None of the above

C

When a module is imported, Python creates a special variable and assigns it a string representing the module's name, the variable looks like which of the following? A. _name_ B. _variable_ C. __name__ D. __.name.__ E. _-_name_-_

C

When using a flow chart, what do the diamond "boxes" represent? A. Outcomes. B. Values. C. Conditional Decisions. D. Inputs. E. Decisions.

C

Which expression is short for relational operator? A. <rel> B. <ro> C. <relop> D. <relat> E. <relot>

C

Which of the following always makes a multi-way decision? A. if B. else C. elif D. try E. none of the above

C

Which of the following is not a relational operator A. > B. <= C. = D. != E. ==

C

Which statement is used to say when not to do one thing do another? A. if B. then C. else D. elif E. instead

C

A multiple choice question is most similar to ? a.) decision b.) an exception handler c.) two-way decision d.) multi-way decision e.) simple decision

D

After the "if" and before the colon, in an "if" statement, is the A. statement. B. decision. C. body. D. condition. E. definition.

D

For a program that has over two decisions, what order of commands would you use? A. If first, then else, then else. B. If first, then elif, then elif. C. If first, then not, then not. D. If first, then elif, then else. E. If first, then else, then elif.

D

In Python, what does = indicate, and what does == indicate? A. = indicates equality, == indicates an assignment statement. B. They both mean the same thing, similar to '' and "" meaning the same thing. C. = indicates an assignment statement, == indicates no equal to. D. = indicates an assignment statement, == indicates equality. E. None of the above

D

Multi-way decisions are implemented with: A. if-el-else B. elif-else-if C. if-else-elif D. if-elif-else E. if-elif-el

D

Python modules that are designed to be imported and used by other programs are called A. .py files B. scripts C. imported files D. libraries E. none of the above

D

The literals for type bool are? a.) T, F b.) True, False c.) 1,0 d.) true,false e.) All of the above

D

This question is most like what kind of scenario? A. simple descision B. primary decision C. two-way decision D. multi-way descision E. an exception handler

D

What Python modules are designed to be imported and used by other modules? A. Programs B. Scripts C. Strings D. Libraries E. All of the above

D

What are the names of statements used for a multi-way decision? A. if-elif B. if-while-else C. try-except D. if-elif-else E. if-except

D

What is Tkinter A. A library that must be imported manually in Python B. A type of expression in Python. C. The name of the command prompt that Python uses. D. Default GUI interface that comes with Python. E. The component that helps decrease memory usage in Python.

D

What is the difference between a library and a program/script in Python? A. Libraries are past programs/scripts. B. A library is a program that someone else wrote to use in a personal program/script. C. Libraries are run directly, while programs/scripts are meant to be imported. D. Programs/scripts are run directly, while libraries are meant to be imported. E. Programs/scripts is anything written in Python.

D

What is the ordering when comparing strings? A. pythongraphic B. unixgraphic C. softgraphic D. lexicographic E. compgraphic

D

What is the result of this example interaction: >>> "Computer" < "computer" A. Error B. true C. false D. True E. no

D

What literals represent Boolean values? A. Yes and no. B. And and not. C. Or and not. D. True and false. E. Boolean values are numbers.

D

What statements are used to handle exceptions in Python? A. try...accept B. try...handle C. try...catch D. try...except E. try...correct

D

What will be the output of the statement max("Four", "4", "Five", "5")? A. '4'. B. 'Five'. C. '5'. D. 'Four'. E. TypeError.

D

Which is Python's exception handling mechanisms? A. try B. except C. If-else D. try-except E. All of the Above

D

An if statement is a ______ decision. A. Two-way B. Complex C. Simple D. One-way E. Both C and D.

E

How to do an if-else statement in Python? A. else if B. if else C. ifel D. if-else E. elif

E

In python conditions not equal to is written as? a.) none b.) =! c.) =/ d.) /= e.) !=

E

Putting one compound statement inside another is called: A. Overlap B. Combination. C. Insertion. D. Procrastination. E. Nesting.

E

The elif statement stands for: A. eliminate if B. elaborate if C. enumerate if D. elongate if E. None of the above

E

What are some relational operators in mathematics? A. <= B. != C. >= D. == E. None of the above

E

What are some relational operators in python? A. < B. <= C. == D. >= E. All of the above

E

What does the try...except statement allow us to do? A. Create a program with many errors within it. B. Suggests you to try certain variables, some are correct others are not. C. Allows you to guess what values are not permitted to be used. D. Try all values except for ones listed. E Write bullet-proof programs.

E

What is the purpose of a try statement? A. It will carry out the entire program without error B. It will only carry out the function you put the statement in C. It will rewrite your code to carry out the purpose of the function better D. It will fix any errors in your code E. It will test your code for errors

E

What is true about conditions? A. conditions may compare either number or strings. B. strings are in alphabetical order according to the underlying Unicode values. C. all uppercase Latin letters come before lowercase equivalents. D. when comparing strings, the ordering is lexicographic. E. all of the above.

E

What kind of statement is used to avoid nesting if-else structures? A. else. B. if. C. try. D. except. E. elif.

E

What point can you expand on simple conditions? A. when the condition thinks it's right B. when the expression is false C. when the expression makes sense D. when the expression does not make sense E. when the expression is true

E

What type of statement is used to implement a decision? A. A What statement. B. A When statement. C. A Who statement. D. A Where statement. E. An If statement.

E

Which of the following is a mechanism that catches and deals with errors as the program is running? A. Nesting. B. Sequential Processing. C. Decision Trees. D. Multi-Way Decisions. E. Exception Handling.

E

Which of the following relational operators means "greater than or equal to"? A. < B. > C. != D. <= E. >=

E


Conjuntos de estudio relacionados

Homework: 2.2 Organizing Quantitative Data and Skewness

View Set

Structure of Healthcare Enterprises

View Set

ATI CHAPTER 5 MENINGITIS - MEDICAL SURGICAL NURSING

View Set

Chapter 4 States of Consciousness

View Set

Do Now Test 1st Semester & 3rd Quarter

View Set

Chapter 23: PrepU - Nursing Management: Patients With Gastric and Duodenal Disorders

View Set

MIS Chapter 1, Chapter 2, Chapter 3, Chapter 4

View Set