Thursday, January 28, 2021

python day26

 # -*- coding: utf-8 -*-

"""

Created on Thu Jan 28 21:45:09 2021

day 26

iterators 


@author: anil


flowers=("jasmin","marigold","lilli")

#print(type(flowers))


#iterators

#__iter__()

#iter()

#

'''

print(iter(flowers))

print(flowers[0])

print(flowers[1])

print(flowers[2])

'''


myiter=iter(flowers)

print(myiter)

"""


#flowers=("jasmin","marigold","lilli","malle","rose")

#print(type(flowers))


#iterators

#__iter__()

#iter()

#

'''

print(iter(flowers))

print(flowers[0])

print(flowers[1])

print(flowers[2])



myiter=iter(flowers)

#print(myiter)


print(next(myiter))

print(next(myiter))

print(next(myiter))

print(next(myiter))

print(next(myiter))





flowers=["jasmin","marigold","lilli","malle","rose"]

myiter=iter(flowers)

#print(myiter)


for i in range(5):

    print(next(myiter))



class numbers:

    def __iter__(self):

        self.a=1

        return self

    

    def __next__(self):

        x=self.a

        self.a=self.a+1

        return x

    


my_class=numbers()

myiter=iter(my_class)


print(next(myiter))

print(next(myiter))

print(next(myiter))

print(next(myiter))


#StopIteration(args)

'''



class numbers:

    def __iter__(self):

        self.a=1

        return self

    

    def __next__(self):

        if self.a<=30:

            x=self.a

            self.a=self.a+1

            return x

        else:

            raise StopIteration

    


my_class=numbers()

myiter=iter(my_class)



for i in range(30):

    print(next(myiter))



#StopIteration(args)

Friday, January 22, 2021

python day 25 docstring and variable, scope

 # -*- coding: utf-8 -*-

"""

Created on Sat Jan 23 06:45:14 2021

topic: classes doc string and variables



@author: anil



class father():

    '''This is the father class developed by praveen

    inside addition method is there

    inside sub method is there

    inside mul method is there

    inside div method is there

    '''

    def __init__(self):

        print("this is father class default constructor")

        help(type(self))

  

    

    

father()

print(father.__doc__)

help(father)


b=10


class father():

    '''This is the father class developed by praveen

    inside addition method is there

    inside sub method is there

    inside mul method is there

    inside div method is there

    '''

    global b

    

    def __init__(self):

        a = 10

        

        

        self.name="praveen"

        print(self.name)

        print(a)

        print(b)

    def display():

        

        print(b)

        


#father()

father.display()

#print(a)

"""

b=30

c=10


class father():

    

    global b

    

    def __init__(self):

        a = 10

        self.name="praveen"

        #print(self.name)

        #print(a)

        #print(b)

        b =20

        print(b)

        b=50


    def display():

       

        print(b,c)


father()

print("this is display method inside values")

father.display()

print("a",a)

#print(a)




python day 24 class super function 2

 # -*- coding: utf-8 -*-

"""

Created on Fri Jan 22 21:48:01 2021

day 24:classes


@author: anil durgam



class engine():

    def piston():

        print("piston")


class carbody(engine):

    engine.piston()

    def seats():

        print("seats")

        

       

carbody()





class engine():

    def __init__(self,name,lastname):

        self.name=name

        self.lastname=lastname

        #print(self.name)

        

    def piston(self):

        print(self.name,self.lastname)


class carbody(engine):

    def __init__(self):

        pass

    

    def seats(self):

        print("seats")

        

    

         

#carbody()

s=engine("raju","kumar")

s.piston()



class engine():

    def __init__(self,name,lastname):

        self.name=name

        self.lastname=lastname

        #print(self.name)

        

    def piston(self):

        print(self.name,self.lastname)


class carbody(engine):

    def __init__(self,name,lastname):

        engine.__init__(self,name,lastname)

       

    #def seats(self):

        #print(self.name,self.lastname)

        

    def seatbelt():

        print("This is seatbelt method")

               

class backseat():

    def backseats(self):

        print("back seat method is working")

        

    

         

x=carbody("honda","spender")

x.piston()

"""



