Unit 3 and 4 Review

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

Which of the following Python programs will not run?

x = 4 y = "hi" print x + y

Which of the following is not a comparison operator?

?

Which of the following is NOT a valid type of comment in Python?

%% This is a comment

What does the following Python program print? x = 9 + 6 / 3 * 2 - 1 print x

12

How many possible values are there for a boolean variable?

2

What does the following Python code display? print "Hello" print "World"

Hello World

Which of the following is not a logical operator in Python?

because

Which of the following Python programs will not print anything?

if False: print "hi"

Which Python code segment will display "Hello, world!" on the screen?

print "Hello, world!"

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!"

What does the following Python program print? x = "I am" y = 6 z = "feet tall" print x print y print z

I am 6 feet tall

Which of the following best describes the main purpose of comments?

Comments describe your program so other people can read it more easily.

Suppose you run the following Python program: x = input("Enter some text: ") print x While the program is running, after the prompt has been printed, the user types the following and presses Enter: Delaware ratified the U.S. Constitution in 1787. What does the program print?

Delaware ratified the U.S. Constitution in 1787.

Which of the following questions could be best answered by a boolean value?

Do you have any pets?

What does this Python expression evaluate to? 100 != 100

False

Which of the following evaluates to the variable x rounded to two decimal places?

round(x, 2)

What is the type of the variable x in the following Python program? x = input("Enter something: ")

string

What type is the following variable? x = "Hi there"

string variable


Kaugnay na mga set ng pag-aaral

Chapter 1 Mental health and Mental Illness

View Set