QuestionQuestion

1. Ask the user for the number of students. Use a try/catch statement to make sure the user enters a whole number. Once you have the number of students, you can define your arrays with this size. For example, FirstName = [""] * num defines an array to hold num items.

2. For each student, ask the user to enter a set of first names into one array, the middle initials into another array, last names into another array and grade point average (GPA - floating point values such as 3.4, 2.8, etc.) into another array for a given student. This way, you will have 4 parallel arrays.

3. Write a function that displays this data in a tabular form using the following format: first name middle initial last name-GPA value. Display GPA with 2 digits after the decimal point. For example:

foo f bar-3.70
joe j jhonson-2.70

Note the space between names and a dash before the GPA. This function needs to have as its parameters what it needs to display the data.

4. Write a function to display the output as a list of email addresses using the format: first name.last name@csd.edu Using the above example, the output will look like:

foo.bar@csn.edu
joe.johnson@csn.edu

This function needs to have as its parameters what it needs to display the data.

5. Write a function to return the average GPA. The average GPA for the example, above would be 3.2. This function just returns the average GPA. It does not display the value inside the function. This function needs to have as its parameters what it needs to calculate the GPA.

6. Write a function to return the student name with the highest GPA. This function returns the value. It does not display it inside the function. This function needs to have as its parameters what it needs to find the name with the highest GPA. HINT: In order to find the highest value, you’ll need a loop and a decision inside the loop comparing values in the array. You should be able to come up with this algorithm all on your own or look it up in your textbook or look at the video recordings and other resources posted in Canvas. One method would be to find the index of the array with the highest GPA. The name at that index would

obviously be the student name with the highest GPA.

7. Write a function to display the contents of all 4 arrays (pick your own format) to a file named “students.txt”. This function needs to have as its parameters what it needs to display the data in all 4 arrays.

In your main function, call these other functions and make sure to display values returned from a function. For example, you all a function that returns the average GPA. Print this value to test the functionality of the function.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

"""
This program process student data using arrays, functions and files.
"""
num = False
while num==False: # while num==False ask the user to input the number of students
    try:
       num = int(input('Please enter the number of students: ')) # ask the user for the number of students
    except ValueError:
       # if the input value is not integer, warn the user that numer of students must be an integer
       print('Number of students must be an integer!')
"""
make a list of empty strings to store students first names, last names, middle initials and GPA for each student
the length of lists is equal to the number of students
"""
FirstName = [""]*num
MiddleInitials = [""]*num #
LastName = [""]*num
GPA = [1]*num
   
for k in range(num): # iterate over the range of the number of students
    print()
    print('Student: ', k+1)...

By purchasing this solution you'll be able to access the following files:
Solution.py.

$18.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats