Question

PLEASE USE IDLE PYTHON: Question (Arrays/Lists) A teacher uses 2   arrays (or Lists) to keep track...

PLEASE USE IDLE PYTHON:

Question (Arrays/Lists)

A teacher uses 2   arrays (or Lists) to keep track of his students. One is used to store student names and the other stores his grade (0-100). Write a program to create these two arrays (or lists) that are originally empty, and do the following using a menu:

1. Add a new student and his/her grade.

2. Print the name and grade of all current students, one student per line.

3. Display the number of students.

4. Print the names of students with a grade more than 90.

5. Raise the grades of all students by 5 points.

6. Exit.

Homework Answers

Answer #1
Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change. 

If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions.

Thank You!
===========================================================================

def displayMenu():
    print('1. Add a new student and his/her grade.')
    print('2. Print the name and grade of all current students, one student per line.')
    print('3. Display the number of students.')
    print('4. Print the names of students with a grade more than 90.')
    print('5. Raise the grades of all students by 5 points.')
    print('6. Exit.')
    choice = input('Enter your choice: ')
    return choice


def addStudent(names, grades):
    name = input('Enter student name: ')
    grade = int(input('Enter grade [0-100]: '))
    if 0 <= grade <= 100:
        names.append(name)
        grades.append(grade)
        print('Student added successfully.')
    else:
        print('Sorry could not add student. Grade cannot be greater than 100 or less than 0')


def main():
    names = []
    grades = []
    while True:
        choice = displayMenu()
        if choice == '1':
            addStudent(names, grades)
        elif choice == '2':
            print('Printing all student names and grades:')
            for i in range(len(names)):
                print('{:<15} - Grade {}'.format(names[i], grades[i]))
        elif choice == '3':
            print('Printing all student names:')
            for name in names: print('{}'.format(name))
        elif choice == '4':
            print('Printing all student names and grades >=90:')
            for i in range(len(names)):
                if grades[i] >= 90:    print('{:<15} - Grade {}'.format(names[i], grades[i]))
        elif choice == '5':
            print('Raising all grades by 5 points.')
            for i in range(len(grades)): grades[i] = 5 + grades[i] if grades[i] <= 95 else grades[i]
        elif choice == '6':
            print('Thank You. Bye!')
            break
        else:
            print('Error: Invalid choice.')


main()

=================================================================

Know the answer?
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
Similar Questions
IN PYTHON Menu: 1. Hotdog. ($2) 2. Salad ($3)  3. Pizza ($2) 4.Burger ($4) 5.Pasta ($7) Write...
IN PYTHON Menu: 1. Hotdog. ($2) 2. Salad ($3)  3. Pizza ($2) 4.Burger ($4) 5.Pasta ($7) Write a menu-driven program for  Food Court. (You need to use functions!) Display the food menu to a user . 5 options Use numbers for the options and for example "6" to exit. Ask the user what he/she wants and how many of it. (Check the user inputs) AND use strip() function to strip your inputs(if needed) Keep asking the user until he/she chooses the exit...
Project 2 statement Please write this in JAVA. Please read this entire statement carefully before you...
Project 2 statement Please write this in JAVA. Please read this entire statement carefully before you start doing anything… This project involves implementing a simple university personnel management program. The program contains two different kinds of objects: students and faculty. For each object, the program stores relevant information such as university ID, name, etc. Different information is stored depending on the type of the object. For example, a student has a GPA, while a faculty has a title and department...
#Linked Lists and Classes #C++ Hi, please use singly linked list method to do this question....
#Linked Lists and Classes #C++ Hi, please use singly linked list method to do this question. Thank you! Here’s the contents of a file called example.cpp: // example.cpp #include "LinkedList.h" #include <iostream> #include <string> using namespace std; int main() { cout << "Please enter some words (ctrl-d to stop):\n"; LinkedList lst; int count = 0; string s; while (cin >> s) { count++; lst.add(remove_non_letters(s)); } // while cout << "\n" << count << " total words read in\n"; cout <<...
I've posted this question like 3 times now and I can't seem to find someone that...
I've posted this question like 3 times now and I can't seem to find someone that is able to answer it. Please can someone help me code this? Thank you!! Programming Project #4 – Programmer Jones and the Temple of Gloom Part 1 The stack data structure plays a pivotal role in the design of computer games. Any algorithm that requires the user to retrace their steps is a perfect candidate for using a stack. In this simple game you...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT
Active Questions
  • A business PhD student who lived on a naval base, looked at prices of items at...
    asked 7 minutes ago
  • 1 Consider diversity, interpersonal communication, & technology in the workplace & explain the roles they may...
    asked 15 minutes ago
  • 1 Explain how "triggers to imbalance" in work-life balance influence the imbalance & how they can...
    asked 30 minutes ago
  • Spaulding is the leading maker for basketballs in the US. Spaulding prides itself on the quality...
    asked 41 minutes ago
  • Select True or False for the following statements about Heisenberg's Uncertainty Principle.  True False  It is possible to...
    asked 1 hour ago
  • Explain why, to maximize entropy, ice must remain at 0 degrees Celsius until all of it...
    asked 1 hour ago
  • THE CODE MUST BE PYTHON superHeroes = {   "MoleculeMan": {       "age": 29,       "secretIdentity": "Dan Jukes",       "superpowers":...
    asked 1 hour ago
  • Which of the four complexes of the mitochondrial electron transfer chain does not directly contribute to...
    asked 1 hour ago
  • Police response time to an emergency call is the difference between the time the call is...
    asked 1 hour ago
  • A space vehicle is traveling at 5030 km/h relative to Earth when the exhausted rocket motor...
    asked 1 hour ago
  • You have 3 parallel production lines which supply the assembly line. Acceptable quality percentage(AQP) for lines...
    asked 1 hour ago
  • A radio telescope with a diameter of 260m uses a wavelength of 4.5m to observe a...
    asked 1 hour ago