0% found this document useful (0 votes)
44 views2 pages

Ss

The document contains multiple Python code snippets demonstrating class inheritance, method overriding, and various functionalities such as list comprehensions and string manipulation. It illustrates how classes A and B interact, including the use of constructors and method definitions. Additionally, it showcases examples of using functions with variable arguments and manipulating object attributes.

Uploaded by

Krishnagopal Kar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views2 pages

Ss

The document contains multiple Python code snippets demonstrating class inheritance, method overriding, and various functionalities such as list comprehensions and string manipulation. It illustrates how classes A and B interact, including the use of constructors and method definitions. Additionally, it showcases examples of using functions with variable arguments and manipulating object attributes.

Uploaded by

Krishnagopal Kar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

class A:

def __init__(self):
self.calculate(30)
print('i-a',self.i)
def calculate(self,i):
self.i=i*2
class B(A):
def __init__(self):
super().__init__()
def calculate(self,i):
self.i=3*i
b=B()
------
for i in range(1,6):
if i%4==0:
print('x')
elif i%2==0:
print('x')
else:
print('xxxxx')
-----
class A:
def __init__(self):
self.calculate(30)
def calculate(self,i):
self.i=2*i
class B(A):
def __init__(self):
super().__init__()
print('i -B',self.i)
def calculate(self,i):
self.i=3*i
b=B()
-----------
class A:
def __init__(self,i=0):
self.i=i
class B(A):
def __init__(self,j=0):
self.j=j
def main():
b=B(50)
print(b.i)
print(b.j)

main()
---------
def country(*abc):
if len(abc)==1:
item=abc[0]
def f(obj):
return obj[item]
else:
def f(obj):
return tuple(obj[item] for item in abc)
return f
selection=[]
selection=country(slice(2,None))('AUSTRALIA')
print(selection)
----------
print([i**+1 for i in range(5)])
--------
class A:
def __init__(self,x):
self.x=x
a=A(100)
a.__dict__['y']=50
print(a.x+len(a.__dict__))
-------
str="example123"
print(str[::-1])
------
class A:
def __init__(self,i=1):
self.i=i
class B(A):
def __init__(self,j=2):
super().__init__()
self.j=j
def main():
b=B()
print(b.i,b.j)

main()
----------
x="abcdef"
i="i"
while i in x:
print(i,end="")
-------
class A:
def __init__(self,x):
self.x=x
x=44
a=A(4)
print(a.x)

You might also like