Question

In Python In this programming assignment, you will do multiple programming exercises, and eventually develop a...

In Python

In this programming assignment, you will do multiple programming exercises, and eventually develop a Python application that can calculate student course grades.

  1. (6 points) Write a program called p2-1.py to: (1) create a list and add integer numbers from 1 to 100 to the list; (2) calculate the average value of all numbers in the list; and (3) print the result (screenshots).

  1. (8 points) Write a program called p2-2.py to: (1) allow a user to define how many integer numbers to input; (2) allow the user to interactively input those numbers; (3) calculate the average value of all numbers in the list; and (4) test your program with 5 integers as the user input and print the result (screenshots).
  1. (10 points) Write a program called p2-3.py to: (1) create a dictionary to store the following student records, in which a “Student Name” is the key and the corresponding “Test Grades” is the value; (2) calculate the average of test grades for each student and store the results to the second dictionary; and (3) find the student with the highest average score; and (4) print the result (screenshots).

Student Records Table:

Student Name

Test Grades

Alice

80, 90, 70, 100, 60

Bob

70, 75, 88, 77, 82

Cindy

60, 70, 90, 80, 80

Don

66, 76, 76, 69, 81

Ellen

85, 88, 78, 82, 68

  1. (11 points) Write a program called p2-py to extend p2-3.py. You should first make a copy of p2-3.py and then rename it as p2-4.py. In this program, according to the grading policy, the average of the five test grades (from the second dictionary in p2-3.py) is used as the final course grade for each student. This program is to: (1) covert the numerical course grade of each student to a letter grade based on the following grading scale; (2) store the result to the third dictionary; and (3) print the result for each student (screenshots).

Grading Scale:

A 90% - 100%

B 80% - 89%

C 70% - 79%

D 60% - 69%

F 0% - 59%

0 0
Add a comment Improve this question Transcribed image text
Answer #1

program 1:

import random
list1=[random.randint(1,100) for i in range(100)]

print ('average of 100 random no in list: {}'.format(sum(list1)/len(list1)))

program 2:

n=int(input('how many integer numbers you to input: '))
list1=[]
i=1
while n:
   list1.append(int(input('enter element no {}: '.format(i))))
   n-=1
   i+=1
print('average of {} integers is: {}'.format(len(list1),sum(list1)/len(list1)))

program3:

dict_stu_marks={'Alice':[80,90,70,100,60],"bob":[70, 75, 88, 77, 82],"cindy":[60, 70, 90, 80, 80],"Don":[66, 76, 76, 69, 81],"Ellen":[85, 88, 78, 82, 68]}

dict_stu_avg={}


max_avg=sum(dict_stu_marks['Alice'])/len(dict_stu_marks['Alice'])
maxkey='Alice'

for i in dict_stu_marks.keys():
   AVG=sum(dict_stu_marks[i])/len(dict_stu_marks[i])
   dict_stu_avg[i]=AVG
   if AVG>max_avg:
       max_avg=AVG
       maxkey=i

print('{} is having max average in list. Average: {}'.format(maxkey,max_avg))

program 4:

dict_stu_marks={'Alice':[80,90,70,100,60],"bob":[70, 75, 88, 77, 82],"cindy":[60, 70, 90, 80, 80],"Don":[66, 76, 76, 69, 81],"Ellen":[85, 88, 78, 82, 68]}

dict_stu_avg={}


max_avg=sum(dict_stu_marks['Alice'])/len(dict_stu_marks['Alice'])
maxkey='Alice'

for i in dict_stu_marks.keys():
   AVG=sum(dict_stu_marks[i])/len(dict_stu_marks[i])
   dict_stu_avg[i]=AVG
  

courseresult={}

for i in dict_stu_avg.keys():
   if dict_stu_avg[i]<=100 and dict_stu_avg[i]>=90:
       courseresult[i]='A'
   elif dict_stu_avg[i]<=89 and dict_stu_avg[i]>=80:
       courseresult[i]='B'
   elif dict_stu_avg[i]<=79 and dict_stu_avg[i]>=70:
       courseresult[i]='C'
   elif dict_stu_avg[i]<=69 and dict_stu_avg[i]>=60:
       courseresult[i]='D'
   elif dict_stu_avg[i]<=59 and dict_stu_avg[i]>=0:
       courseresult[i]='F'
   else:
       print('Invalid value')
      
for i in courseresult.keys():
   print('{} has grade : {}'.format(i,courseresult[i]))
      

Add a comment
Know the answer?
Add Answer to:
In Python In this programming assignment, you will do multiple programming exercises, and eventually develop a...
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 this assignment you are asked to write a python program to maintain the Student enrollment...

    In this assignment you are asked to write a python program to maintain the Student enrollment in to a class and points scored by him in a class. You need to do it by using a List of Tuples What you need to do? 1. You need to repeatedly display this menu to the user 1. Enroll into Class 2. Drop from Class 3. Calculate average of grades for a course 4. View all Students 5. Exit 2. Ask the...

  • For this assignment we are going to create the beginnings of a simple Grade Book. We...

    For this assignment we are going to create the beginnings of a simple Grade Book. We will revisit this assignment again once we learn some new concepts. For the purposes of this grade book you should first provide a menu with the following options: 1. Add a new course 2. Add a new student 3. Add a student to a course 4. Add grades for a student in a course 5. Print a list of all grades for a student...

  • PYTHON PROGRAMMING Instructions: You are responsible for writing a program that allows a user to do...

    PYTHON PROGRAMMING Instructions: You are responsible for writing a program that allows a user to do one of five things at a time: 1. Add students to database. • There should be no duplicate students. If student already exists, do not add the data again; print a message informing student already exists in database. • Enter name, age, and address. 2. Search for students in the database by name. • User enters student name to search • Show student name,...

  • (IN PYTHON) You are to develop a Python program that will read the file Grades-1.txt that...

    (IN PYTHON) You are to develop a Python program that will read the file Grades-1.txt that you have been provided on Canvas. That file has a name and 3 grades on each line. You are to ask the user for the name of the file and how many grades there are per line. In this case, it is 3 but your program should work if the files was changed to have more or fewer grades per line. The name and...

  • Write python code on computer, No handwritten code You will implement a program which asks the...

    Write python code on computer, No handwritten code You will implement a program which asks the user to enter scores of different courses in different semesters. The program should read the input and output some simple statistics 1. An example input string by the user is given below. Fal12016-coursel:82, course2:80,course3:85;Spring2018- course4:82;Fall2018-course5:85, course6:50, course7:78 Info from different semesters are separated by a ";", courses in each semester are separated by a,and score and corresponding course is separated by a, information of...

  • Write a c++ program which uses a structure having the indicated member names to store the...

    Write a c++ program which uses a structure having the indicated member names to store the following data: Name (student name) IDnum (student ID number) Tests (an array of three test scores) Average (average test score) Grade (course grade) The program will keep a list of three test scores for one student. The program may prompt the user for the name, ID number, and test scores, or these may be assigned within the program. The average test score will be...

  • In JAVA please! Write program for exercises You will write a Graphical User Interface(GUI) application to manage student...

    In JAVA please! Write program for exercises You will write a Graphical User Interface(GUI) application to manage student information system. The application should allow: 1. Collect student information and store it in a binary data file. Each student is identified by an unique ID. The user should be able to view/edit an existing student. Do not allow student to edit ID. 2. Collect Course information and store it in a separate data file. Each course is identified by an unique...

  • using C geany. Please Dr. exercise # 1 and 2 During the lab: PART I: PROGRAMMING...

    using C geany. Please Dr. exercise # 1 and 2 During the lab: PART I: PROGRAMMING EXERCISES a. Using Geany, write a C program that prompts and asks the user for two assignment marks (al and a2) and two test marks (ti and t2). All four variables are integer variables and are in % (out of 100). You program should display the four marks properly lalebed to check if the input has been successful. b. Next, calculate and display the...

  • please use the c language Assignment 12 The program to write in this assignment is a...

    please use the c language Assignment 12 The program to write in this assignment is a program that calculates score statistics and manages the grades of the students. First, the student list and are given in a file named "student.dat" as in the following: 이성우 77 홍길동 88 scores 201 1710086 2012700091 This program reads the input file "student.dat" and keeps this data in a linear linked list. Each node must be a struct which contains the following: student id...

  • PYTHON 3 Object Oriented Programming ***a9q3.py file below*** class GradeItem(object): # A Grade Item is anything...

    PYTHON 3 Object Oriented Programming ***a9q3.py file below*** class GradeItem(object): # A Grade Item is anything a course uses in a grading scheme, # like a test or an assignment. It has a score, which is assessed by # an instructor, and a maximum value, set by the instructor, and a weight, # which defines how much the item counts towards a final grade. def __init__(self, weight, scored=None, out_of=None): """ Purpose: Initialize the GradeItem object. Preconditions: :param weight: the weight...

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