Question

Write a for-loop that will loop the following salaries in the list s, sum the salaries,...

Write a for-loop that will loop the following salaries in the list s, sum the salaries, find the average salary, and print the value of the average salary.

#complete the code below with your solution

sum = 0 n = 0

s = [28000, 42500, 32600, 29700]

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#complete the code below with your solution
sum = 0
n = 0
s = [28000, 42500, 32600, 29700]
for n in s:
    sum += n
print(sum/len(s))

33200.0

Add a comment
Know the answer?
Add Answer to:
Write a for-loop that will loop the following salaries in the list s, sum the salaries,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in c++ language 1.Re-write the following for loop statement by using a while loop statement: int...

    in c++ language 1.Re-write the following for loop statement by using a while loop statement: int sum = 0; for(int i=0;i<=1000;i++){                 sum+=i; } 1 (b). Following is the main () function of a program. The program asks a user to enter 150 integers and print the largest integer user entered. int main() {    int score, highest;             //missing portion of the program             return 0;    } 1(c). Find the missing portion of the following code, so the...

  • MAT 110 Statistics Lab 1. The following is a list of starting salaries for an entry...

    MAT 110 Statistics Lab 1. The following is a list of starting salaries for an entry level office administrator in one rural town (Apple City) in the Midwest. Use this information to answer the questions below. 28800 29000 27900 30600 27100 29700 30200 28600 29200 30400 28200 27100 30700 30700 29600 28800 28200 27400 27800 30600 29900 28000 27600 27100 30200 27100 29400 26800 27800 30300 a. What is the mean salary? Mean= 864800 ÷ 30 = 28,826.7 b. What...

  • Step 4: Write a Sum Function Since we can write, compile and run simple c files,...

    Step 4: Write a Sum Function Since we can write, compile and run simple c files, lets add a bit to make a program that will sum an entire array of integers. To do this we are going to simply overwrite the main.c file to include the new function. The sum function below is not complete and must be finished before the program will execute properly. %%file main.c #include <stdio.h> int sum(int array[], int arrayLength) {     int i =...

  • Exercise 1 - Create a List to Sum Values Write a python script that sums the...

    Exercise 1 - Create a List to Sum Values Write a python script that sums the values in a list called add_list that contains the following values: (10, 2, -4, 8). Make sure you include a for loop when iterating through the list to sum the values. Take screenshots of the code and output. Exercise 2 – Create a Dictionary Write a python script that prints a dictionary where the key numbers are 1, 2, 3, 4, and 5 and...

  • Write a for loop that assigns summed Value with the sum of all odd values from...

    Write a for loop that assigns summed Value with the sum of all odd values from 1 to user Num. Assume userNum is always greater than or equal to 1. Ex: If userNum is 5, then summed Value is 9 (i.e. 1+3+5 =9). Function Save C Reset MATLAB Documentation 1 function summedValue - Oddssum(userNum) summedValue = 0; % Write a for loop that assigns summedValue with the % sum of all odd values from 1 to user Num 7 end...

  • (Write or type in answers, except for problem #15, which should be entered as a small...

    (Write or type in answers, except for problem #15, which should be entered as a small program, tested, and submitted in Repl.it) 1. Write a Python statement to define a list named temps using the following elements, in order: 95, 100, 77, 54, 103, 82 2. a) What is the length of the list temps? b) What Python function can be used to obtain the length of the list? Use it in a statement to obtain the length of temps...

  • Write two clauses in PROLOG that determines if there are three values in a list that sum up to a ...

    Write two clauses in PROLOG that determines if there are three values in a list that sum up to a value of N. The output should be a single true if there exist three values whose sum is N or a single false if there are not. If there are multiple values whose sum is N then the program should only print true once.

  • The loop below stores the values 1 to 5 in myList: for (int i = 0;...

    The loop below stores the values 1 to 5 in myList: for (int i = 0; i < 5; i ++) { myList [ i ] = i + 1; //store values using a loop } The loop below prints the values from first to last in myList: for (int i = 0; i < myList.length; i++) { System.out.print(myList [ i ] + " "); } Use the examples on the slides to complete the lab below. Please submit the...

  • C program. Using do-while loop for this question. Question: write a program to calculate the average...

    C program. Using do-while loop for this question. Question: write a program to calculate the average of first n numbers. output: Enter the value of n : 18 The sum of first 18 numbers =171 The average of first 18 numbers = 9.00 my code couldn't give me the right avg and sum. Please help. #include<stdio.h> int main() {     int num;     int count =0;     int sum=0;     float avg;      printf("Enter the value of n: ");    ...

  • Write a PHP program using a ''FOR loop' to compute and print the employee's salary for...

    Write a PHP program using a ''FOR loop' to compute and print the employee's salary for some number of years with a percent increase each year. Your submit button should re-call this page and use PHP to create a table of salaries for each year starting at 1 up to the value of the years variable. So if 'years' is equal to 5, there should be 5 rows in your table. For each year, the salary increases by X%. Make...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT