Search Header Logo

2. If Elif and Else

Authored by Jeremy Talbot

others

Used 3+ times

2. If Elif and Else
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

OPEN ENDED QUESTION

1 min • 1 pt

Media Image

Can you identify the issue present in this snippet of code?

Evaluate responses using AI:

OFF

Answer explanation

Because there is only 1 equals sign for the if statement.

2.

OPEN ENDED QUESTION

1 min • Ungraded

Media Image

What would be the output of the code above?

Evaluate responses using AI:

OFF

Answer explanation

Sorry you cannot afford to buy apples

3.

OPEN ENDED QUESTION

1 min • Ungraded

Media Image

What is the problem with this code?

Evaluate responses using AI:

OFF

Answer explanation

You’re checking to see if a variable called capital (which doesn’t exist) is equal to the word “Tokyo”, when it needs to be comparing it to the variable answer (which exists)

4.

OPEN ENDED QUESTION

1 min • Ungraded

Media Image

What will the output be when you have less then $5?

Evaluate responses using AI:

OFF

Answer explanation

Sorry you do not have enough money to make a purchase


5.

OPEN ENDED QUESTION

1 min • Ungraded

Media Image

Fill in the blank line

Evaluate responses using AI:

OFF

Answer explanation

elif arrive == “yes”:


6.

OPEN ENDED QUESTION

1 min • Ungraded

Media Image

Referencing the code, which print function will execute?

Evaluate responses using AI:

OFF

Answer explanation

Great Work


7.

OPEN ENDED QUESTION

1 min • Ungraded

Media Image

A female soccer team is looking for female players older than 12 years of age. Fill in the blank to abide by these 2 conditions.

Evaluate responses using AI:

OFF

Answer explanation

age = int(input(“How old are you”))

sex = input(“Are you female or male? Type ‘m’ for female or ‘f’ for female: “)

if age > 12 and sex == “f”:

print(“You are eligible for the team”)

else:

print(“Sorry you are not eligible for the team”)


OR

age = int(input(“How old are you”))

sex = input(“Are you female or male? Type ‘m’ for female or ‘f’ for female: “)

if sex == “f” and age > 12:

print(“You are eligible for the team”)

else:

print(“Sorry you are not eligible for the team”)


Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?