0
0
Agentic AIml~10 mins

Branching and conditional logic in Agentic AI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to check if the input number is positive.

Agentic AI
if number [1] 0:
    print("Positive number")
Drag options to blanks, or click blank then click option'
A>
B!=
C==
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' will check for negative numbers.
Using '==' checks only if the number equals zero.
2fill in blank
medium

Complete the code to print 'Even' if the number is divisible by 2.

Agentic AI
if number [1] 2 == 0:
    print("Even")
Drag options to blanks, or click blank then click option'
A//
B%
C+
D**
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' or '**' operators will cause errors or wrong logic.
Using '//' gives the quotient, not the remainder.
3fill in blank
hard

Fix the error in the condition to check if age is between 18 and 30.

Agentic AI
if 18 [1] age [2] 30:
    print("Eligible")
Drag options to blanks, or click blank then click option'
A<
B>
C<=
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' instead of '<' reverses the logic.
Using '>=' or '<=' changes the range to include boundaries.
4fill in blank
hard

Fill both blanks to create a dictionary of words with length greater than 3.

Agentic AI
{word: len(word) for word in words if len(word) [1] 3 and word [2] 'test'}
Drag options to blanks, or click blank then click option'
A>
B==
C!=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' or '==' in the first blank changes the length condition.
Using '==' in the second blank includes 'test' instead of excluding it.
5fill in blank
hard

Fill all three blanks to filter a dictionary with keys starting with 'a' and values greater than 10.

Agentic AI
{k: v for k, v in data.items() if k[1]'a') and v [2] 10 and isinstance(v, [3])}
Drag options to blanks, or click blank then click option'
A.startswith(
B>
Cint
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '.startswith(' causes errors.
Using '==' instead of '>' changes the value condition.
Using wrong type instead of 'int' causes type check failure.