Page 346 - Computer Science V2.0 Class 11
P. 346

10.  Write a program to find the grade of a student when grades are allocated as given in the table below.
                     Percentage of Marks     Grade
                     Above 90%               A
                     80% to 90%              B
                     70% to 80%              C
                     60% to 70%              D
                     Below 60%               E
                    Percentage of the marks obtained by the student is input to the program.
               Ans.  percentMarks = float(input('Enter the percentage of the student: '))
                    if(percentMarks >= 90):
                        print("Grade A")
                    elif(percentMarks >= 80):
                        print("Grade B")
                    elif(percentMarks >= 70):
                        print("Grade C")
                    elif(percentMarks >= 60):
                        print("Grade D")
                    else:
                        print("Grade E")
                                                     CASE STUDY-BASED QUESTIONS
                    Let us add more functionality to our SMIS developed in Chapter 7.
                    6.1. Write a menu driven program that has options to
                     • accept the marks of the student in five major subjects in Class X and display the same.
                     • calculate the sum of the marks of all subjects. Divide the total marks by number of subjects
                        (i.e. 5), calculate percentage = total marks/5 and display the percentage.
                     • Find the grade of the student as per the following criteria:
                     Criteria                                  Grade
                     percentage > 85%                          A
                     percentage < 85 && percentage >= 75       B
                     percentage < 75 && percentage >= 50       C
                     percentage < 30 && percentage >= 50       D
                     percentage < 30                           Reappear
                     Let’s peer review the case studies of others based on the parameters given under “DOCUMENTATION TIPS” at the end of Chapter 7 and
                    provide a feedback to them.
               Ans.  def acceptMarks():
                        marks = []
                        print("Enter marks for each subject:")
                        for i in range(5):
                            subjectMarks = float(input(f"Subject {i+1}: "))
                            marks.append(subjectMarks)
                        return marks

                    def computePercentage(totalMarks):
                        return totalMarks / 5

                    def findGrade(percentage):
                        if percentage > 85:
                            return 'A'
                        elif 75 <= percentage < 85:
                            return 'B'

               332   Touchpad Computer Science (Ver. 2.0)-XI
   341   342   343   344   345   346   347   348   349   350   351