COSC 1436 Quiz 3

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

x < y or z > x What is the result of the following Boolean expression, given that x = 5, y = 3, and z = 8? not (x < y or z> x) and y< z a. 5 b. 8 c. True d. False

d. False

Match the relational operators with its meaning: > < >= <= == !=

> Greater than. < Less than >= Greater than or equal to <= Less than or equal to == Equal to != Not equal to

If score = -1, What is the output of the following code? if score == 0: print ("Test was not taken") elif score < 0 or score > 100: print ("Score is not valid") else: print ("Your score is:", score) a. Score is not valid b. Score is valid c. Test was not taken d. ERROR e. Your score is: -1

a. Score is not valid

Assume the variables: a == 2, b = 4, c = 6 The result of the following expressions is [True/ False]? a == 4 or b > 2 a. True b. False

a. True

What is the result of the following Boolean expression , given that x = 5, y = 3, and z = 8? x < y or z> x a. True b. 5 c. False d. 8

a. True

When using the ________ logical operator, both subexpressions must be true for the compound expression to be true. a. and b. not c. or d. either or or and

a. and

Select the if statement that assigns .2 to comissionRate if the monthlySales is greater than 10000. a. if monthlySales > 10000: commissionRate = .2 b. if monthlySales > 10000 commissionRate = .2 c. if monthlySales > 10000: commissionRate == .2 d. if monthlySales > 10000: .2 = commissionRate

a. if monthlySales > 10000: commissionRate = .2

What is the value of z after the following code is executed? x = 10 y = 40 z = 0 if x >= y: z = x + y else: z = y % x a. 4 b. 0 c. 50 d. 400

b. 0

(True or False) The following code snippet is an example of nested if statement. if student == 'Y' : print("student!") elif student == 'N' : print("Not student!") else: print("Error!") a. True b. False

b. False

An if statement that displays 'Speed is normal' if the speed variable is between the range of 55 - 65 is: if speed >= 55 or speed <= 65: print('Speed is normal') a. True b. False

b. False

Consider the following statements. If the input is 85, the output of the following code will be: score = 0 grade = "Unknown" score = int(input("Enter a score: ")) if score >= 90: grade = "A" if score >= 80: grade = "B" if score >= 70: grade = "C" if score >= 60: grade = "D" else: grade = "F" print (grade) a. B b. A c. D e. F f. G

c. D

Which of the following is NOT a logical operator: a. or b. not c. if d. and

c. if

Which of the following is the correct if clause to determine whether choice is anything other than 10? a. if not (choice < 10 and choice > 10): b. if choice <> 10: c. if choice != 10: d. if choice != 10

c. if choice != 10:

A(n) _______ statement will execute one block of statements if its condition is true or another block if its condition is false. a. print b. if c. if-else d. ==

c. if-else

Which of the following will assign a random integer in the range of 1 through 50 to the variable number? a. randint(1, 50) = number b. random (1, 50) = number c. number = random.randint(1, 50) d. number = random(range(1, 50))

c. number = random.randint(1, 50)

Which logical operators perform short-circuit evaluation? a. or, not b. not, and c. or, and d. and, or, not

c. or, and

What is the output of the following code? x = 10 if x != 10: print("This is true!") else: print("This is false!") print("This is all folks!") a. This is false! b. This is true! This is all folks! c. This is true! d. This is false! This is all folks!

d. This is false! This is all folks!

Which of the following is the correct if clause to determine whether y is in the range 10 through 50, inclusive? a. if 10 < y or y> 50: b. if y >= 10 or y <= 50: c. if 10 > y and y < 50: d. if y >= 10 and y <= 50:

d. if y >= 10 and y <= 50:

TRUTH TABLE for the "and" operator: true and false false and true false and false true and true

true and false == false false and true == false false and false == false true and true == true

TRUTH TABLE for the "or" operator: Match the expression with it's value (result). true or false false or true false or false true or true

true or false == true false or true == true false or false == false true or true == true


Set pelajaran terkait

Quiz #1 -Radiation Protection (Chapters 1 & 2)

View Set

Ch. 26 Management of Pts w Dysrhythmias & Conduction Problems

View Set

LT4: Evaluate Inverse Trig Sin/Cos/Tan -- Answer in Radians

View Set

Chemistry J117 Past Exam/Practice Exam Questions

View Set

Chapter 1: The Evolution of Psychology

View Set

Chapter 14: Socioemotional development in Middle adulthood

View Set

Organelles That Capture and Release Energy

View Set