1 Replies - 166 Views - Last Post: 30 June 2019 - 03:36 AM Rate Topic: -----

#1 pythonhelp   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 20-January 19

Textbook example not working

Posted 30 June 2019 - 01:45 AM

I have coded this example from a course textbook (it says it is a working example), When I run the code, it is coming with a Name Error, Assessment not defined.

I have played around with the code but with no luck. Can anyone please help me correct the error? (I have followed the book line by line).

class Course:
    def __init__(self,t,m):
         
        self.__CourseTitle=t
        self.__MaxStudents=m
        self.__NumberOfLessons=0
        self.__CourseLesson=[]
        self.__CourseAssessment=Assessment
 
 
    def AddAssessment(self,t,m):
        self.__CourseAssessment=Assessment(t,m)
 
    def AddLesson(self,t,d,r):
        self.__NumberOfLessons=self.__NumberOfLessons+1
        self.__CourseLesson.append(Lesson(t,d,r))
 
     
         
    def OutputCourseDetails(self):
        print(self.__CourseTitle,"Maximum Number: ",self.__MaxStudents)
        for i in range(self.__NumberOfLessons):
            print(self.__CourseLesson[i].OutputLessonDetails())
 
     
MyCourse=Course("Computing",10)
 
MyCourse.AddAssessment("Programming",100)
MyCourse.AddLesson("Problem Solving",60,False)
MyCourse.AddLesson("Programming",120,True)
MyCourse.AddLesson("Theory",60,False)
 
 
 
MyCourse.OutputCourseDetails()





Is This A Good Question/Topic? 0
  • +

Replies To: Textbook example not working

#2 pythonhelp   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 20-January 19

Re: Textbook example not working

Posted 30 June 2019 - 03:36 AM

PLEASE DELETE THIS THREAD.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1