How to assign values to attributes [closed]












-3















I am a newbie in python and am trying to write and execute a python code that returns student name, age and grade but on executions gives me an error message that:"Students() takes no arguments."



Here is my code:



class Students:
def _init_ (self,name,age,grade):
self.name=name
self.age=age
self.grade=grade

student1=Students('Bob',12,'7th')
Student1.name
Student1.age
Student.grade


I want the code to return to me 'Bob' as the student's name,12 as age and 7th as the student grade.










share|improve this question















closed as off-topic by Daniel Roseman, tripleee, eyllanesc, jww, Makyen Jan 2 at 6:01


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Daniel Roseman, tripleee, eyllanesc, jww, Makyen

If this question can be reworded to fit the rules in the help center, please edit the question.












  • 2





    The initialization of Python classes is handled by a method named __init__(). A method named _init_() (note different number of underscores) has no particular meaning.

    – jasonharper
    Jan 2 at 2:55
















-3















I am a newbie in python and am trying to write and execute a python code that returns student name, age and grade but on executions gives me an error message that:"Students() takes no arguments."



Here is my code:



class Students:
def _init_ (self,name,age,grade):
self.name=name
self.age=age
self.grade=grade

student1=Students('Bob',12,'7th')
Student1.name
Student1.age
Student.grade


I want the code to return to me 'Bob' as the student's name,12 as age and 7th as the student grade.










share|improve this question















closed as off-topic by Daniel Roseman, tripleee, eyllanesc, jww, Makyen Jan 2 at 6:01


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Daniel Roseman, tripleee, eyllanesc, jww, Makyen

If this question can be reworded to fit the rules in the help center, please edit the question.












  • 2





    The initialization of Python classes is handled by a method named __init__(). A method named _init_() (note different number of underscores) has no particular meaning.

    – jasonharper
    Jan 2 at 2:55














-3












-3








-3








I am a newbie in python and am trying to write and execute a python code that returns student name, age and grade but on executions gives me an error message that:"Students() takes no arguments."



Here is my code:



class Students:
def _init_ (self,name,age,grade):
self.name=name
self.age=age
self.grade=grade

student1=Students('Bob',12,'7th')
Student1.name
Student1.age
Student.grade


I want the code to return to me 'Bob' as the student's name,12 as age and 7th as the student grade.










share|improve this question
















I am a newbie in python and am trying to write and execute a python code that returns student name, age and grade but on executions gives me an error message that:"Students() takes no arguments."



Here is my code:



class Students:
def _init_ (self,name,age,grade):
self.name=name
self.age=age
self.grade=grade

student1=Students('Bob',12,'7th')
Student1.name
Student1.age
Student.grade


I want the code to return to me 'Bob' as the student's name,12 as age and 7th as the student grade.







python class object






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 4:34









Strom

2,368524




2,368524










asked Jan 2 at 2:41









Wycliffe MuchumiWycliffe Muchumi

11




11




closed as off-topic by Daniel Roseman, tripleee, eyllanesc, jww, Makyen Jan 2 at 6:01


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Daniel Roseman, tripleee, eyllanesc, jww, Makyen

If this question can be reworded to fit the rules in the help center, please edit the question.







closed as off-topic by Daniel Roseman, tripleee, eyllanesc, jww, Makyen Jan 2 at 6:01


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Daniel Roseman, tripleee, eyllanesc, jww, Makyen

If this question can be reworded to fit the rules in the help center, please edit the question.








  • 2





    The initialization of Python classes is handled by a method named __init__(). A method named _init_() (note different number of underscores) has no particular meaning.

    – jasonharper
    Jan 2 at 2:55














  • 2





    The initialization of Python classes is handled by a method named __init__(). A method named _init_() (note different number of underscores) has no particular meaning.

    – jasonharper
    Jan 2 at 2:55








2




2





The initialization of Python classes is handled by a method named __init__(). A method named _init_() (note different number of underscores) has no particular meaning.

– jasonharper
Jan 2 at 2:55





The initialization of Python classes is handled by a method named __init__(). A method named _init_() (note different number of underscores) has no particular meaning.

– jasonharper
Jan 2 at 2:55












1 Answer
1






active

oldest

votes


















1














You have not included a constructor for Students, your code creates a method named _init()_ not the constructor __init()__.
Also, Python is case sensitive, make sure all of your identifiers match case and spelling.



class Students:
def __init__ (self,name,age,grade):
self.name=name
self.age=age
self.grade=grade

student1=Students('Bob',12,'7th')
student1.name
student1.age
student1.grade





share|improve this answer
























  • It worked,Thank you guys.

    – Wycliffe Muchumi
    Jan 11 at 9:40


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You have not included a constructor for Students, your code creates a method named _init()_ not the constructor __init()__.
Also, Python is case sensitive, make sure all of your identifiers match case and spelling.



class Students:
def __init__ (self,name,age,grade):
self.name=name
self.age=age
self.grade=grade

student1=Students('Bob',12,'7th')
student1.name
student1.age
student1.grade





share|improve this answer
























  • It worked,Thank you guys.

    – Wycliffe Muchumi
    Jan 11 at 9:40
















1














You have not included a constructor for Students, your code creates a method named _init()_ not the constructor __init()__.
Also, Python is case sensitive, make sure all of your identifiers match case and spelling.



class Students:
def __init__ (self,name,age,grade):
self.name=name
self.age=age
self.grade=grade

student1=Students('Bob',12,'7th')
student1.name
student1.age
student1.grade





share|improve this answer
























  • It worked,Thank you guys.

    – Wycliffe Muchumi
    Jan 11 at 9:40














1












1








1







You have not included a constructor for Students, your code creates a method named _init()_ not the constructor __init()__.
Also, Python is case sensitive, make sure all of your identifiers match case and spelling.



class Students:
def __init__ (self,name,age,grade):
self.name=name
self.age=age
self.grade=grade

student1=Students('Bob',12,'7th')
student1.name
student1.age
student1.grade





share|improve this answer













You have not included a constructor for Students, your code creates a method named _init()_ not the constructor __init()__.
Also, Python is case sensitive, make sure all of your identifiers match case and spelling.



class Students:
def __init__ (self,name,age,grade):
self.name=name
self.age=age
self.grade=grade

student1=Students('Bob',12,'7th')
student1.name
student1.age
student1.grade






share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 2 at 3:11









StromStrom

2,368524




2,368524













  • It worked,Thank you guys.

    – Wycliffe Muchumi
    Jan 11 at 9:40



















  • It worked,Thank you guys.

    – Wycliffe Muchumi
    Jan 11 at 9:40

















It worked,Thank you guys.

– Wycliffe Muchumi
Jan 11 at 9:40





It worked,Thank you guys.

– Wycliffe Muchumi
Jan 11 at 9:40





Popular posts from this blog

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

SQL update select statement

'app-layout' is not a known element: how to share Component with different Modules