0% found this document useful (0 votes)
11 views

Prayagpython

The document discusses various operations that can be performed on lists, tuples and sets in Python. It contains examples of creating, accessing, modifying and joining lists, tuples and sets. It also discusses common list, tuple and set methods like append, insert, remove, pop, sort, reverse, copy, join etc.

Uploaded by

guptaprayag931
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)
11 views

Prayagpython

The document discusses various operations that can be performed on lists, tuples and sets in Python. It contains examples of creating, accessing, modifying and joining lists, tuples and sets. It also discusses common list, tuple and set methods like append, insert, remove, pop, sort, reverse, copy, join etc.

Uploaded by

guptaprayag931
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/ 26

#

# List
'''
w=[10,20,30,40,50,60,70,80]
print(w)
'''
'''
li=["prayag","gupta","krishna","gupta","kapil","gupta"]
print(type(li))
print(li)

li=[10,20,30,40,50]
print(type(li))
print(li)

li=[10.89,67.2,20.20,10.80,80.5]
print(type(li))
print(li)

li=[10j,20j,30j,40j,50j]
print(type(li))
print(li)

li=["Ram",2+15,"Prayag",10j,10.5,50]
print(type(li))
print(li)
'''

# LIST ARE IN ORDER


'''
li=["prayag","krishna","kapil","Aditya","prince"]
print(li[0])
print(li[1])
print(li[2])
print(li[3])
print(li[4])
'''
# FROM LOOP
'''
li=["carrot","onion","cauliflower","cabbage","spinach","Bottle Gourd","Bitter
gourd"]
for x in li:
print(x)
'''
# shortcut from the loop
'''
li=["carrot","onion","cauliflower","cabbage","spinach","Bottle Gourd","Bitter
gourd"]
[print(x)for x in li]
'''

'''
li=["shiv","deepak","Surya","vikash","dany"]
for x in li:
print(x,"",end='')
print()
'''
'''
li=["shiv","shankar","Bholenath","Mahadev"]
for i in range(len(li)):
print(li[i],"",end="")
print()
'''
'''
li=["Kumkum","Kashish","Shivani","Purvi","shalini"]
i=0
while i<len(li):
print(li[i],"",end="")
i=i+1
'''
# LIST ARE CHANGEABLE
'''
li=["History","Geography","psychology","polity","IR"]
li[0]="current affairs"
print(li)
'''
'''
li=["History","Geography","psychology","polity","IR"]
for x in li:
print(x,"",end="")
print()
'''
# LIST ALLOW DUPLICATE VALUES
'''
LI=["SOCIOLOGY","BIOLOGY","PHYSICS","CHEMISTRY","PIB","BIOLOGY","SOCIOLOGY","PIB"]
print(LI)
'''
# RANGE VALUE FROM THE LIST
'''
li=["IN","Geography","include","HUMAN","ECONOMIC","PHYSICAL","AND","INDAIN
GEOGRAPHY"]
print(li[1:4])
print(li[1:])
print(li[-5:])
print(li[0:])
print(li[-4:-2])
print(li[-4:])
print(li[1:])
print(li[8:])
'''
# change the Range item From the list
'''
li=["History","Ancient History","Medivel History","Modern History"]
li[1:3]=[10,20]
print(li)
'''
# More Range Items
'''
li=["current Affairs","Read through","news
paper","Magazine","like","Yojana","krukshetra","PIB"]
li[1:5]=[10,20,30,40,50]
print(li)
'''
# Less range items
'''
li=["pooja","dooja","bhooja","chooja","kankhajura",'Dany']
li[1:2]=[6,7,8,9,10]
print(li)
'''
# we can insert an item using insert() method by the item index
'''
li=["pooja","dooja","kashvin","nachiketa","robin hood"]
li.insert(0,"Dany")
li.insert(1,100)
li.insert(6,600)
li.insert(-1,"Many")
print(li)
'''
# we can extend the list using extend method
'''

li=["C","C++","Python","Java","Javascript","core java","HTML"]
li2=[10,20,30,40,50,60]
li.extend(li2)
print(li)
'''
''''
# Add any Iterable like tuple or set
li=["carrot","onion","cauliflower","cabbage","spinach","Bottle Gourd","Bitter
gourd"]
tu=("kiwi","mango","Orange")
li.extend(tu)
print(li)
'''
''''
# Access list items using Append Method
li=["carrot","onion","cauliflower","cabbage","spinach","Bottle Gourd","Bitter
gourd"]
li.append("Ladyfinger")
print(li)
'''
# we can remove the item by using remove() method

# it takes single argument at a time


'''
li=["carrot","onion","cauliflower","cabbage","spinach","Bottle Gourd","Bitter
gourd"]
li.remove("cauliflower")
print(li)
'''
# we can remove an item using pop method
'''
li=["C","C++","Python","Java","Javascript","core java","HTML"]
li.pop()
print(li)
'''
# we can remoove an item by index using pop(index) method
'''
li=["pooja","dooja","rahul","nachiketa","sulekha","arspreet"]
li.pop(2)
print(li)
'''
'''
# we can remove an item by del keyword usind item index
li=["carrot","onion","cauliflower","cabbage","spinach","Bottle Gourd","Bitter
gourd"]
del li[0]
print(li)

li=["carrot","onion","cauliflower","cabbage","spinach","Bottle Gourd","Bitter
gourd"]
del li
'''
# we can delete using clear
'''
li=["pooja","dooja","kmlendra"," kuldeep","prayag"]
li.clear()
print(li)
'''
# copy items into the second list by filter
# Run only lasrt three items of the list
'''
li=["pooja","dooja","kmlendra"," kuldeep","prayag"]
li1=[]
for x in li:
if "p"in x:
li1.append(x)

print(li1)
'''
# Ascending order sort
'''
li=["pooja","Dooja","sooja"]
li.sort()
print(li)

li=[10,22,45,11,85,56,76,]
li.sort()
print(li)
'''
# descending order sort
'''
li=["chotu","sachin","golu","ankit","anurag"]
li.sort(key=str.lower)
print(li)
'''

# Descending order sort with reverse method


'''
li=["carrot","onion","cauliflower","cabbage","spinach","Bottle Gourd","Bitter
gourd"]
li.sort(reverse=True)
print(li)
li=[10.55,33,44,55,66,22,2.1,3,45,65]
li.sort(reverse=True)
print(li)

li=["carrot","onion","cauliflower","cabbage","spinach","Bottle Gourd","Bitter
gourd"]
li.reverse()
print(li)
'''
# copy the list items
'''
li=["C","C++","Python","Java","Javascript","core java","HTML"]
li1=li.copy()
print(li1)
'''
'''
# join two list using + sign
li=["C","C++","Python","Java","Javascript","core java","HTML"]
li1=[10,22,45,11,85,56,76]
li2=li+li1
print(li2)
'''
'''
#Multiply Tuple
li=(10,20,30,40,50)
li1=li*5
print(li1)
'''
# join the list using + operator or sign by Append method
'''
li=["C","C++","Python","Java","Javascript","core java","HTML"]
li1=[10,22,45,11,85,56,76,]
for x in li1:
li.append(x)
print(li)
'''
'''
# With Extend method
li=["carrot","onion","cauliflower","cabbage","spinach","Bottle Gourd","Bitter
gourd"]
li1=[10,20,30,40,50]
li.extend(li1)
print(li)
'''
# TUPLE
"""# creating tuple by constructor
tu=tuple(("prayag","kuldeep","kamlendra"))
for x in tu:
print(x)
"""
'''
# Tuple are in order
tu=tuple(("Rohan","aniket","shaharsh","Abhay","Jubair"))
print(tu[0])
print(tu[1])
print(tu[2])
print(tu[3])
print(tu[4])
'''
'''
tu=tuple(("prayag","kuldeep","kamlendra"))
print(tu)
'''
# tuple are in order by loop
'''
tu=tuple(("shiv","vishu","bramha","indra","surya","chandra"))
for x in tu:
print(x)
'''
# By while loop
'''
tu=tuple(("dog","cat","Bat","Rat","Fat","Set"))
i=0
while i<len(tu):
print(tu[i])
i+=1
'''
# Tuple are in oder with shortcut
'''
tu=tuple(("shiv","vishu","bramha","indra","surya","chandra"))
[print(x) for x in tu]
'''
# Tuple allow duplicate value
'''
tu=tuple(("suresh","Mahesh","dogesh","Mukesh","dogesh","Paresh"))
print(tu)
'''

