Answer: Exception
Solution:
class TV:
pass
creates a new data type called TV.
pass is just a no-operation statement, it doesn't add any data or functionality to the class.
Hence, this data type does not contain any attributes or functionality
obj = TV()
creates a new object named obj, of the data type TV.
obj.price = 200
creates a new variable named
The value of this variable is set to 200.
Finally, we have
print(self.price)
But there is no object named
Hence, we get an Exception stating that there is nothing called
But you'd have seen
It is simply a convention to use
the first parameter of the method.
The first parameter of a method is is the object through which the method was invoked.
Eg.
a = [1,2,3]
then
a.append(5)
is equivalent to
list.append(a, 5)
So here,
The name
conventionally used to refer to the implicit argument passed in methods.
Otherwise, the word
Hence, the code in the question gives an error, because
I hope this helped!
@python_assets
@javascript_resources
Solution:
class TV:
pass
creates a new data type called TV.
pass is just a no-operation statement, it doesn't add any data or functionality to the class.
Hence, this data type does not contain any attributes or functionality
obj = TV()
creates a new object named obj, of the data type TV.
obj.price = 200
creates a new variable named
price, within obj.The value of this variable is set to 200.
Finally, we have
print(self.price)
But there is no object named
self here!Hence, we get an Exception stating that there is nothing called
self.But you'd have seen
self in other programs elsewhere.self is not a keyword or pre-defined variable in Python.It is simply a convention to use
self WITHIN methods to denotethe first parameter of the method.
The first parameter of a method is is the object through which the method was invoked.
Eg.
a = [1,2,3]
then
a.append(5)
is equivalent to
list.append(a, 5)
So here,
a is implicitly passed to the method append.The name
self isconventionally used to refer to the implicit argument passed in methods.
Otherwise, the word
self has no special meaning in Python.Hence, the code in the question gives an error, because
self is not defined before use.I hope this helped!
@python_assets
@javascript_resources
For questions here is the Chat group link
https://t.me/+2KE896TMwHkxOWE1
For Resources aka PDfs and Ebooks group link
https://t.me/+eweUkdFwlho4YjRl
Join Python Channel
https://t.me/python_assets
https://t.me/+2KE896TMwHkxOWE1
For Resources aka PDfs and Ebooks group link
https://t.me/+eweUkdFwlho4YjRl
Join Python Channel
https://t.me/python_assets
Telegram
Webos
You’ve been invited to join this group on Telegram.
👍1
This media is not supported in your browser
VIEW IN TELEGRAM
Beginning Spring 6: From Beginner to Pro, 2nd Edition (2024)
By Andrew Lombardi
https://t.me/c/2109572262/973
By Andrew Lombardi
https://t.me/c/2109572262/973
👍1
https://t.me/c/2109572262/1000
python scikit and Boolean pdf
python scikit and Boolean pdf
https://t.me/c/2109572262/1012
Cracking the cod!nd interview
Cracking the cod!nd interview
Forwarded from Web Development CS JS Python JavaScript Hacking ReactJs Python django Flask CSS Frontend Backend Full Stack Java Node Pdf Books
CryptoZombies
CryptoZombies is an interactive school that teaches you all things technical about blockchains.
https://cryptozombies.io
CryptoZombies is an interactive school that teaches you all things technical about blockchains.
https://cryptozombies.io
cryptozombies.io
#1 Solidity Tutorial & Ethereum Blockchain Programming Course | CryptoZombies
CryptoZombies is The Most Popular, Interactive Solidity Tutorial That Will Help You Learn Blockchain Programming by Building Your Own Fun Game with Zombies — Master Blockchain Development with Web3, Infura, Metamask & Ethereum Smart Contracts and Become a…
👍1
Forwarded from Web Development CS JS Python JavaScript Hacking ReactJs Python django Flask CSS Frontend Backend Full Stack Java Node Pdf Books
Generative Art with JavaScript and SVG: Utilizing Scalable Vector Graphics and Algorithms for Creative Coding and Design (2024)
Pdf available on private channel
https://t.me/c/2109572262/1079
Pdf available on private channel
https://t.me/c/2109572262/1079