-
Notifications
You must be signed in to change notification settings - Fork 0
/
python_class&function_topic.py
48 lines (26 loc) · 1.1 KB
/
python_class&function_topic.py
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
42
43
44
45
46
47
48
print('\\\\\\--CLASS CREATION AND FUNCUTION CREATION--\\\\\\')
print('CREATING CLASS')
class class1:
def __init__(self,name,age):
self.peru=name
self.vayasu=age
def __str__(self):
return f"{self.peru}({self.vayasu})"
x=class1('BOBBY',20)
print('output coming because of __str__ function in class :',x)
print('output coming after arguments passed with var x & printing name :',x.peru)
print('printing name and age by giving values in print statement :',class1('CHARAN',20).peru)
class class2:
def jan26():
ans=input('s to run,other then s to stop : ')
while ans=='s':
if ans=='s':
name=input('give name : ')
print('printing name and age by giving values in print statement :',class1(name,19).peru)
ans=input('s to run,other then s to stop : ')
return 'printed cuz answer is no , and came out of loop'
joiner=class2.jan26()
print(joiner)
cls1=class1('platinum',1119)
print(cls1)
print('WE CAN MODIFY/DELECT THE OBJECT PROPERTIES AND PASS STATEMENTS')