#tuple contain different data types


'''
tu=(("carrot","onion","cauliflower","cabbage","spinach","Bottle Gourd","Bitter
gourd"))
tu1=((10,20,30,40,50))
tu2=((True,False,True ,False))
print(tu)
print(tu1)
print(tu2)
'''
'''
# Display hte item in range
tu=tuple(("shiv","vishu","bramha","indra","surya","chandra"))
print(tu[0:])
print(tu[1:4])
print(tu[1:])
print(tu[-1:])
print(tu[-6:])
print(tu[:2])
print(tu[:-2])
'''
# Find an item from the tuple
'''
tu=tuple(("shiv","vishnu","bramha","indra","surya","chandra"))
if "vishnu" in tu:
print("yes it is present")
else:
print("it is absent")
'''
'''
# Tuple are not changeable
tu=tuple(("shiv","vishu","bramha","indra","surya","chandra"))
tu[i]=200
print(tu)
'''
# IF we want to change the tuple first wehave to convert the truple into list
after after change list have tom convert into tuple
'''
tu=tuple(("shiv","vishu","bramha","indra","surya","chandra"))
li=list(tu)
li[1]="jadoo"
tu=tuple(li)
print(tu)
'''
'''
# when a tuple created called is packed
tu=tuple(("shiv","vishu","bramha","indra"))
[a,b,c,d]=tu
print("a=",a,"b=",b,"c=",c,"d=",d)

# when a tuple created called is unpacked


tu=tuple(("shiv","vishu","bramha","indra"))
[*a,b,c]=tu
print("a=",a,"b=",b,"c=",c)

tu=tuple(("shiv","vishu","bramha","indra"))
[a,*b,c]=tu
print("a=",a,"b=",b,"c=",c)
'''
#one tuple join eith oher using + sig
'''

tu=tuple(("shiv","vishu","bramha","indra","surya","chandra"))
tu1=(10,20,30,40)
tu2=tu+tu1
print(tu2)
'''
# count method
'''
tu=tuple(("shiv","vishu","bramha","indra","surya","chandra"))
tu.count(0)
print(tu)
'''
'''
tu=tuple(("shiv","vishu","bramha","indra","surya","chandra"))
tu.index()
print(tu)
'''
''''
tu=(20)
tu1=tu/5
print(tu1)
'''

# SET

# Set not allow duplicate value


'''
st={10,20,30,40,50,60,30}
print(type(st))
print(st)
st={"Apple","mango","Banana","Apple"}
print(st)
'''
# len() method get length of set
'''
st={"Apple","mango","Banana","Apple"}
print(len(st))
'''
# set not in order
'''
st={10,20,30,40,50}
print(st[0])
'''
'''
# set not changeable
st={10,20,30,40,50,40}
for x in st:
print(x)
'''

'''# set not changeable


st={10,20,30,40,50,30}
if 20 in st:
print("yes")
'''
'''
# Insert item into the set using insert method
st =set((10,20,30,40,50,60))
st.add(600)
print(st)
'''
'''
# update set ysing update method
st1=set((10,20,30,40,50))
st2={"harsh","dany","ashwin"}
st1.update(st2)
print(st1)
'''
'''
# Remove method use for remove item from the set
st2={"harsh","dany","ashwin"}
st2.remove("dany")
print(st2)
'''
'''
##discard() method also remove item feom the set
st2={"harsh","dany","ashwin"}
st2.discard("dany")
print(st2)
'''
'''
# by using pop remove items
st2={"harsh","dany","ashwin","Krishna","Gopal","mokey"}
st2.pop()
print(st2)
'''
'''
# clear metohd
st1={"nisha","surbhi","pooja"}
st1.clear()
print(st1)
'''
# del keyword
'''
st1={"nisha","surbhi","pooja"}
del st1
'''

'''
# join two set by union
st1={"nisha","surbhi","pooja"}
st2={"shobit","Anuj","ravi"}
st3=st1.union(st2)
print(st3)
'''
'''
# join two set with update method
st1={"nisha","surbhi","pooja"}
st2={"shobit","Anuj","ravi"}
st1.update(st2)
print(st1)
'''

# join two set usin intersectin update


'''
x={"nisha","surbhi","pooja"}
y={"shobit","Anuj","ravi"}
x.intersection_update(y)
print(x)
'''
'''
# pop() metohd remove an item from the list
st1={"nisha","surbhi","pooja"}
st2={"shobit","Anuj","ravi"}
st3=st1.intersection(st2)
print(st3)

# pop() metohd remove an item from the list


st1={"nisha","surbhi","pooja"}
st2={"shobit","Anuj","ravi"}
st1.symmetric_difference_update(st2)
print(st2)

# pop() metohd remove an item from the list


st1={"nisha","surbhi","pooja"}
st2={"shobit","Anuj","ravi"}
st3=st1.symmetric_difference(st2)
print(st3)
'''
# DICTIONARY
# Dictionaery are in order,changeable but it does not allow duplicate value

'''
di={
"Name":"Prayag Gupta",
"Age":20,
"Mob":9770968020
}
print(type(di))
print(di)
'''
'''
# Duplicate value not allow
di={
"Name":"Dany",
"Age":20,
"Mob":43954488,
"colour":["Blue","Green","White"],
"Age":45
}
print(type(di))
print(di)
'''
'''
# Access Dict Item

di={
'Name':"sumit",
"Age":21,
"Gender":"Male",
"colour":['Black','Blue','Green'],
"Age":23
}
print(type(di))
print(len(di))
'''
'''
di={
'Name':"sumit",
"Age":21,
"Gender":"Male",
"colour":['Black','Blue','Green'],
"Age":23
}
print(type(di))
print(len(di))
'''
'''
# Acccess dict items

di={
"Name":"Prayag Gupta",
"Age":20,
"nationality":"Indian",
"colour":["Red","Pink","Black"]
}
print(di["Name"], di["nationality"])
print(di["Age"])
print(di["colour"])
'''
'''
# Access itemusing get()

di={
"Name":"Rupesh",
"Age":20,
"Mob":977977977965,
"colour":["Gray","yellow","Orange"]
}
print(di.get("Name"))
print(di.get("Age"))
print(di.get("Mob"))
print(di.get("colour"))

'''
# only recieve key using key()
'''
di={
"Name":"kamlendra",
"Age":21,
"gender":"Male",
"Mob":7000630452,
"colour":["White","blue"],
"Nationality":"Indian"
}
print(di.values())
'''

# only recieve key using key()


'''
di={
"Name":"kamlendra",
"Age":21,
"gender":"Male",
"Mob":7000630452,
"colour":["White","blue"],
"Nationality":"Indian"
}
print(di.items())
'''
# we can modify dict value
'''
di={
"Name":"kamlendra",
"Age":21,
"gender":"Male",
"Mob":7000630452,
"colour":["White","blue"],
"Nationality":"Indian"
}
di["Name"]="Prayag gupta"
print(di)
'''
'''
# we can modify dict value
di={
"Name":"kamlendra",
"Age":21,
"gender":"Male",
"Mob":7000630452,
"colour":["White","blue"],
"Nationality":"Indian"
}
di["Name"]="Prayag gupta"
di["Nationality"]="Russian"
di["Age"]="20"
print(di)
'''
# Add new item into the dict
'''
di={
"Name":"kamlendra",
"Age":21,
"gender":"Male",
"Mob":7000630452,
"colour":["White","blue"],
"Nationality":"Indian"
}
di["salary"]=150000
di["Grade"]='A'
print(di)
'''
# we can update the item using update method

'''
di={
"Name":"kamlendra",
"Age":21,
"gender":"Male",
"Mob":7000630452,
"colour":["White","blue"],
"Nationality":"Indian"
}
di.update({"Name":"Prayag","Age":20})
print(di)
'''
# pop () use for remove the item with key name
'''
di={
"Name":"kamlendra",
"Age":21,
"gender":"Male",
"Mob":7000630452,
"colour":["White","blue"],
"Nationality":"Indian"
}
di.pop("Age")
di.pop("Name")
print(di)
'''
# pop () use for remove the item with key name
'''
di={
"Name":"kamlendra",
"Age":21,
"gender":"Male",
"Mob":7000630452,
"colour":["White","blue"]
}
di.popitem()
print(di)
'''
# del use for remove the item from the dictionary
'''
di={
"Name":"kamlendra",
"Age":21,
"gender":"Male",
"Mob":7000630452,
"colour":["White","blue"],
"Nationality":"Indian"
}
del di["Name"]
print(di)
'''

# del use for remove the item from the dictionary


'''
di={
"Name":"kamlendra",
"Age":21,
"gender":"Male",
"Mob":7000630452,
"colour":["White","blue"],
"Nationality":"Indian"
}
del di
'''
# d11el use for remove the item from the dictionary
'''
di={
"Name":"kamlendra",
"Age":21,
"gender":"Male",
"Mob":7000630452,
"colour":["White","blue"],
"Nationality":"Indian"
}
del di["gender"]
print(di)
'''
# clear () all item from the dict
'''
di={
"Name":"kamlendra",
"Age":21,
"gender":"Male",
"Mob":7000630452,
"colour":["White","blue"]
}
di.clear()
print(di)
'''
# using loop or keys

'''
di={
"Name":"kamlendra",
"Age":21,
"gender":"Male",
"Mob":7000630452,
"colour":["White","blue"]
}
for x in di.keys():
print(x)
'''
# for values
'''
di={
"Name":"kamlendra",
"Age":21,
"gender":"Male",
"Mob":7000630452,
"colour":["White","blue"]
}
for x in di.values():
print(x)
'''
'''
di={
"Name":"kamlendra",
"Age":21,
"gender":"Male",
"Mob":7000630452,
"colour":["White","blue"]
}
for x,y in di.items():
print("key=",x,"y=",y)
'''
# copy the dict items
'''
di={
"Name":"kamlendra",
"Age":21,
"gender":"Male",
"Mob":7000630452,
"colour":["White","blue"]
}
di1=di.copy()
print(di1)

# other way of cop dict

di={
"Name":"kamlendra",
"Age":21,
"gender":"Male",
"Mob":7000630452,
"colour":["White","blue"]
}
di1=dict(di)
print(di1)
'''
'''
# nested class
child1={
"Name":"Pappu",
"Father":"Kashvin"
}
child2={
"Name":"Rahul",
"Father":"Sumit"
}
child3={
"Name":"Surbhi",
"Father":"Vikas"
}

family={
"Child1":child1,
"Child2":child2,
"Child3":child3,
}
print(family["Child1"]["Father"])
print(family["Child2"]["Father"])
print(family["Child3"]["Father"])
'''
# string
'''
name="Prayag"
print(name)

name= "prayag gupta belongs to umaria"


print(name)
'''
'''
# string through indexing
name="sumit Mishra also Belongs to umaria"
print(name[0])
print(name[1])
print(name[2])
print(name[3])
print(name[4])
'''
'''
# through loop
name="kuldeep Bhaiya Belongs to Sihora"
for x in name:
print(x)
'''
''''
name="kuldeep Bhaiya"

if "Bhaiya" in name:
print("Yes it is present")
else:
print("Absent")
'''
'''
name="kuldeep Bhaiya"
print(name[0:])
print(name[0:10])
print(name[-14:-0])
print(name[:-7])
print(name[:10])
'''
# replace String
'''
name="hello How Are You"
print(name.replace("You","Hello"))
'''
'''
# Splitting of string
name="How Was your Day going"
print(name.split("o"))
print(name.split("D"))
'''
# THIS SHOW THE VALUE DATA TYPES
'''
a=10
print(isinstance(a,int))
'''
'''
b="sumit"
print(isinstance(b,str))
'''
'''
# join twom string
kname="kuldeep Shrama"
pname="\nPrayag Gupta"
gname=kname+pname
print(gname)
'''
'''
# Format String
name="prayag"
Age="20"
Qualification="Graduation"

Gupta="My name is {} Age is {} Qualification is {}"


print(Gupta.format(name,Age,Qualification))
'''
'''
name="Kuldeep Bhaiya"
Age="21"
Qualification="BSC"

des="My name is {2} Age is {0} Qualificatin is {1} "


print(des.format(name,Age,Qualification,))
'''
#
#Enter a number to find it s prime or not

