Suppose there is class of 10 students who have CGPA between 0-10. The university has decided to give the grace for those students those who have the CGPA between 4.5 to 4.9 to make it 5. Identify the students those have CGPA after adding the grace marks. Add the grace CGPA to the obtained CGPA of student through list comprehensions. Input Format- The input should contains an array of roll_no,and CGPA of the students. Constraints- CGPA must lies between 1.0 to 10.0 otherwise print "invalid input" Output Format- For each test case, display the roll_no and increased CGPA of those students only who lies between the obtained CGPA of 4.5-4.9
roll_numbers=[]
CGPAs=[]
for i in range(10):
roll_numbers.append(input("Enter roll_no: "))
CGPA=-1
while CGPA<1 or CGPA>10:
CGPA=float(input("Enter CGPA: "))
if CGPA<1 or CGPA>10:
print("invalid input")
CGPAs.append(CGPA)
print("\n\nStudents who have the CGPA between 4.5 to 4.9\n")
for i in range(10):
if CGPAs[i]>=4.5 and CGPAs[i]<=4.9:
print(f"Roll number: {roll_numbers[i]}")
print(f"CGPA: {CGPAs[i]}")
CGPAs[i]=5
print(f"New CGPA: {CGPAs[i]}")
Comments
Leave a comment