In: Computer Science
write a python program that inputs 10 integer values from the keyboard and then displays their sum. use for loop
Code:
print("Enter 10 integers: ") #asking user to enter 10 integers
_sum=0 #declare and initalize _sum with 0
for i in range(0,10): #Iterate loop from 0 to 10
val = int(input("")) #take the input number from user
_sum=_sum+val #add number to sum
print("Sum of given 10 integers is {}".format(_sum)) #finally print the sum value
Code and Output Screenshots:
Note: In python indendation is very important so for perfect indendation please refer the attached screenshot.
Note: if you have any queries please post a comment before giving any review thanks a lot..always available to help you...