'''
def prime(x):
i=2
while i<x:
if x%i==0:
return (False)
i+=1
return (True)
num=int(input("Enter A number="))

if prime(num):
print("yes it is prime number")
else:
print("No")
'''
# Short hand if
'''
a=50
b=20
if a>b:print("a is greater than b")
'''
'''
# short hand else if

a=90
b=40
print("A")if a<b else print("sorry")
'''
# short hand if else if else
'''
a=50000
b=5000
print("A")if a>b else print("=") if a==b else print("B")
'''
# And Statement
'''
a=200
b=30
c=500
if a>b and c>a:
print("Both the Conditions are True")
'''
# Pass Statement
'''
a=50
b=250
if a>b:
pass
print("Sorry Shaktiman")
'''
# break Statement
'''
i=1
while i<=10:
if i==5:
break
print(i)
i+=1
'''
# Continue Statement
'''
i=1
while i<=10:
if i==5:
continue
print(i)
i+=1
'''
# Else Statement
'''
i=1
while i<=10:
print(i)
i+=1
else:
print("Program is Closed")
'''
# Else From loop
'''
for i in range(10):
print(i)
else:
print("program closed")
'''
# Or Statement
'''
a=2000
b=500
c=5000
if a>b or a>c:
print("At least one condition is true")
'''
# Function
'''
def sum(): # function Defition
print("Kuldeep Bhaiya")
print("Prayag Gupta")
print("kamlendra Singh")
sum()
'''
'''
def sum(a,b,c): # function With Argument
d=a+b+c
print("d=",d)
sum("parayag","kuldeep","kamlendra")
'''
'''
def sum(a,b,c): # function With Argument
d=a+b+c
print("d=",d)
sum(20,30,40)
'''
'''
def sum(a,b,c): # function With Argument
d=a*b*c
print("d=",d)
sum(20,3,4)
'''

