EXERCISE TOPIC▼
- 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 EXERCISES▼
PYTHON EXERCISES▼
Python | Basic coding exercise | Create a simple program to add two numbers
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.
Software ==> | Python (28 exercises) |
Version ==> | Latest version |
Topic ==> | Basic coding (3 exercises) |
Level ==> | Average difficulty |
Subject ==> | Python training |
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.
Your task for this exercise is to write a program to add together two numbers typed in by a user. Here's what a typical output from the program might look like:

The hard part of this exercise is making sure that you're working with numbers when you need numbers, and text when you need text.
To being with, create a new program called Slack adder.py. Within this create two variables to equal the two inputs typed in by your user.
You'll need to use the int() function to convert the text typed in by your user into integers, otherwise you won't be able to subsequently add the two numbers together. You can assume that your user will be well-behaved and type in only numbers.
Create a third variable to hold the sum of your two numbers, then print out your results (this time you'll need to use the str() function to turn your numbers back into text, before using the + sign to concatenate the bits of text you need to form your message).
When your program is working to your satisfaction, save it and close it down!