Basic Conditionals
Advanced Conditionals
Comparison Operators
Logical Operators
Boolean Expressions
100

What keyword is used to start an "if" statement in Python?

What is 'if'?

100

How does the "elif" statement differ from the statement "else"?

"elif" allows for multiple condition checks if an "if" statement is false, unlike "else". 

100

What is the comparison operator in Python used to check if two values are equal?

"=="

100

What is the purpose of the "and" operator and how does it work?

The "and" operator is used to combine two conditions and only returns "True" if both conditions are "True"

100

What are boolean expressions in Python, and what are the two possible values a boolean expression can have?

Boolean expressions are expressions that can either be "True" or "False"

200

What is the purpose of the elif statement in an if block, and how is it used?

The elif statement is used to check for additional conditionals within an if block when the initial if condition is false. It can be used as:

if condition1:

    print("True")

elif condition2:

    print("False")


200

What is the purpose of logical operators in Python conditionals, and how are they used to combine multiple conditions?

Logical operators like "and", "or", and "not" are used to combine multiple conditions in a single "if" statement. "And" requires both conditions to be True, "or" requires at least one condition to be True, and "not" negates a condition. 

200

Which comparison operator is used to check if one value is not equal to another?

"!="

200

What is the logical operators in Python used to check if at least one of two conditions is "True", and how is it represented?

The operator is "or", and returns "True" if at least one of the conditions is "True"

200

How are comparison operators used to create boolean expressions in Python? Provide an example.

Comparison operators, such as ==, !=, <, >, <=, and >=, are used to compare values and create boolean expressions. For example, x == y checks if x is equal to y.


300

What is the purpose of the "else" statement in Python and how is it used?

Similar to the elif statement, the "else" statement is used to provide an alternative action when the "if" condition is false. It is used as:


If condition1:

    print("true")

else:

    print("false")

300

my_age = int(input("Enter your age"))

if my_age > 17:

    print("You are older than 18")

____:

    print("You are younger than 18")


Fill in the blank with the appropriate keyword

"else"

300

How is the greater-than operator represented, and what is it purpose?

The greater-than operator is ">" and it is used to check if the value on the left is greater than the value on the right.

300

How is the "not' operator used in python, and give an example how it can be used?

The "not" operator is used to negate a condition. It returns "True" if the condition is "False". For example:

my_age = 20

if not my_age > 18:

    print("False")

else:

    print("True")

300

Explain the purpose of logical operators in boolean expressions and provide an example of using logical operators to combine conditions.

Logical operators (and, or, and not) are used to combine and manipulate boolean values. For example, x and y is True, only if both x and y are True.

400

What are "nested conditionals" in Python, and how are they structured?

Nested conditionals are "if" statements within other "if" statements. They are structured by indenting inner "if" statements, like so:

if condition1:

    if condition2:

        print("true")

    print("false")

400

x = 7 

y = 5 

if x > 5 and y <= 5:    

    print("A") 

else:    

    print("B")

The output will be A

400

The comparison operator _____ is used to check if a value is less than or equal to another value.

"<="

400

Given the following code, what will the output be?

x = True

y = False

result = x and y 

print(result)

The output will be "False"

400

Given the following code, what will be the output?

x = True

y = False

result = not x or y

print(result)

The output will be "False"

500

What is the difference between "==" and "is" when comparing objects in Python, and why is it important to understand this distinction?

"==" checks to see if two objects have the same values, while "is" checks if two objects are the same object in memory. This distinction is crucial because "==" compares values, while "is" compares identity. 

500

x = 5 

y = 8 

if x >= 5 or y < 7:    

    print("A") 

else:    

    print("B")

The output will be "A"

500

In Python, the _____ operator is used to determine if two values are both true.

"And"

500

What is the purpose of the "in" operator, and how does it work?

The "in" operator checks if a value is present in a sequence, and returns true if the value is present in the sequence.

For example: 

list = ["apples", "bananas", "oranges"]

if "apples" in list:

    print("True")

else:

    print("False")

500
Given the following code, what will be the output of the expression?


x = 5

y = 10

result = x > 3 and y < 15

print(result)

The output will be "True"