classes | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

classes

The provided code defines a Student class, creates a Student object, and calls its greet() method. However, the code has an error and does not run. Fix the code to produce the expected output. class Student: def __init__(self, name): self.name = name def greet(): print(self.name+" says hi") obj = Student("John") obj.greet() Can anybody help me out there...?

4th Jul 2021, 3:24 PM
Lokendra Gupta
Lokendra Gupta - avatar
4 Answers
+ 3
I did this to cut the other def class Student: def __init__(self, name): self.name = name self.x = self.name+" says hi" obj = Student("John") print(obj.x)
19th Aug 2021, 5:06 PM
Shobuyi
Shobuyi - avatar
+ 2
just change def greet() -----into ----> def greet(self) # celebrate it must work well
4th Jul 2021, 3:31 PM
Jitendra
Jitendra - avatar
0
Hello Friends Sell Back College Books is a place for college students to sell their books easily and at affordable prices. We want to make it easy for students to sell books they no longer need https://www.resumehelpservices.com/velvetjobs-com-review/ but don't have a place to store. But velvetjobs make this platform easy for you to buy books in careers. You can also buy the book for yourself from
6th Jan 2023, 7:31 AM
Conamill
Conamill - avatar
0
This will surely work without a doubt, using only 3 lines name = input() lvl = input() print(name + "(Level " + lvl + ")")
26th Sep 2023, 10:16 AM
Rashed Carnain
Rashed Carnain - avatar