Difference between revisions of "Grade Conversion"

From CompSciWiki
Jump to: navigation, search
 
(Completed the Grade Conversion program)
Line 1: Line 1:
 
{{Template:1010ExtraLabs
 
{{Template:1010ExtraLabs
 
|Chapter_TOC=[[Extra Labs]]
 
|Chapter_TOC=[[Extra Labs]]
|Introduction=How are you doing in grade conversion?.
+
|Introduction=Create a program that converts a numerical grade to its corresponding letter grade.  The letter grades that need assigning are (Please note that the following ranges are inclusive): 
 +
<br>'''A''' : 80-100 (Excellent work)
 +
<br>'''B''': 70-79 (Very Good)
 +
<br>'''C''': 60-69 (Average)
 +
<br>'''D''': 50-59 (Below Average)
 +
<br>'''F''': 0-49 (Below Average)
 +
<br>Prompt the user to input a letter grade (between 0 and 100). Output the letter grade and a brief grade description (such as "Excellent work"). Use '''raw_input''' and '''print''' for output. Ensure that necessary validity checks are done in the program to prevent invalid (numerical) input.  Use constants for the letter grade ranges.  .
 
|Body=
 
|Body=
  
== Step 1: ==
+
===[[Step 1: Get inputs/outputs needed to solve the problem ]]===
 +
 
 +
<li>input - Used to prompt the user for input
 +
<li>mark - The mark that is to be used for the computation
 +
 
 +
===[[Step 2: Write the program]]===
  
 
{{CodeBlock
 
{{CodeBlock
|Code=Bla0;
+
|Code=####################################
}}
+
####################################
 +
# This program is used to convert
 +
# a mark into its approparite
 +
# letter grade
 +
 
 +
## Get mark from the user
 +
mark = input("Please enter your marks:")
 +
 
 +
if (mark >= 75):
 +
    print "Your grade is above average"
 +
elif (mark >= 70):
 +
    print "Your grade is average"
 +
elif (mark <= 65):
 +
    print "Your grade is below average"
 +
else:
 +
    print "This is not a valid mark. Please input another mark."
 
}}
 
}}
  
Bla2.
+
===[[Step 3: Contrast with Letter Grade Conversion program in Program-A-Day example]]===
 +
 
 +
This Python program produces  exactly the same result as the Java Letter Grade Conversion program in Program-A-Day.
 +
}}

Revision as of 22:49, 3 April 2012

COMP 1010 Home > Back to Extra Labs

Introduction

Create a program that converts a numerical grade to its corresponding letter grade. The letter grades that need assigning are (Please note that the following ranges are inclusive):
A : 80-100 (Excellent work)
B: 70-79 (Very Good)
C: 60-69 (Average)
D: 50-59 (Below Average)
F: 0-49 (Below Average)
Prompt the user to input a letter grade (between 0 and 100). Output the letter grade and a brief grade description (such as "Excellent work"). Use raw_input and print for output. Ensure that necessary validity checks are done in the program to prevent invalid (numerical) input. Use constants for the letter grade ranges. .

Step 1: Get inputs/outputs needed to solve the problem

  • input - Used to prompt the user for input
  • mark - The mark that is to be used for the computation

    Step 2: Write the program

     ####################################
    ####################################
    # This program is used to convert
    # a mark into its approparite 
    # letter grade
    
    ## Get mark from the user
    mark = input("Please enter your marks:")
    
    if (mark >= 75):
        print "Your grade is above average"
    elif (mark >= 70):
        print "Your grade is average"
    elif (mark <= 65):
        print "Your grade is below average"
    else:
        print "This is not a valid mark. Please input another mark." 

    Step 3: Contrast with Letter Grade Conversion program in Program-A-Day example

    This Python program produces exactly the same result as the Java Letter Grade Conversion program in Program-A-Day.