- Access exercises (91)
- C# exercises (79)
- Excel exercises (278)
- Power Apps exercises (13)
- Power Automate exercises (18)
- Power BI exercises (139)
- Power Platform exercises (157)
- Python exercises (28)
- Report Builder exercises (141)
- SQL exercises (198)
- SSAS exercises (51)
- SSIS exercises (46)
- SSRS exercises (99)
- VBA exercises (85)
- Visual Basic exercises (46)
Python | Functions exercise | Create a function to print out an underlined title
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
It's often nice to print titles out with underlining - like this, in fact:
The underlining for each title is the same width as its text.
Here's some code to produce the output shown above:
This code assumes the print_title function exists - read on!
Write the required print_title function to make your code work. As a reminder, here's the syntax of a function:
def function_name(argument_1: data_type, ..., argument_n: data_type) -> return_type:
# do things, but remember to ...
You can use the len function to count the number of characters in each title (call this N), and then print out "-" * N to print the space character N times.
Test that your program works by printing a few things (with titles, of course), then close it down.