'''
def sum(a,b,c):# functin with argument with retun value
z=a+b+c
return z
W=sum("sodhi\n","jetha\n","bhide")
print("Returned Value Printed=",W)
'''
'''
def sum(a=10,b=20,c=30):# function with Default argument
z=a+b+c
return z

w=sum()
print("Returned Value Printed=",w)
w=sum(100)
print("Returned Value Printed=",w)
w=sum(100,200)
print("Returned Value Printed=",w)
w=sum(100,200,300)
print("Returned Value Printed=",w)
'''
'''
def sum(a=200,b=300,c=600):
x=a+b+c
return x
q=sum()
print("Returned Value Printed=",q)
q=sum(800,90)
print("Returned Value Printed=",q)
q=sum(50,50,50)
print("Returned Value Printed=",q)
'''
'''
def sum(a,b,c=5000): # also shows this type
z=a+b+c
return z
G=sum(300,250)
print("Returned Value Printed",G)
'''
# functin with default argument
'''
def sum(*b):
z=b[0]+b[1]+b[3]+b[3]+b[4]
return z
X=sum(2000,2000,2000,2000,2000)
print("Returned Value Printed=",X)
'''
#through loop
'''
def sum(*P):
z=0
for x in P:
z+=x
return z
R=sum(1,2,3,4,5)
print("Returned Value Printed=",R)
'''
'''
# for string use two astrisk Sign
def sum(**M):
z=M["Name"]+""+M["Sname"]
return z
X=sum(Name="paryag ",Sname="Gupta")
print("Returned Value Printed=",X)
'''
'''
def sum(*P):
z=0
i=0
while i<len(P):
z+=P[i]
i+=1
return z
X=sum(10,20,30,40,50)
print("Returned Value Printed=",X)
'''
'''
import numpy
a=numpy.array([1,2,3,4,5])

print(a[0]," ",end='')
print(a[1]," ",end='')
print(a[2]," ",end='')
print(a[3]," ",end='')
print(a[4]," ",end='')

for x in a:
print(x)
'''
'''
import numpy as np

a=np.array([10,20,30,40,50])
print(a[0]," ",end="")
print(a[1]," ",end="")
print(a[2]," ",end="")
print(a[3]," ",end="")
print(a[4]," ",end="")

for x in a:
print(x)

'''
# Class
'''
class Employee:
name="prayag"
Age=20

object=Employee()
print("name=",object.name,"Age",object.Age)

class pen:
company="Pentonic22
Price=
colour="Blue"

Book=pen()
print("company",Book.company,"price",Book.Price,"colour",Book.colour)

class car:
Brand="Toyota"
price=10000000

b=car()
print("Brand",b.Brand,"price",b.price)

class laptop:
Modelno=1234567
lprice=65000
lcompany="HP"

dell=laptop()
print("Modelno",dell.Modelno,"\n","Lprice",dell.lprice)
print("Lcompany",dell.lcompany)

class Room:
length="20 feet"
breadth="40 feet"
h=Room()
print("Length",h.length,"\n","Breadth",h.breadth)

class keyboard:
Button=104
keyboard_price=700
A=keyboard()
print("Button",A.Button,"\n","keyboard price",A.keyboard_price)

class key:
key_number=101
key_price=100

k=key()
print("Key Number",k.key_number,"\n","Key Price",k.key_price)
'''
'''
class phone:
def __init__(self,ph,pp,pr):
self.Phone_name=ph
self.Phone_price=pp
self.Phone_Ram=pr
def show(self):
print("Phone Name=",self.Phone_name)
print("Phone Price=",self.Phone_price)
print("Phone Ram=",self.Phone_Ram)
A=phone("Realme",22000,"8gb")
A.show()

class water:
def __init__(self,qot,olp):
self.Quantity_on_Earth=qot
self.one_Litter_price=olp
def show(self):
print("Quantity Of Water on Earth=",self.Quantity_on_Earth)
print("Price of one Litter water=",self.one_Litter_price)

Earth=water("2.4 percent",20)
Earth.show()

class Family:
def __init__(self,fm,Nn):
self.fmembers=fm
self.Nname=Nn
def show(self):
print("family Members=",self.fmembers)
print("Nickname=",self.Nname)
R=Family(5,"Cute Family")
R.show()

class TV:
def __init__(colour,tc,tp):
colour.TV_Company=tc
colour.TV_price=tp
def show(Glass):
print("TV company=",Glass.TV_Company)
print("TV price=",Glass.TV_price)
D=TV("Sony",100000)
D.show()

class book:
def get(self,bn,bp):
self.Book_name=bn
self.Book_price=bp
def show(self):
print("Book Name",self.Book_name,"\n","Book Price",self.Book_price)

object=book()
object.get("Psychology of Mind",380)
object.show()
'''
# Add Two Time
'''

class Time:
def __init__(self,h,m):
self.hours=h
self.minuts=m
def show(self):
print("Hours",self.hours,"Minuts",self.minuts)
def sum(self,B1):
temp=Time(0,0)
if _name_=='__main__':
temp.minuts=self.minuts+B1.minuts
temp.hours=temp.minuts//60
temp.hours=temp.minuts%60
temp.hours=temp.hours+self.hours+B1.hours
return temp
A=Time(2,30)
B=Time(3,30)

print("\n A object Value")


A.show()
print("\n B object Value")
B.show()
c=Time(0,0);
c.show(B);
C.show()
'''

