Basic Conditionals
Advanced Conditionals
Comparison Operators
Logical Operators
Boolean Expressions
100

What keyword is used to start conditional statement in Python?

What is 'if'?

100

How does the "if/elif" statement differ from multiple if statements?

In an "if/elif" structure only one condition will evaluate to TRUE and the remaining conditions below will be ignored, while for multiple if statements, Python will evaluate every one of them (most of the time wasting time resorse)

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 above if/elif conditions are all 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" and all associated 'elif' conditions are 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 18 or younger")


Fill in the blank with the appropriate keyword

"else"

300

What is the output?

print('10'>'5')

print('10'>5)

False

Error -> use this instead: print(int('10')>5)


NOTE: in the first line 10 and 5 are compared as Strings according to Unicode

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

What is the output?

print('abcd'>'abc')

print('ABCD'>'abc')


True

False

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 = True

result = not x or y and x

print(result)

The output will be "True

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

What is the output?

print('ABC'>'abc')

FALSE,  

in ASCII upper case letters come before the lower case, hence their ID is smaller.

NOTE: in Python, Strings are compared character -by-character left-to-right according to Unicode values

500

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

DO NOT USE IT!!!!

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"

M
e
n
u