Python Forum
Calculate median for school grades per subject
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calculate median for school grades per subject
#1
Hi,

I need some help with calculating median for school grades for subject or subject and diffuculty level (..200, 300).

The text is not in english, not sure if it needs to be? If so I can probaly translate.

Just managed to calculate median for all grades but I can not get it right for per subjects.

 emner = ['INFO100','INFO104',
             'INFO200','INFO204',
             'INFO300','INFO304',
             'ECON100','ECON101',
             'ECON200','ECON251',
             'ECON310','ECON320',
             'GEO100','GEO105',
             'GEO251','GEO205',
             'GEO351','GEO350',]

fag = {'informasjonsvitenskap':'INF', 'økonomi':'ECON', 'geovitenskap':'GEO'}

karakterer = {'INFO100':'C', 'INFO104':'B', 'INFO204':'C',
                 'ECON100':'B', 'ECON101':'A', 'ECON251':'B',
                 'GEO100':'A', 'GEO105':'C', 'GEO205':'B'}
    

if handling == 4:

            tall = 0
            count = 0

            input("Velg fag og/eller emnenivå (<enter> for alle)")
            subject = input(" -Fag : ")
            level = input(" -Nivå : ")
            
            for k,v in karakterer.items():

                if v =="A":
                    tall+=6
                    count +=1
                if v =="B":
                    tall+=5
                    count +=1
                if v =="C":
                    tall+=4
                    count +=1
                if v =="D":
                    tall+=3
                    count +=1
                if v =="E":
                    tall+=2
                    count +=1
                if v =="F":
                    tall+=1
                    count +=1
                    
            snitt = tall/count
            snitt = round(snitt)
            
            if snitt == 6:
                snitt = "A"
            if snitt == 5:
                snitt = "B"
            if snitt == 4:
                snitt = "C"
            if snitt == 3:
                snitt = "D"
            if snitt == 2:
                snitt = "E"
            if snitt == 1:
                snitt = "F"
        
            
            if subject == "" and level == "":
                print(snitt)

            if subject == "" and level 
Thanks so much for all help :)
Reply
#2
In your for k,v loop, keep additional tallies and counts for each subject and level. You will need to parse the k string - getting the characters up to and including the first numeric character.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Grades Code": Anthony 14 1,421 Nov-24-2023, 07:41 AM
Last Post: buran
  python program that calculat grades of students biligorm 3 2,218 Apr-04-2020, 10:11 AM
Last Post: buran
  Startiing a Course/Subject System with inquiry legendavid03 1 1,736 Nov-24-2019, 01:17 PM
Last Post: ichabod801
  Help on Creating Program to find the Median and Mode by hand EvanCahill 3 2,935 Jul-19-2018, 06:17 PM
Last Post: woooee
  Median of the age row - tsv file sonxy 3 3,004 Apr-09-2018, 11:48 PM
Last Post: micseydel
  Masked median filters Jim421616 0 2,854 Aug-24-2017, 01:30 AM
Last Post: Jim421616

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020