Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python: Printing Student Data Ask the user: How many students are in the class? Read in the number of students If there are students For
Python: Printing Student Data
- Ask the user: "How many students are in the class?"
- Read in the number of students
- If there are students
- For each student
- Ask for the name of the student: "Enter the name of student:"
- Read in the name of the student
- If the student's name is greater than 24 characters
- Do not display this student's data
- Do not ask for their gpa
- Print: "Name of student cannot exceed 24 characters."
- Ask for the gpa of the student: "Enter the gpa of student:"
- Read in the gpa of the student
- If the student's gpa is not valid (between 0 and 4.0, inclusively)
- Do not display this student's data
- Do not include their gpa in the calculation
- Print: "GPA of student must be between 0.0 and 4.0."
- If the number of valid students is greater than zero
- Display a chart of student data with headers and a header horizontal dividing line:
- Number (left aligned in 10 spaces)
- Name (left aligned in 24 spaces)
- GPA (left aligned, spaces don't matter)
- Horizontal divider (37 hyphens)
- Student data vertically aligned with headers, one student per line
- Display the average GPA of all of the valid students: "Average GPA: #.###" (there is no limit to the number of decimal places)
- Display a chart of student data with headers and a header horizontal dividing line:
- For each student
Assumptions
You may assume the following
- The number of students will be an integer
- The number of students will not exceed 10 characters
- The name of the student will be printable characters, you do not need to check them in any way
- The gpa of a student will be a floating point value
- Use the float type for floating point precision
Input(Exactly)
5 Stan Marsh 3.6 Kenny McCormick 2.3 Someone with a really long name more than 20 characters Eric Cartman -1.1 Kyle Broflovski 4.0 Output(Exactly)
How many students are in the class? Enter the name of student: Enter the gpa of student: Enter the name of student: Enter the gpa of student: Enter the name of student: Name of student cannot exceed 24 characters. Enter the name of student: Enter the gpa of student: GPA of student must be between 0.0 and 4.0. Enter the name of student: Enter the gpa of student: Number Name GPA ------------------------------------- 1 Stan Marsh 3.6 2 Kenny McCormick 2.3 5 Kyle Broflovski 4.0 Average GPA: 3.3000000000000003
- The number of students will be an integer
- The number of students will not exceed 10 characters
- The name of the student will be printable characters, you do not need to check them in any way
- The gpa of a student will be a floating point value
- Use the float type for floating point precision
Requirements
To solve this problem, you must use the following python features:
- len() function
- for loop with range
- and/or
- continue
You may not use a string formatter
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started