0
0
Agentic AIml~10 mins

State graphs and transitions 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 add a state transition from 'start' to 'processing'.

Agentic AI
state_graph = {}
state_graph['start'] = [1]
Drag options to blanks, or click blank then click option'
A['processing']
B'processing'
Cprocessing
D('processing')
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string instead of a list for transitions.
Forgetting to use quotes around 'processing'.
2fill in blank
medium

Complete the code to check if 'end' is a valid next state from 'processing'.

Agentic AI
if [1] in state_graph['processing']:
    print('Can move to end')
Drag options to blanks, or click blank then click option'
A"processing"
Bend
C'end'
D'processing'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name without quotes.
Checking for the wrong state name.
3fill in blank
hard

Fix the error in the code to correctly add a transition from 'processing' to 'end'.

Agentic AI
state_graph['processing'] = [1]
Drag options to blanks, or click blank then click option'
A'end'
B('end')
Cend
D['end']
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning a string instead of a list.
Using parentheses which create a string, not a tuple.
4fill in blank
hard

Fill both blanks to create a state graph with transitions from 'start' to 'processing' and from 'processing' to 'end'.

Agentic AI
state_graph = {
    'start': [1],
    'processing': [2]
}
Drag options to blanks, or click blank then click option'
A['processing']
B'end'
C['end']
D'processing'
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings instead of lists for transitions.
Mixing up the order of states.
5fill in blank
hard

Fill all three blanks to define a function that returns the next states from a given state in the graph.

Agentic AI
def get_next_states(state_graph, state):
    return state_graph.get([1], [2])

next_states = get_next_states(state_graph, [3])
Drag options to blanks, or click blank then click option'
Astate
B[]
C'processing'
D'start'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string literal instead of the variable 'state'.
Not providing a default value for missing keys.
Passing the wrong state name when calling the function.