Question

In: Computer Science

the previous one I saw it, I wonder how to do the last one. Read carefully...

the previous one I saw it, I wonder how to do the last one.

Read carefully
See the photo of the algorithm below after reading these instructions: write a program in Python 3 which uses a list. Your program will use a list to store the names and exam scores of students. The program starts by asking how many results will be entered. Then a loop will be used to enter the name and score for each student. As each name and score is entered it is appended to a list (which was initially empty). When the loop is finished (i.e. all scores are entered) the program ends by printing the list.

Make a copy of your Lab6A.py file to Lab6B.py. Amend the comments accordingly for these instructions. Send the list you created in Lab 6A to a function which returns a list of names of all above average students.

Solutions

Expert Solution

Python Program:

def main():
   """ Python Program that reads names and marks from students and adds to list """
   # Reading number of results
   numResults = int(input("Specify how many results will be entered? "))
   # List that holds names and scores
   names = []
   scores = []
  
   # Iterating and reading student data
   for i in range(numResults):
       # Reading names
       name = input(" Enter student name: ")
       score = int(input("Enter Score: "))
      
       # Adding to list
       names.append(name)
       scores.append(score)
      
   # Printing list
   print(names)
   print(scores)
  
   # Printing above average students
   print(" Above average students: ")
   print(aboveAvg(names, scores))
  

def aboveAvg(names, scores):
   """ Function that returns names of above average students """
   # Finding average
   avgScore = sum(scores)/len(scores)
  
   # List that holds result names
   resNames = []
  
   # Iterating over each score
   for i in range(0, len(scores)):
       # Comparing score
       if scores[i]>avgScore:
           # Adding to list
           resNames.append(names[i])

   # Returning result
   return resNames
  
# Calling main function
main()

______________________________________________________________________________________________

Sample Run:


Related Solutions

Your project MUST do exactly what I am asking for. Read very carefully. I will take...
Your project MUST do exactly what I am asking for. Read very carefully. I will take point off. Show the output that I ask for in the text file and upload the file. When I run your project, if it does not match the given out put you get Zero. In addition, any two project that copies from each other get zero credit and report to the SMC disciplinary department. Advanced Java Programming Polymorphism, Class Design, Inheritance Assignment: You are...
INPUT FILE INTO ARRAY. CHECKING FOR COMMAS AND SUCH. HOW TO DO? *IMPORTANT* PLEASE READ CAREFULLY....
INPUT FILE INTO ARRAY. CHECKING FOR COMMAS AND SUCH. HOW TO DO? *IMPORTANT* PLEASE READ CAREFULLY. WE HAVE TO DO WHAT THIS ASSIGNMENT DOES OR WE WILL MARKED OFF POINTS. IT DOES NOT HELP WHEN YOU CHANGE THE SKELETON TO YOU'RE PREFERENCE. THIS IS FOR A BASIC C++ LEVEL CLASS SO WE HAVE TO STICK TO BASIC C++ CODE. HOWEVER IT COULD BE WRONG IN TERMS OF WORKING CONDITIONS SO PLEASE HELP FIX THESE. *IMPORTANT* void readFile(Candidate candidates[]) – reads...
INPUT FILE INTO ARRAY. CHECKING FOR COMMAS AND SUCH. HOW TO DO? ****IMPORTANT**** PLEASE READ CAREFULLY...
INPUT FILE INTO ARRAY. CHECKING FOR COMMAS AND SUCH. HOW TO DO? ****IMPORTANT**** PLEASE READ CAREFULLY ****IMPORTANT**** ***GOALS*** HOW TO CHECK FOR COMMAS, TILL THE END OF FILE. IT WILL CHECK THE LINE FOR THE APPRORIATE FORMAT IN THE TEXT FILE. IF THERE IS MISSING A COMMA, IT WILL IGNORE, IF THERE IS A WHITE SPACE, IT WILL CORRECT AND READ LINE, IF IT IS MISSING 1 OF THE 3 INFORMATION, IT WILL IGNORE. Display candidates’ names using displayList() function...
I am posting this for the third time. PLEASE READ EVERYTHING CAREFULLY AND THEN ANSWER I...
I am posting this for the third time. PLEASE READ EVERYTHING CAREFULLY AND THEN ANSWER I am m designing a questionnaire for the topic: FACTORS INFLUENCING CONSUMER BUYING BEHAVIOR IN PURCHASE OF MILK IN ORGANIZED AND UNORGANIZED SECTOR. the study is basically to study the factors that influence consumer decisions in purchase of milk in organized and unorganized sector of milk. For this i need variables that influence purchase of milk in organized and unorganized sector. \ Note: I need...
I am posting this for the third time. PLEASE READ EVERYTHING CAREFULLY AND THEN ANSWER I...
I am posting this for the third time. PLEASE READ EVERYTHING CAREFULLY AND THEN ANSWER I am m designing a questionnaire for the topic: FACTORS INFLUENCING CONSUMER BUYING BEHAVIOR IN PURCHASE OF MILK IN ORGANIZED AND UNORGANIZED SECTOR. the study is basically to study the factors that influence consumer decisions in purchase of milk in organized and unorganized sector of milk. For this i need variables that influence purchase of milk in organized and unorganized sector. Note: I need just...
Read the questions carefully and do not look for a quick answer. There are none. Your...
Read the questions carefully and do not look for a quick answer. There are none. Your answers should reflect your ability to think about complexity using multiple disciplines to explore murky answers. Your answers must be typed, and it should be more than 4 citations. Please explain in 3-4 full paragraph and please add the site that you used. It should be more than 4 sources. 1)How will space exploration and travel be changed with the private sector playing a...
I need this in pseudocode: Similar to the previous assignment, you’re going to read in the...
I need this in pseudocode: Similar to the previous assignment, you’re going to read in the number of years the player played and the starting year of that player – followed by the statistics for those years. This time, however, you’re going to print out the years from worst to best in sorted order. Hint: this will require a second array to store years. If you can sort one array, can you sort both? Sample Output #1: Enter the number...
In a Servlet, how do you read HTML Form Data (data from the previous Web page)...
In a Servlet, how do you read HTML Form Data (data from the previous Web page) into the Servlet?
How do I do this: Write a program that can read a text file of numbers...
How do I do this: Write a program that can read a text file of numbers and calculate the mean and standard deviation of those numbers. Print the result in another text file. Put the result on the computer screen. EACH LINE OF THE PROGRAM MUST BE COMMENTED!
READ THE FOLLOWING CAREFULLY TO GET FULL VALUE FROM THE PRACTICE. IF NOT COMFORTABLE WITH CLASSES,I...
READ THE FOLLOWING CAREFULLY TO GET FULL VALUE FROM THE PRACTICE. IF NOT COMFORTABLE WITH CLASSES,I WOULD START WITH DEFINING THE CLASS WITH ONE constructor AND GO FROM THEREUse the following to calculate a GPA (the following is for calculation information only):A = 4.00 grade points per credit hourA- = 3.70 grade points per credit hourB+ = 3.33 grade points per credit hourB = 3.00 grade points per credit hourB- = 2.70 grade points per credit hourC+ = 2.30 grade...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT