Print: "I'm From Function1 "

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

6/26/2020 Untitled99 - Jupyter Notebook

In [7]: def f1 ():


print("i'm from function1 ")
f1()

i'm from function1

In [34]: class car:


car_model='Hundai'
car_m='maruti'

print(car.car_model)
obj1=car()
obj2=car()
print(f"output from obj:{obj1.car_model}")
print(car.car_model)

obj1 == obj2
obj1.car_model == obj2.car_model

print(car.car_m)

Hundai
output from obj:Hundai
Hundai
maruti

localhost:8888/notebooks/Untitled99.ipynb?kernel_name=python3 1/4
6/26/2020 Untitled99 - Jupyter Notebook

In [47]: class dbi:


db=['oracle', 'sql', 'mysql']
ports=(80,120,345)
user={'name1': 'user1', 'name2':'user2'}
dir(dbi)

Out[47]: ['__class__',
'__delattr__',
'__dict__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__le__',
'__lt__',
'__module__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__setattr__',
'__sizeof__',
'__str__',
'__subclasshook__',
'__weakref__',
'db',
'ports',
'user']

In [35]: def car():


global car_model
car_model='Hundai'
car()
print(car_model)

Hundai

In [48]: ports=(80,120,345)
type(ports)

Out[48]: tuple

localhost:8888/notebooks/Untitled99.ipynb?kernel_name=python3 2/4
6/26/2020 Untitled99 - Jupyter Notebook

In [50]: class dbi:


db=['oracle', 'sql', 'mysql']
ports=(80,120,345)
user={'name1': 'user1', 'name2':'user2'}
dir(dbi)

Out[50]: ['__class__',
'__delattr__',
'__dict__',
'__dir__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__gt__',
'__hash__',
'__init__',
'__init_subclass__',
'__le__',
'__lt__',
'__module__',
'__ne__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__setattr__',
'__sizeof__',
'__str__',
'__subclasshook__',
'__weakref__',
'db',
'ports',
'user']

localhost:8888/notebooks/Untitled99.ipynb?kernel_name=python3 3/4
6/26/2020 Untitled99 - Jupyter Notebook

In [59]: class dbi:


db=['oracle', 'sql', 'mysql']
ports=(80,120,345)
user={'name1': 'user1', 'name2':'user2'}

a=dbi.__dict__['ports'] ###oops method


b=dbi.ports
print(a)
print(b)

dbi.__dict__

(80, 120, 345)


(80, 120, 345)

Out[59]: mappingproxy({'__module__': '__main__',


'db': ['oracle', 'sql', 'mysql'],
'ports': (80, 120, 345),
'user': {'name1': 'user1', 'name2': 'user2'},
'__dict__': <attribute '__dict__' of 'dbi' objects>,
'__weakref__': <attribute '__weakref__' of 'dbi' objects>,
'__doc__': None})

localhost:8888/notebooks/Untitled99.ipynb?kernel_name=python3 4/4

You might also like