CODE HS

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What is the proper operator for "not equals" in Python?

!=

Which of the following Boolean expressions is equivalent to the expression (a OR b) AND NOT (c OR d)

(a OR b) AND (NOT c) AND (NOT d), Nice work! For (a OR b) AND NOT (c OR d) to be true, a or b must be true AND both c and d must be false (NOT false becomes true).

In the following code, what will be the last number to print to the screen before the program finishes? for i in range(10): if i % 2 == 0: print(i) else: print(2 * i)

18

How many times will the following code print "hello"? for i in range(0, 8, 2): print("hello")

4

How many times will the following code print "hello"? for i in range(3, 8): print("hello")

5

How many times will the following program print "hello"? for i in range(5): print("hello")

5

What is the proper way to compare if two values are equal in a boolean expression in Python?

==

In the following code block, assume that the variables rainy and tooCold are boolean. IF (NOT (rainy OR tooCold)) { DISPLAY("It's a good beach day") } Which of the following are equivalent to the above code block? IF (( NOT rainy) OR (NOT tooCold))

IF (( NOT rainy) AND (NOT tooCold)) { DISPLAY("It's a good beach day") }

Determine whether the following expression would evaluate to true or false. 7 = 6 OR 8 ≥ 4

True, 7 = 6 OR 8 ≥ 4 false OR true, true

We've written a function animate that moves a ball across the screen like this: def animate(event): ball.move(5, 5) How can we set up animate to be called every time a key on the keyboard is pressed down?

add_key_down_handler(animate)

What symbol represents the and operator in Python?

and

Which of the following programs will not print anything?

if False: print("hi") (does not state what x equals and if true or false print ...)

Assume you are writing a program, and you have a boolean variable called b, defined like so: b = True Pick the correct if statement to follow the code above. The if statement should be correct Python, and the body of the if statement should only run if b is True.

if b: print("b is True!") (make sure to indent and put the if b at the top)

What symbol represents the or operator in Python?

or

After the following code runs, what is the value of is_weekend? is_saturday = True is_sunday = False is_weekend = is_saturday or is_sunday

true

Which of the following is not a valid value for a boolean?

yes


Kaugnay na mga set ng pag-aaral

HDE 12: Chpt. 1 - The Study of Human Sexuality

View Set

Nutrition: Lipids: Triglycerides, Phospholipids, and Sterols

View Set

Perfect Squares & Square Roots to 26

View Set

Basic Leagal concepts - Tort Law

View Set

World History 3201Public Exam Review

View Set

Cattle Kingdom & Farming in the West

View Set

Chapter 6 Analyzing Information to Determine Credibility

View Set

ENG T 231 - Foundations of Global Leadership

View Set