Question: Python: I have a problem with converting strings to float input 'Eric Cartman'? ** Input and output should be EXACTLY like the one on the

Python: I have a problem with converting strings to float input 'Eric Cartman'? ** Input and output should be EXACTLY like the one on the bottom.

input:

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:

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:

My Code:

num_of_students=int(input())

for i in range(num_of_students): # Name of student name_of_student=input() # GPA of Students gpa_of_student=input()

print('How many students are in the class?') for j in range(num_of_students): while(len(name_of_student)>24): print('Name of student cannot exceed 24 characters') continue print("Enter the name of student:") print("Enter the gpa of student:")

while(float(gpa_of_student)<0.0 or float(gpa_of_student)>4.0): print('GPA of student must be between 0.0 and 4.0') continue print("Enter the name of student:") print("Enter the gpa of student:")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!