-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNotes.txt
41 lines (38 loc) · 2.3 KB
/
Notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
❤️DAY-16❤️
🌻 Object Oriented Programming🌻
In object oriented programming we are trying to model the real life objects and do things.
The things include
1, Attributes:- in general It describes about what it has.
2, Methods:- In general it is a function which tell about what an object does.
example:- class:- waiter, objects:- Preethi, chintu, yethish.
-> class names are defined in a way that each word starting with capital letter.(Pascal Case)
➡️Turtle Graphics
Turtle Documentation ----> 🔗https://docs.python.org/3/library/turtle.html
➡️prettytable -? A simple python package used to represent data into simple structure like table using ASCII format.
prettytable Documentation ----> 🔗https://code.google.com/archive/p/prettytable/wikis/Tutorial.wiki
❤️DAY-17❤️
📝->PascalCase:- all starting letters of a word in a class name is capitalized.
->camelCase:- The first letter is small and the subsequent starting words are capitalized.
->snake_case:- all words are separated by a underscore.
➡️#Creating a class
class classsName:
#content here if there is no content use pass keyword to avoid errors.
#Creating a object from the above class
obj = ClassName()
➡️Constructors
__init__:- It is a special method called everytime when an object is created and used to initialize the variables which are frequently used.
class User:
def __init__(self,name,f_name):
self.id = '97'
self.name = name
self.father_name = f_name
user_1 = User("Yethishwar","Surendhar Rao")
print(f"My name is {user_1.name}.\nMy father name is {user_1.father_name}.\nRoll no:- {user_1.id}")
__str__ :- This method in Python classes is primarily used to provide a human-readable string representation of an object. This makes it easier to understand the state and properties of the object when it is printed or converted to a string.
➡️Method inside the class
def method_name(self, parameters):
#Code here
user_1 = User().method_name() #MEthod is called successfully
❤️The self parameter is a reference to the current instance of the class, and is used to access variables that belongs to the class.
🔗https://www.youtube.com/watch?v=ZDa-Z5JzLYM&list=PL-osiE80TeTsqhIuOqKhwlXsIBIdSeYtc&ab_channel=CoreySchafer
👆Youtube Tutorial for better undersanding of OOPS