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