Exercise 2
Write a program in Python that asks the user to enter two numbers 'a' and 'b' and display their sum: 'a + b'
Solution
1 2 3 4 5 6 7 8 9 |
# coding: utf-8 # ask the user to enter the values of a and b a = input("Type the value of number a: ") b = input("Type the value of number b: ") # Convert strings to integer a = int(a) b = int(b) s = a+b print("The sum of a and b is a + b = ", s) |
Younes Derfoufi
CRMEF OUJDA
1 thought on “Solution Exercise 2: python program that displays the sum of two numbers”