Answer to Question #267007 in Python for Dhiraj

Question #267007

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


1
Expert's answer
2021-11-16T07:44:51-0500
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]}")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS