The following exercises are designed to help you practice the skills you’ve learned in the Get Started with Python Programming learning path on Microsoft Learn. Each exercise is self-contained and can be completed independently, but they are best used in conjunction with the corresponding modules on Microsoft Learn.

Exercises


Create a personalized greeting

Level: 100 | Duration: 15 minutes

Write a Python program that uses print(), input(), and f-strings to display a personalized greeting message.


Calculate a student’s GPA

Level: 100 | Duration: 20 minutes

Write a Python program that stores student grades as variables, performs arithmetic to calculate a GPA, and accepts scores as user input using type conversion.


Create a personalized banner app

Level: 100 | Duration: 25 minutes

Set up a Python project in Visual Studio Code, install a package with pip, and use GitHub Copilot to build a banner app that greets the user.


Create a rock, paper, scissors game

Level: 100 | Duration: 30 minutes

Build a rock, paper, scissors game in Python that uses comparison operators, if/elif/else conditional logic, and logical operators to determine the winner.


Create a Guess the Number game

Level: 100 | Duration: 25 minutes

Write a Python program that uses a while loop, conditional logic, and break to run an interactive Guess the Number game.


Build a coffee shop order tracker

Level: 100 | Duration: 25 minutes

Write a Python program that uses a dictionary of menu items, a list to track a customer’s order, and loops to print a formatted receipt.


Build a to-do list

Level: 100 | Duration: 25 minutes

Write a Python program that saves and loads tasks from a text file so a to-do list persists between runs.


Create a calculator

Level: 100 | Duration: 25 minutes

Write a Python program that uses functions with parameters and return values to build a simple interactive calculator.


Refactor a sales report generator to code defensively

Level: 200 | Duration: 40 minutes

Improve a Python sales report program so that it is readable, documented, handles bad data, and is covered by unit tests.


Benchmark and optimize a sales report generator

Level: 200 | Duration: 30 minutes

Use timeit and cProfile to measure a slow sales report, find the function that causes the delay, and confirm that a better algorithm fixes it.


Write specifications for GitHub Copilot

Level: 200 | Duration: 30 minutes

Deconstruct a feature request, write an explicit specification, and define edge cases. Then use GitHub Copilot to generate the code and verify that it follows your specification.


Audit AI-generated code with GitHub Copilot

Level: 200 | Duration: 30 minutes

Find hallucinated functions, validation gaps, and unsafe logic in AI-generated Python code. Then fix the code and verify it with a checker script.


Note: While you can complete these exercises on their own, they’re designed to complement modules on Microsoft Learn; in which you’ll find a deeper dive into some of the underlying concepts on which these exercises are based.