Friday, September 11, 2020

Python program to accept 3 integers separated by commas and display their sum

Python program to accept 3 integers separated by commas and display their sum


 

 

 

Python program to accept 3 integers separated by

                 commas and display their sum

                 --------------------------------------------------------------

 

Code:

var1 , var2 , var3 = [int(x) for x in input("Enter three numbers:").split(',')]

print('Sum = ', var1+var2+var3)

 

output:

Enter three numbers: 10,20,30

Sum = 60

 

here , all the three numbers are being received in a

single line within a list but separated from each other

by commas in-between them . Split function () is used

to isolate the numbers from each other and store them

within each variable .

 

 


No comments:

Post a Comment

Durga Puja in Odisha

 Durga Puja in Odisha