Smart Inline Completions: Use Cases, Examples, and Exercises
33%
Predict the Output
Predicting the output of a code snippet is another interesting use case of Copilot. You can add a comment at the end of the code snippet and ask Copilot to generate the output for you.
Let's assume we have a function that generates random points in a 2D space and stores them in a list called random_points.
import random
random_points = []
for i in range(10):
random_points.append((random.randint(0, 100), random.randint(0, 100)))
print(random_points)
Add a new line at the end of your code followed by a comment that describes what you want to see. This can be as simple as output: or result:.
# output: <-- [wait for the suggestion]
This is the completion that Copilot might suggest:
# output:
[(12, 45), (67, 89), (34, 56), (78, 90), (23, 45), (56, 78), (12, 34), (56, 78),Building with GitHub Copilot
From Autocomplete to Autonomous AgentsEnroll now to unlock all content and receive all future updates for free.
