We can use the type() function to figure out what class a variable or value belongs to. For example, type(" ") tells us that this is a string class. The only attribute in this case is the string value, but there are a bunch of methods associated with the class. We've seen the upper() method, which returns the string in all uppercase, as well as isnumeric() which returns a boolean telling us whether or not the string is a number. You can use the dir() function to print all the attributes and methods of an object. Each string is an instance of the string class, having the same methods of the parent class. Since the content of the string is different, the methods will return different values. You can also use the help() function on an object, which will return the documentation for the corresponding class. This will show all the methods for the class, along with parameters the methods receive, types of return values, and a description of the methods.
Christine Rafla
Email us at - techlaboffice77@gmail.com
On this page of the site you can watch the video online 50 Classes and Objects in Python | Python [ COMPLETE COURSE ] with a duration of hours minute second in good quality, which was uploaded by the user Tech Lab 21 August 2020, share the link with friends and acquaintances, this video has already been watched 46 times on youtube and it was liked by 0 viewers. Enjoy your viewing!