Question

In: Computer Science

write a python program that inputs 10 integer values from the keyboard and then displays their...

write a python program that inputs 10 integer values from the keyboard and then displays their sum. use for loop

Solutions

Expert Solution

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...


Related Solutions

In Python, write a program to get a positive integer n from keyboard first (your program...
In Python, write a program to get a positive integer n from keyboard first (your program must be able to check the validation of n being positive), and then get n integers from keyboard and store these n integers in a list. Do some processing, and print out average of the elements in the list at end of your program. For example, suppose user enters 3 first (n = 3), which means we get another three integers from the user....
Using Python. Write a program that reads a sequence (unknown number of inputs) of integer inputs...
Using Python. Write a program that reads a sequence (unknown number of inputs) of integer inputs and prints the number of even and odd inputs in the sequence. please explain. Thanks
C program, please Write a program that reads a sequence of 10 integer inputs and prints...
C program, please Write a program that reads a sequence of 10 integer inputs and prints the smallest and largest of the inputs and the number of even and odd inputs. for a beginner please, you could use a while loop,if-else,
Write a C++ program that accepts a positive integer number from the keyboard . The purpose...
Write a C++ program that accepts a positive integer number from the keyboard . The purpose of the program is to find and the display all the square pair numbers between 1 and that number. The user should be able to repeat the process until he/she enters n or N in order to terminate the process and the program. Square numbers are certain pairs of numbers when added together gives a square number and when subtracted also gives a square...
Program must be in Python Write a program in Python whose inputs are three integers, and...
Program must be in Python Write a program in Python whose inputs are three integers, and whose output is the smallest of the three values. Input is 7 15 3
Write a Java program which reads a positive integer from the command line, then displays the...
Write a Java program which reads a positive integer from the command line, then displays the sum of all even values up to and including the value provided, followed by the sum of all odd values up to and including the value provided. validate that the command line argument is an integer greater than 0 to validate the type, you can use Integer.parseInt() with a try/catch for NumberFormatException use one or more for loops to perform the even and odd...
Write a C program to Declare an integer array of size 10 with values initialized as...
Write a C program to Declare an integer array of size 10 with values initialized as follows. int intArray[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; Compute each item of a new array of same size derived from the above array by: adding first item (intArray[0]) of the array with 3rd, 2nd with 4th, 3rd with 5th and so on. For the last-but-one item intArray[8], add it with first item and for the last item (intArray[9])...
Write a C++ program to read in a list of 10 integers from the keyboard. Place...
Write a C++ program to read in a list of 10 integers from the keyboard. Place the even numbers into an array called even, the odd numbers into an array called odd, and the negative numbers into an array called negative. Keep track of the number of values read into each array. Print all three arrays after all the numbers have been read. Print only the valid elements (elements that have been assigned a value). a. Use main( ) as...
Write a python program. Grades are values between zero and 10 (both zero and 10 included),...
Write a python program. Grades are values between zero and 10 (both zero and 10 included), and are always rounded to the nearest half point. To translate grades to the American style, 8.5 to 10 become an “A,” 7.5 and 8 become a “B,” 6.5 and 7 become a “C,” 5.5 and 6 become a “D,” and other grades become an “F.” Implement this translation, whereby you ask the user for a grade, and then give the American translation. If...
IN PYTHON Write a program that takes in a positive integer as input, and outputs a...
IN PYTHON Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is: As long as x is greater than 0 Output x % 2 (remainder is either 0 or 1) x = x // 2 Note: The above algorithm outputs the 0's and 1's in reverse order. You will need to write a second function to reverse the string....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT