Comp Sci Unit 2 Quiz

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What does the following program print? a = "hi" b = 4 c = a * b print type(c)

<type 'str'>

Which of the following operations will output a value of 5?

11/2

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

12

What is the final result of the expression 4 + 5 * 3?

19

What is the final result of the expression 2**3?

8

What is the final result of the expression 7 / 3 + 6?

8

What is the difference between a binary operator and a unary operator?

A binary operator needs two things, while a unary operator only needs one.

In what order should these statements be executed in order to get input from the user and print out the result? A) response = input("Do you like cheese? ") B) print "You have chosen " + confirm C) print "You responded " + response D) confirm = input("Are you sure? ")

A, C, D, B

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 statements is true about print statements? I. In order to print a string literal, the string must be enclosed in quotes. II. Each print statement will be printed on its own line. III. Print statements will not let you print strings and numbers in the same statement. IV. Print statements are how you display text on the screen.

I, II, IV

On which line of code will Python error? weight = input("How much do you weigh? ") oz_water = weight / 2 print "You should drink " + str(oz_water) print "ounces of water every day if you weigh " + weight

Line 2

What kind of data does a float variable contain?

Numbers that can have decimal components

Suppose you have a variable defined a = "4". What is the variable type of a?

str

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


Ensembles d'études connexes

Multiplication Facts 1-10 (no repeating answers for quizlet live)

View Set

Ch. 37- Transportation Operations

View Set

Chap. 16:outcome identification and planning- PrepU

View Set

Functional Ability Comprehension Check

View Set

Chapter 61 - Assessment of the Endocrine System

View Set

Mastering for exam 3 brinninstool

View Set

Ch 9-10, 12 Check Your Basic Knowledge

View Set

Clinical Nutrition: Nutritionism

View Set