Question

Using Python programming, defines a function that accepts a letter grade as a parameter and returns...

Using Python programming, defines a function that accepts a letter grade as a parameter and returns the GPA. If the grade is not one of the standard letter grades (A, B, C, D, F), return -1 to indicate this.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

def grade(ch):
if(ch=='A'):#use if statements to check grades
return 9
elif(ch=='B'):
return 8
elif(ch=='C'):
return 7
elif(ch=='D'):
return 6
elif(ch=='F'):
return 0
else:
return -1
ch=input()
res=grade(ch)
if(res>0):
print("The GPA is above ",res)
elif(res==-1):
print("NO grade")
else:
print("The person failed")

Add a comment
Know the answer?
Add Answer to:
Using Python programming, defines a function that accepts a letter grade as a parameter and returns...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ //get_letter_grade.h /* Write a function gpa_to_letter_grade that returns a string and accepts a double gpa...

    C++ //get_letter_grade.h /* Write a function gpa_to_letter_grade that returns a string and accepts a double gpa parameter */ //get_letter_grade.cpp /* Write function code for gpa_to_letter_grade that returns a string and accepts a double gpa parameter YOU MUST USE A SWITCH STATEMENT Given a double 3.5 returns the string A TIP: You'll have to convert the double to an int using multiplication Table 3.5 to 4 returns an A 3.0 to 3.49 returns a B 1.7 to 2.99 returns a C...

  • What you're creating Using a case statement, create a function that accepts a letter grade and...

    What you're creating Using a case statement, create a function that accepts a letter grade and returns a minimum score to achieve that grade. How you'll do it You learned sequence structure, statements executed in order, then selection statements with if statements, then looping statements. In some languages, there is a case selection statements, sometimes called switch/case. In Python, you can write your own case statement using a function and a dictionary. In this assignment you will write a function...

  • 1.1. Write a function named "areFirstTwoTheSame AsLast TwoChars" that accepts a string. It returns true if...

    1.1. Write a function named "areFirstTwoTheSame AsLast TwoChars" that accepts a string. It returns true if the first two characters and the last two characters of the string are the same. It returns false otherwise. In addition, if the string is empty or has only one character, it also returns false. For example, these are the strings with their expected return values false falsc "AB" true "ABA" false "ABAB" trus "ABBA" false "ABCABC false "ABCCAB" true 1.2 Write a function...

  • use python Write function letter2number() that takes as input a letter grade (A, B, C, D,...

    use python Write function letter2number() that takes as input a letter grade (A, B, C, D, F, possibly with a - or +) and returns the corresponding number grade. The numeric values for A, B, C, D, and F are 4, 3, 2, 1, 0. A + increases the number grade value by 0.3 and a - decreases it by 0.3. >>> letter2number('A-') 3.7 >>> letter2number('B+') 3.3 >>> letter2number('D') 1.0

  • Design a function named max that accepts two integer values as arguments and returns the value...

    Design a function named max that accepts two integer values as arguments and returns the value that is the greater of the two. For example, if 7 and 12 are passed as arguments to the function, the function should return 12. Use the function in a program that prompts the user to enter two integer values. The program should display the value that is the greater of the two. Need Variable lists, Psuedocode, ipo chart, Flow Chart, and a python...

  • Using Python Programming Language: 3. Write a function flatten that takes a 2D list and returns...

    Using Python Programming Language: 3. Write a function flatten that takes a 2D list and returns all the items of each list concatenated together into one new 1D list. For example: flatten ([["a", "b"],["c","0"],["e","f"]]) would return ["a", "b","C","d", "e","f"] Save the function in a PyDev library module named functions.py Write a program t03.py that tests flatten function and prints the returned flat list to the screen. Test your program with a different list, hardcoded in t03.py • Copy the results...

  •    PYTHON --create a function that accepts a list of numbers and an int that returns...

       PYTHON --create a function that accepts a list of numbers and an int that returns index of 2nd occurrence of the int in list, otherwise returns None if # does not repeat more 2 or more times EX: [10,24,3,45,10,49,4,5], 10) returns 4 --create a function that accepts a string that returns true if every letter of the alphabet can be found at least one time in the string, (has to be the lowercase alphabet), and false otherwise.    for...

  • Using Python programming, defines a function that gets a user's input of a list of words,...

    Using Python programming, defines a function that gets a user's input of a list of words, then uses a set to get the unique words, and displays the unique words in alphabetical order.

  • #write a function with int parameter to return letter grade for integer score # complete the...

    #write a function with int parameter to return letter grade for integer score # complete the code below: def grader(int1): grade = '' if int1 >=90: grade = 'A' elif int1 >=80: grade = 'B' elif int1 >=70:

  • Create a program in Python to change Grades in number and find the GPA of the...

    Create a program in Python to change Grades in number and find the GPA of the user Problem: The user wants an easy calculator to calculate their GPA. They want to enter the letter grade (A, B, C, D, F) for 5 classes, the credit hours (1, 2, 3,4, 5) and then run the program to calculate the GPA (3.50- 4.00 A, 3.49 – 2.50 B, 2.49 -1.60 C, 1.59 – .50 D, .49 -0 F) for the semester. Task...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT