Skip to content

Commit de04476

Browse files
committed
implemented adding two numbers in python program
1 parent 51053cb commit de04476

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

SimpleAddition/Sum_2_numbers.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
1+
# first lets get 2 numbers to add
2+
print "enter 2 number to add"
13

4+
# getting the first number
5+
number1 = raw_input("Ok enter the first number ")
6+
7+
# and now the second number
8+
number2 = raw_input("and now the second number ")
9+
10+
# finally calculating the addidition of the numbers
11+
# sum = number1 + number2
12+
# seems to be right
13+
# but as the inputs are taken as string we need to type cast them
14+
# that is convert number1 and number2 to integer from string
15+
# so lets do that
16+
17+
number1 = int(number1)
18+
number2 = int(number2)
19+
# and now lets calculate the sum
20+
sum = number1 + number2
21+
22+
# and now lets print the numbers
23+
print "the addition of the 2 numbers is "
24+
print sum

0 commit comments

Comments
 (0)