Complete the code to print a simple greeting from a virtual assistant.
print("Hello, I am your [1] assistant!")
The word virtual fits best to describe an assistant powered by AI.
Complete the code to check if a recommendation system suggests a movie based on user preference.
if user_preference == [1]: print("We recommend this movie!")
The user preference should be a string, so it needs quotes like "comedy".
Fix the error in the code that simulates a voice assistant responding to a command.
command = "play music" if command [1] "play music": print("Playing your favorite songs.")
= instead of == causes syntax errors.The comparison operator == checks if the command matches the string.
Fill both blanks to create a dictionary comprehension that maps app names to their AI feature status.
ai_features = {app[1]: status for app, status [2] apps.items() if status == True}== instead of in for iteration.The method .lower() converts app names to lowercase keys, and in is used to iterate over dictionary items.
Fill all three blanks to create a dictionary comprehension that filters AI assistants by language and converts names to uppercase.
filtered_assistants = [1]: assistant for assistant, language [2] assistants.items() if language [3] "English"}
== and =, or using wrong string methods.assistant.upper() converts names to uppercase, in iterates over items, and == checks language equality.