class engine():

    def __init__(self,name,lastname):

        self.name=name

        self.lastname=lastname

        #print(self.name)

        

    def piston(self):

        print(self.name,self.lastname)


class carbody(engine):

    def __init__(self,name,lastname):

        super().__init__(name,lastname)

       

    #def seats(self):

        #print(self.name,self.lastname)

        

    def seatbelt():

        print("This is seatbelt method")

               

class backseat():

    def backseats(self):

        print("back seat method is working")

        

    

         

x=carbody("honda","spender")

x.piston()

Thursday, January 21, 2021

python day 23 topic classes with super function

 # -*- coding: utf-8 -*-

"""


 day 23:

topic : classes

@author: 



class employee():

    pass



employee()



class employee():

    #print("this is employee class")

    

    def __init__(self,s_no,name,sal):

        self.s_no = s_no

        self.name = name

        self.sal  = sal

        #print("inside constructor",a,b)

        

    def display(self):

        print("employee info ",self.s_no,self.name, self.sal )

        



s=employee(1,"venky",2000)

s.display()



class person():

    def __init__(self,name,):

        self.name=name

        

    def display(self):

        print("employee info ",self.name )

    

class employee(person):   

    

    def __init__(self,name):

        person.__init__(self,name)

        

    


a=employee("ram")

a.display()


"""


class person():

    def __init__(self,name,):

        self.name=name

        

    def display(self):

        print("employee info ",self.name )

    

class employee(person):   

    

    def __init__(self,name):

       super().__init__(name)

        

a=employee("ram")

a.display()


python day 22 topic classes

 # -*- coding: utf-8 -*-

"""

day 22: 

Topic : classes


@author: anil



class addition():

   def __init__(self,a,b):

       self.a=a

       self.b=b

       #print("self",self.a,self.b)

       

   def add(self):

       c= self.a + self.b

       print("self",self.a,self.b)

       return c

       

if __name__ == "__main__":

    

    a=addition(10,20)

    a.add()


class addition():

   def __init__(self,a,b):

       self.a=a

       self.b=b

       #print("self",self.a,self.b)

       

   def add(self):

       c= self.a + self.b

       print("self",self.a,self.b,c)

       return c

       

if __name__ == "__main__":

    

    a=addition(10,20)

    a.add()

    #print(addition(300,40))



class addition():

   def __init__(self,a,b):

       self.a=a

       self.b=b

       #print("self",self.a,self.b)

       

   def add(self):

       c= self.a + self.b

       print("self",self.a,self.b,c)

       return c

   

    

   def sub(self):

       c= self.a - self.b

       print("self",self.a,self.b,c)

       return c

       

if __name__ == "__main__":

    

    a=addition(10,20)

    a.sub()

    #print(addition(300,40))

  

class addition():

         

   def add(self):

      print("this is add method")

   

    

 

       

if __name__ == "__main__":

    

    a=addition()

    a.add()

    #print(addition(300,40))

   

class engine():

    #print("this is engine")

    def piston():

        print("piston")


class carbody():

    #print("this is carbody")

    def seats():

        print("seats")

         

      

    

engine.piston()

carbody.seats()

 

class engine():

    #print("this is engine")

    def piston():

        print("piston")


class carbody():

    #print("this is carbody")

    def seats():

        print("seats")

        

    engine.piston()

         

carbody.seats()

""" 

class engine():

    def __init__(self):

        print("this is engine")

    def piston():

        print("piston")


class carbody(engine):

    print("this is carbody")

    def seats():

        print("seats")

        

    

         

carbody()


Wednesday, January 20, 2021

python class 21 ...topic classes

 # -*- coding: utf-8 -*-

