conditionals quiz

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

what will the output of this program be? number = 5 greater_than_zero = number > 0 if greater_than_zero: if number > 5: print(number)

nothing will print

what does this program print? favorite_color = "blue" if favorite_color != "blue": if favorite_color != "red": print("Must be yellow") elif favorite_color == "blue": if favorite_color != "yellow": print("Must be blue") elif favorite_color == "blue": if favorite_color != "yellow": print("I like purple") else: if favorite_color == "blue": print("Blue is the best")

Must be blue

why should you round when you compare two numbers that have a type float?

Sometimes numbers can be rounded in unexpected ways based on how Python computes them. Therefore, it is best to use round in order to make sure both numbers are rounded the same way.

What will the following program print when run? above_16 = True has_permit = True passed_test = False if above_16 and has_permit and passed_test: print("Issue Driver's License") elif above_16 or has_permit or passed_test: print("Almost eligible for Driver's License") else: print("No requirements met.")

almost eligible for drivers license

what will print to the screen when the following program is run? number = 5 less_than_zero = number < 0 print(type(less_than_zero))

<type 'bool'>

what will print to the screen when the following program is run? number = 5 greater_than_zero = number > 0 print(type(number))

<type 'int'>

What will be the output of this program? number = 5 less_than_zero = number < 0 if less_than_zero: print(number) number = number-10 less_than_zero = number < 0 if less_than_zero: print(number)

-5

What will the following program print when run? number_one = 5 number_two = 10 if number_one == 5: print(1) elif number_one > 5: print(2) elif number_two < 5: print(3) elif number_one < number_two: print(4) elif number_one != number_two: print(5) else: print(6)

1

What will the following program print when run? number_one = 5 number_two = 10 if number_one == 5: print(1) if number_one > 5: print(2) if number_two < 5: print(3) if number_one < number_two: print(4) if number_one != number_two: print(5)

1 4 5

what will the output of this program be? number = 5 greater_than_zero = number > 0 if greater_than_zero: print(number)

5

What will be the output of this program? number = 5 greater_than_zero = number > 0 less_than_zero = number < 0 if greater_than_zero: print(number) if less_than_zero: print(number + 1) if greater_than_zero and less_than_zero: print(number + 2) if greater_than_zero or less_than_zero: print(number + 3)

5 8

What does this program print? favorite_color = "blue" if favorite_color != "green": print("But green is the color of grass!") if favorite_color == "red": print("I like red, too!") if favorite_color == "blue": print("Blue is the best") if favorite_color != "yellow": print("But yellow is the color of school buses!")

But green is the color of grass! Blue is the best But yellow is the color of school buses!

how would you round the number held in the variable pi to 3.14?

round (pi,2)

What does this program print? height = 65 gender = "female" if height < 62 or (height < 69 and gender == "male"): print("You are below average height") elif height > 69 or (height > 62 and gender == "female"): print("You are above average height") else: print("You are average height")

you are above average height

What does this program print? height = 65 gender = "female" if height < 62: print("You are below average height") elif height > 69: print("You are above average height") else: print("You are average height")

you are average height


Kaugnay na mga set ng pag-aaral

Chapter 3 - Legal Concepts of the Insurance Contract

View Set

"flowers for Algernon" questions review

View Set

Chapter 9.3.7 Practice Questions

View Set

Pituitary, hypothalamus and pineal gland

View Set