Question

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, followed by age, address, and all grades tabbed over (next line).

3. Enter grade.

• User enters an assignment (assume that the assignment already exists)

• User enters a student name (assume that student already exists in database)

• User enters a grade (It’s up to you to have grades as string or integer or float)

• The student’s grade is assigned to that assignment.

4. Add assignment.

• User enters the name of the assignment to be added

• Once an assignment is added, it exists for all students.

• The default grade is a ‘-’ character.

5. Delete assignment.

• User enters an assignment to be deleted.

• The assignment is deleted for all students.

6. Quit.

• Quits the program.

Restrictions:

1. You must use a list or dictionary or both of those.

2. You must use an infinite loop.

3. You must use a break statement.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
""" Adding student to the dictionary """


def add_student(details, student):
    if student not in details:
        details[student] = {}
    else:
        print("Student already exists in database")
    return details


""" Adding students detail to the dictionary"""


def add_details(name, age, address, details, student):
    details[student]['name'] = name
    details[student]['age'] = age
    details[student]['address'] = address


""" Searching student from the dictionary"""


def search_student(details, name):
    for (k, v) in details.items():
        if details[k]['name'] == name:
            print(details[k])
            break


""" Adding grade to the student """


def add_grade(details, student, assignment, grade):
    details[student][assignment][grade] = grade


"""Adding new assignment to the student"""


def add_assignment(details, assignment):
    for k, v in details.items():
        details[k][assignment] = {'grade': '-'}
    print(details)

"""Deleting the requested assignment """


def delete_assignment(details,name, assignment):
    if details[name][assignment]:
        del details[name][assignment]


def main():
    details = {}  # dictionary for storing the student details

    while True:
        student = input("Enter student")
        add_student(details, student)

        name = input("Enter student name")
        age = int(input("Enter age"))
        address = input("Enter address")

        add_details(name, age, address, details, student)

        search_name = input("Enter name you want to search for")
        search_student(details, search_name)

        assignment = input("Enter assignment")
        add_assignment(details, assignment)

        grade = input("Enter grade")
        add_grade(details, student, assignment, grade)

        remove_assignment = input("Enter assignment")
        delete_assignment(details, name,remove_assignment)

        n = int(input("If you want to quit please enter 1 else input some other number"))

        if n == 1:
            break


if __name__ == '__main__':
    main()
Add a comment
Know the answer?
Add Answer to:
PYTHON PROGRAMMING Instructions: You are responsible for writing a program that allows a user to do...
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
  • Write a program that asks the user for a student name and asks for grades until...

    Write a program that asks the user for a student name and asks for grades until the user enters a non-number input, it should then ask if the user wants to enter another student, and keep doing the process until the user stops adding students. The student’s must be stored in a dictionary with their names as the keys and grades in a list. The program should then iterate over the dictionary elements producing the min, max, and mean of...

  • Design and code a JAVA program called ‘Grades’. ? Your system should store student’s name, and...

    Design and code a JAVA program called ‘Grades’. ? Your system should store student’s name, and his/her course names with grades. ? Your system should allow the user to input, update, delete, list and search students’ grades. ? Each student has a name (assuming no students share the same name) and some course/grade pairs. If an existing name detected, user can choose to quit or to add new courses to that student. ? Each student has 1 to 5 courses,...

  • Write a program that performs the following: 1. Presents the user a menu where they choose...

    Write a program that performs the following: 1. Presents the user a menu where they choose between:              a. Add a new student to the class                           i. Prompts for first name, last name                           ii. If assignments already exist, ask user for new student’s scores to assignments              b. Assign grades for a new assignment                           i. If students already exist, prompt user with student name, ask them for score                           ii. Students created after assignment will need to...

  • In this assignment, you will write a program in C++ which uses files and nested loops...

    In this assignment, you will write a program in C++ which uses files and nested loops to create a file from the quiz grades entered by the user, then reads the grades from the file and calculates each student’s average grade and the average quiz grade for the class. Each student takes 6 quizzes (unknown number of students). Use a nested loop to write each student’s quiz grades to a file. Then read the data from the file in order...

  • This code should be written in php. Write a program that allows the user to input...

    This code should be written in php. Write a program that allows the user to input a student's last name, along with that student's grades in English, History, Math, Science, and Geography. When the user submits this information, store it in an associative array, like this: Smith=61 67 75 80 72 where the key is the student's last name, and the grades are combined into a single space-delimited string. Return the user back to the data entry screen, to allow...

  • [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and...

    [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and methods must be used for this program. Process: •Read the number of students in a class. Make sure that the user enters 1 or more students. •Create an array with the number of students entered by the user. •Then, read the name and the test score for each student. •Calculate the best or highest score. •Then, Calculate letter grades based on the following criteria:...

  • Java program Program: Grade Stats In this program you will create a utility to calculate and...

    Java program Program: Grade Stats In this program you will create a utility to calculate and display various statistics about the grades of a class. In particular, you will read a CSV file (comma separated value) that stores the grades for a class, and then print out various statistics, either for the whole class, individual assignments, or individual students Things you will learn Robustly parsing simple text files Defining your own objects and using them in a program Handling multiple...

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

  • You are to write a program which will ask the user for number of students (dynamic...

    You are to write a program which will ask the user for number of students (dynamic array of class Student). For each student, you will ask for first name and number of grades (dynamic array of grades as a variable in Student). **The program should give the student random grades from 0-100** Find the averages of each student and display the information. **Display name, grades, and average neatly in a function in the Student class called Display()** Sort the students...

  • You are to write a program which will ask the user for number of students (dynamic...

    You are to write a program which will ask the user for number of students (dynamic array of class Student). For each student, you will ask for first name and number of grades (dynamic array of grades as a variable in Student). **The program should give the student random grades from 0-100** Find the averages of each student and display the information. **Display name, grades, and average neatly in a function in the Student class called Display()** Sort the students...

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