Intro to Coding - Use Conditional Statements

Ace your homework & exams now with Quizwiz!

Complete the sentence below. A boolean-operator compares two values in order to return a value of True or False is the logical representation of a conditional statement describes the requirements that must be evaluated as True or False combines several comparisons logically into one expression

1. compares two values in order to return a value of True or False

Which of the following is true about If statements? If the condition is not a boolean expression, the program returns 0. If the condition evaluates as False, then the block is skipped. In Python, an If statement begins with "If", followed by the block, and ends with the condition. If the block isn't indented, Python can still interpret it properly.

2. If the condition evaluates as False, then the block is skipped.

Which of these symbols is a boolean operator? < > ++ != #

3. !=

Conditional snakes assignment code:

snake_input = int(input("How many snakes are there? >")) if snake_input == 0: print("You don't see any snakes. What a relief!") elif snake_input == 1: print(f"There is only {snake_input} snake. That's not so bad.") elif snake_input > 1: print(f"You see {snake_input} snakes! RUN!") else: print("There cannot be negative snakes.")


Related study sets

A Raisin in the Sun Act 2-3 Test (Questions & Quotes)

View Set

nervous system test - let us die

View Set

Fundamentals Term 4 Laboratory tests

View Set