'''
class Time:
def __init__(self,h,m):
self.hours=h
self.minuts=m
def show(self):
print("Hours=>",self.hours,"Minuts=>",self.minuts)

class work(Time):
pass
A=work(3,30)
A.show()
'''
'''
class student:
def __init__(self,sn,sa):
self.Sname=sn
self.Sage=sa
def show(self):
print("student Name=>",self.Sname,"\n","Student Age=>",self.Sage)

class Teacher(student):
pass
A=Teacher("Sunny Singh",20)
A.show()

'''
'''
class car:
def __init__(self,cc,cp,cm):
self.Carcompany=cc
self.Carprice=cp
self.Car_modelno=cm
def show(self):
print("Car Company->",self.Carcompany)
print("Car Price->",self.Carprice)
print("Car Model Number->",self.Car_modelno)

class Bike(car):
pass

Wheel=car("rolls Royce",1000000.90,100110)
Wheel.show()
'''
'''
class Animal:
def __init__(self,Ab,An):
self.Animal_breed=Ab
self.Animal_Name=An
def show(self):
print("Breed of Animal is=",self.Animal_breed)
print("Name of Animal is=",self.Animal_Name)

class Bird(Animal):
pass
b=Bird("German","Dog")
b.show()
'''
'''
class Mobile:
def __init__(self,Mc,Mp):
self.Mobile_Company=Mc
self.Mobile_price=Mp
def show(self):
print("Company of Mobile is=",self.Mobile_Company)
print("Price of Mobile is=",self.Mobile_price)
class Laptop(Mobile):
pass
oppo=Laptop("Apple",10000000)
oppo.show()
'''
'''
class dept:
def __init__(self,Dn,Dc):
self.Dname=Dn
self.Dcode=Dc
def show(self):
print("Department Name-->",self.Dname)
print("Department Code-->",self.Dcode)
class info(dept):
pass
A=info("Defence Research Development organiisation (DRDO)",1234567)
A.show()
'''
'''
class Teacher:
def __init__(self,tn,ta,tg,ts):
self.Tname=tn
self.Tage=ta
self.tgender=tg
self.tsalary=ts
def show(self):
print("Name of teacher is=",self.Tname)
print("Age of Teacher is=",self.Tage)
print("Gender of Teaher is=",self.tgender)
print("Monthly Salary of teacher is=",self.tsalary)
class pen(Teacher):
pass
A=pen("Sushmita",34,"Female",1100000)
A.show()
'''
'''
class Time:
def __init__(self,h,m):
self.Hours=h
self.Minuts=m
def show(self):
print("Hours=",self.Hours)
print("Minuts=",self.Minuts)

class work(Time):
def __init__(self,h,m,ec,en):
Time.__init__(self,h,m)
self.Employeecode=ec
self.Ename=en
def showwork(self):
print("Employeecode",self.Employeecode,"Employeename",self.Ename)
A=work(2,30,101,"Rubina")
A.showwork()
A.show()
'''
'''
class Teacher:
def __init__(self,tn,tq):
self.Tname=tn
self.tqualification=tq
def show(self):
print("Name of teacher Is=",self.Tname)
print("Qualification of Teaher",self.tqualification)

class student(Teacher):
def __init__(self,tn,tq,sn,sh):
Teacher.__init__(self,tn,tq)
self.sname=sn
self.shobby=sh
def showstudent(self):
print("Student name=",self.sname)
print("Student Hobby=",self.shobby)

A=student("Sumit Pasi","Ph.d in Psychology","jhon","Cricket")


A.showstudent()
A.show()
'''
'''
class car:
def __init__(self,cn,cp):
self.cname=cn
self.cprice=cp
def show(self):
print("Name of Car is=",self.cname)
print("Price of Car is=",self.cprice)
class bike(car):
def __init__(self,cn,cp,bc,bp):
car.__init__(self,cn,cp)
self.bcompany=bc
self.bprice=bp
def showbike(self):
print("Bike Company is=",self.bcompany)
print("Bike price is=",self.bprice)
B=bike("Lambhorgini",8999,"Royal Enfield Hunter",9000)
B.showbike()
B.show()
'''
class Dept:
def _init_(self,dn,phone):
self.Dname=dn
self.Phone=phone
def showdept(self):
print('Department Name=',self.Dname," Department Phone=",self.Phone)
class Time:
def _init_(self,h,m):
self.Hours=h
self.Minuts=m
def show(self):
print("Hours=>",self.Hours," Minuts=>",self.Minuts)

class Work(Time,Dept):
def _init_(self,h,m,ec,en,dn,phone):
Time._init_(self,h,m)
Dept._init_(self,dn,phone)
self.Employeecode=ec
self.Ename=en
def showwork(self):
print("Employee Code=",self.Employeecode," Employee Name=",self.Ename)

A=Work(10,45,105,"Nachiketa","Income",898977)
A.showwork()
A.showdept()
A.show()

You might also like