This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Which example shows incorrect information in AI-generated code?
Code that uses documented functions with the correct parameters
Code that looks correct but uses nonexistent functions or makes false assumptions
Code that raises a documented exception when it receives invalid input
What should you always check when reviewing AI-generated code?
Only that it follows style conventions
Whether functions and modules actually exist, if the logic is correct, if errors are handled, and if the code has security risks
Only that the code runs without errors
How can you identify inefficiencies in AI-generated code?
By reading the variable names
By checking for unnecessary loops, redundant operations, or inefficient algorithms
By counting the total number of lines
AI-generated code builds a SQL query from user input. Which change makes the query safe?
Escape quote characters with str.replace() before you insert the input into the f-string
Pass the input as a parameter, such as cursor.execute("SELECT * FROM users WHERE name = ?", (name,))
Convert the input to uppercase before you run the query
You must answer all questions before checking your work.
Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?