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.
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!