"""

python topic classes

@author: anil



from substraction import sub


def addition(a,b):

    return a+b


a=sub(10,5)

print(a)



class addition():

   def __init__(self):

       print("praveen is thopu")

    


addition()




class addition():

   def __init__(self):

       print("praveen is thopu")

       print("praveen is thopu")

       print("praveen is thopu")

       print("praveen is thopu")

       print("praveen is thopu")

       print("praveen is thopu")

       print("praveen is thopu")

    


addition()



class addition():

   def __init__(raju):

       print("praveen is thopu")

       print("praveen is thopu")

       print("praveen is thopu")

       print("praveen is thopu")

       print("praveen is thopu")

       print("praveen is thopu")

       print("praveen is thopu")

    


addition()


class addition():

   def __init__(self):

       a=10

       b=20

       c= a+b

       print(c)

    


addition(10,20)


class addition():

   def __init__(self):

       print("this is default constructor")

      

   def addition():

       #c= a+b

       #print(c)

       print("this is addition method")

       

   def sub():

       #c= a+b

       #print(c)

       print("this is sub method")

    


addition()

addition.addition()

addition.sub()

"""

class addition():

   def __init__(self):

       print("this is default constructor")

      

   def add(a,b):

       c= a+b

       print(c)

       #print("this is addition method")

       

   def sub(a,b):

       c= a-b

       print(c)

       #print("this is sub method")

    



addition.add(10,20)

#add(10,20)

python day 20 revision on all topics

 # -*- coding: utf-8 -*-

"""


 python day 20

@author: anil


for i in range(1,100,1):

     print(i)

     


fruits=["dragon","mango","apple"]

print(type(fruits))

print(fruits[0])

print(fruits[1])

print(fruits[2])




pra1={'key1':10,

      'key2':{'key3':23},

      

      }

print(type(pra1))

print(pra1['key2']['key3'])



def basha(a,b):

    #print("rajini is the boss",a+b)

    return a+b



if __name__ == "__main__":

    s=basha(3,4)

    print(s)


    s=basha(300,400)

    print(s)

    

"""

def basha(a,b,*s,**kw):

    return s


s=basha(4,5,7)

print(s)

    





     



Sunday, December 27, 2020

python day 19 classes

 # -*- coding: utf-8 -*-

"""

Created on Mon Dec 28 07:41:21 2020

day 19

topic : class


@author: anil durgam


class praveen():

    pass


praveen()



class praveen():

    print("praveen rocks!!!")


p=praveen()

print(p)


class praveen():

    print("praveen rocks!!!")

    print("praveen rocks!!!")

    print("praveen rocks!!!")

    print("praveen rocks!!!")

    print("praveen rocks!!!")

    print("praveen rocks!!!")

    print("praveen rocks!!!")

    


p=praveen()

print(p)


class praveen():

    x=10

    print(x)

    


p=praveen()

print(p)


class praveen():

    x=10

    #print(x)

    


p=praveen()

#print("printx ",p.x)

a=p.x

print("a",id(a))


z=praveen()

b=z.x

print("b=:",id(b))


class praveen():

    x=10

    #print(x)

    


p=praveen()

print("printx ",p.x)

p.x=20

print("printx ",p.x)


class praveen():

    x=10

    #print(x)

    


p=praveen()

print("printx ",p.x)

p.x=20

print("printx ",p.x)


p.x=500

print("printx ",p.x)


class student():

    name="rakesh"

    lastname="daggubati"

    a=10

    b=20

    c=30

    

p=student()

print(p.name)

print(p.lastname)

print(p.a)

print(p.b)

print(p.c)


class student():

    name="rakesh"

    lastname="daggubati"

    a=10

    b=20

    c=30

    

p=student()

print(id(p))

print(id(p.name))

print(id(p.lastname))

print(id(p.a))

print(id(p.b))

print(id(p.c))


class student():

    name="rakesh"

    lastname="daggubati"

    a=10

    b=20

    c=30

    

p=student()

print(type(p.name))

print(type(p.a))


class student():

    name="rakesh"

    lastname="daggubati"

    a=10

    b=20

    c=30

    

student()

print(student.a)

"""

class student():

    def __init__(self):

        name="rakesh"

        print(name)

    

    

