Jump to content

[Python] functions help


Recommended Posts

So it is late and i am trying to find this issue out with this code for my class. Anyone that can help, I would so need right now.

hear is the code:

import random
import time


def get_letter_grade(percentage):
if percentage >= 95:
letter_grade = "A"
return (letter_grade)
if percentage >= 94:
letter_grade = "A-"
if percentage >= 91:
letter_grade = "B+"
if percentage >= 88:
letter_grade = "B"
if percentage >= 85:
letter_grade = "B-"
if percentage >= 82:
letter_grade = "C+"
if percentage >= 79:
letter_grade = "C"
if percentage >= 76:
letter_grade = "C-"
if percentage >= 73:
letter_grade = "D+"
if percentage >= 70:
letter_grade = "D"
if percentage >= 67:
letter_grade = "D-"
if percentage >= 65:
letter_grade = "F"

return (letter_grade)

def get_grade_number(grade):
grade = int(grade)
get_letter_grade()

def opt(grade,percentage):
opt = int(get_letter_grade,get_grade_number)
return (letter_grade)


grade = 0

def menu():
print ("1: Enter grade in percentage (0-100)")
print ("2: Get letter grade from percentage grade")
print ("3: Calculate letter from extra credit")
print ("4: Calculate extra credit needed to boost letter grade")
print ("0: Exit ")
print (("Current Grade:"),(grade))


loop = 1

while loop ==1:
choice = menu()
choice = input ("Please make a choice: ")
choice = int(choice)

if choice == 1:
grade = input(" Enter percentage grade (0-100)?:")

elif choice == 2:
percentage = (opt)
opt =((get_letter_grade,get_grade_number), print (percentage))


basicly it a menu thing seen on this video :http://www.screencast.com/t/ZonV3w5Y7

but I am stuck at the part were trying to get the grade letter within the code.

I do not knwo what i am doing wrong with it so any help I baddly need.

Not sure how to do the when u get the % grade trying to get elif choice == 2 to work when it displays the letter grade.

thoughts on this?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...