Does anyone know the solution to this problem?
Write a program to take two integers as input and output their sum. Sample Input: 2 8 Sample Output: 10
If you have tried, show us your code.
Please read the task description carefully: You need to take 2 integers as ***INPUT***. DO NOT HARD CODE THE VALUES. Get input()
num1 = 2 num2 = 8 print(num1 + num2)
Every one know who have willing to learn and started code .. Ok. What about you?? Are you tried anything?
Yes i did try it several times but can never come up with a solution.
Thanks for your advice
You can take input by function : input() #it accept input of string form. If you want integer type, then you need to convert to int as int( input() ). Hope it helps..
Yes it helped
The solution you gave above is "hard-coded", meaning that to carry out the same function with different input you have to modify your code. The assignment was to write a flexible program to take in any two integers and print out their sum.
TENNYSON LEBBIE Please do not post in random threads. Create your own thread when you have a question. Go to Learn section, pick a course and start learning. The lesson unlock when you have completed all previous lessons.
Share your try here.. Better to Save code in playground and share link here ..
Yes, it's better to start with something like: num1 = int( input() ) which prompts the user for the first input value and stores it as an integer in variable "num1". Do the same to get the second input integer stored, and then print the sum as you have above.
All the lesson are lock