Python Forum
[split] need help with the code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] need help with the code
#1
Hello I need help with the code
Where is the mistake?
class Dijak:
  def_init_(self,imeInPriimek,odelek,stDosezenihTock,vrstaOcene):
    self.imeInPriimek=imeInPriimek
    self.odelek=odelek
    self.stDosezenihTock=stDosezenihTock
    self.vrstaOcene=vrstaOcene
  def vrniOceno(self):
    odstotek=self.stDosezenihTock/28*100
    if(odstotek>=88):
      return(5)
    elif(odstotek>=75):
      return(4)
    elif(odstotek>=63):
      return(3)
    elif(odstotek>=50):
      return(2)
    else:
      return(1)
  def vrniImeInPriimek(self):
    loci=self.imeInPriimek.split("")
    niz=loci[1]+","+loci[0]
    return(niz)
  def izpisObjekta(self):
    print(self.vrniImeInPriimek()+"("+self.odelek+")"+"ocena :"+str(self.vrniOceno)+","+self.vrstaOcene)
  def shraniPodatek(N):
    for i in range(N)
      objekt=Dijak(input("Dijak :")),input("Odelek :"),int(input("Tocke :")),input("Vrsta :"))
      seznam.append(objekt)
    return(seznam)
  def VrniOceneDijaka(seznamdijakov,imeInPriimek):
    for s in seznamdijakov:
      if(s.imeInPriimek==imeInPriimek):
        s.izpisObjekta()
  def povprecjeRazreda(seznamdijakov,odelek,vrstaOcene):
    vsota=0
    stevec=0
    for s in seznamdijakov:
      if(s.vrstaOcene==vrstaOcene and s.odelek==odelek):
        vsota+=s.vrniOceno()
          stevec+=1
    print(vsota/stevec)
[hr]
class Dijak:
  def_init_(self,imeInPriimek,odelek,stDosezenihTock,vrstaOcene):
    self.imeInPriimek=imeInPriimek
    self.odelek=odelek
    self.stDosezenihTock=stDosezenihTock
    self.vrstaOcene=vrstaOcene
  def vrniOceno(self):
    odstotek=self.stDosezenihTock/28*100
    if(odstotek>=88):
      return(5)
    elif(odstotek>=75):
      return(4)
    elif(odstotek>=63):
      return(3)
    elif(odstotek>=50):
      return(2)
    else:
      return(1)
  def vrniImeInPriimek(self):
    loci=self.imeInPriimek.split("")
    niz=loci[1]+","+loci[0]
    return(niz)
  def izpisObjekta(self):
    print(self.vrniImeInPriimek()+"("+self.odelek+")"+"ocena :"+str(self.vrniOceno)+","+self.vrstaOcene)
  def shraniPodatek(N):
    for i in range(N)
      objekt=Dijak(input("Dijak :")),input("Odelek :"),int(input("Tocke :")),input("Vrsta :"))
      seznam.append(objekt)
    return(seznam)
  def VrniOceneDijaka(seznamdijakov,imeInPriimek):
    for s in seznamdijakov:
      if(s.imeInPriimek==imeInPriimek):
        s.izpisObjekta()
  def povprecjeRazreda(seznamdijakov,odelek,vrstaOcene):
    vsota=0
    stevec=0
    for s in seznamdijakov:
      if(s.vrstaOcene==vrstaOcene and s.odelek==odelek):
        vsota+=s.vrniOceno()
          stevec+=1
    print(vsota/stevec)
Reply
#2
Edit your post: https://python-forum.io/misc.php?action=help&hid=25
Use the code tags.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#3
What is it supposed to do?
What errors are you getting?

You define 2 classes but don't instantiate either.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] Kera Getting errors when following code example Image classification from scratch hobbyist 3 2,392 Apr-13-2021, 01:26 PM
Last Post: amirian
  [split] Python code help sairam17519 3 1,035 Sep-10-2020, 01:44 PM
Last Post: sairam17519
  How to Split Output Audio on Text to Speech Code Base12 2 4,331 Aug-29-2020, 03:23 AM
Last Post: Base12
  How to split and combine embedded lines using less code pjfarley3 6 1,029 Aug-13-2020, 09:13 PM
Last Post: pjfarley3
  [split] SyntaxError when trying to execute code on Windows nehaya 2 824 Aug-04-2020, 11:18 AM
Last Post: nehaya
  [split] VS Code Editor SupaNub 5 1,367 Nov-27-2019, 03:37 PM
Last Post: snippsat
  [split] I need help making a four digit code cracker with random tycpytyt 1 1,447 Mar-24-2019, 05:53 PM
Last Post: micseydel
  [split] Paspberry Pi and Python - how to write code soona 1 1,477 Mar-19-2018, 11:02 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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