student()

print(student)


    





Friday, December 25, 2020

python day 18 files

 # -*- coding: utf-8 -*-

"""

Created on Sat Dec 26 07:42:27 2020

 topic: files

@author: anil



f = open("file1.txt")

print(f)



f = open("file1.txt")

print(type(f))


f = open("day_17.py",'r')

print(f.read())


import os


f = open("day_17.py",'r')

print(f.read())




f = open("file1.txt", "r")

print(f.read(15))


f = open("file1.txt", "r")

print(f.readline())

f.close()


f = open("file1.txt", "r")

print(f.readline())

f.close()







f = open("file1.txt", "r")

print(f.read())


f = open("file1.txt", "a")

f.write("\nPraveen is thopu!!!!")


f = open("file1.txt", "r")

print(f.read())




f.close()



f = open("file1.txt", "r")

print(f.read())


f = open("file1.txt", "a")

f.write("\nPraveen is thopu!!!!")


f = open("file1.txt", "r")

print(f.read())






f = open("file5.txt", "a")

f.write("\nPraveen is thurum!!!!")

f = open("file5.txt", "a")

f.write("\nPraveen is thopu!!!!")


f = open("file5.txt", "r")

print(f.read())

f.close()



import os

os.remove("file5.txt")

"""

import os


file = "a.mp3"

os.system(file)


Wednesday, December 23, 2020

python day 17 lambda

 # -*- coding: utf-8 -*-

"""

Created on Thu Dec 24 07:39:48 2020

day:17

topic: lambda

@author: anil


def x_fn(a):

    print(a+10)

    

x_fn(25)



x = lambda a : a + 10


print(x(25))



lambda a : a + 10


a=lambda a : 5 + 10



print(a(5))




a=lambda a : a + 10


print(a(5))


a=lambda a : a + 10


print(a(5))




a=lambda a,b : a * b


print(a(5,6))


a=lambda a,b,c : (a * b)+c


print(a(5,6,7))



a=lambda a,b,c : (a * b * c)


print(a(5,6,7))





a=lambda a,b,c,d,e,f,g : a * b * c+d-e/f%g


print(a(5,6,7,5,5,5,5))



a=lambda a,b,c,d,e,f,g : a * b * c+d-e/f%g


print(a(5,6,7))



cars = ["Ford", "Volvo", "BMW"]

print(cars)

print(type(cars))



fruits = ['apple', 'banana', 'cherry']


x = fruits.index("cherry")


print(x)

x = fruits.index("banana")

print(x)



#pass by value 

#pass by reference


def BMW_function(a):

    print(a)

    

    

b=(15*120)

BMW_function(b)




def BMW_function(a):

    print(a)

    

    

b=10

BMW_function(15*150)

BMW_function(15*150)

BMW_function(15*120)

BMW_function(15*120)

BMW_function(15*120)

BMW_function(15*120)

BMW_function(15*120)



def BMW_function(a):

    print(a)

    

    

b=10*17*16*6237*73246*167*5454*12

BMW_function(b)

BMW_function(b)

BMW_function(b)

BMW_function(b)

BMW_function(b)

BMW_function(b)

BMW_function(b)





def BMW_function(a):

    print("a:",a)

    


print(a)


    


if __name__ == '__main__' :

    b=10

    BMW_function(b)

    print(b)

    


global a


def brother_function(b):

    print("a:",a)

    


def small_brother_function(c):

    print("a:",a)

    

def sister_function(d):

    print("a:",a)

    

    


if __name__ == '__main__' :

    a=10

    sister_function(a)

    small_brother_function(a)

    brother_function(a)

    print(a)

    

"""

global a


def brother_function(b):

    

    

   

    print("a:",a)

    


def small_brother_function(c):

    

    print("a:",a)

    

def sister_function(d):

    

    print("a:",a)

    

    


if __name__ == '__main__' :

    

    a=10

    sister_function(a)

    small_brother_function(a)

    brother_function(a)

    print(a)

    

    




















    

    


python class topic video