Prayagpython
Prayagpython
# 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)
'''
'''
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
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)
'''
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)
'''
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
'''
# 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)
'''
'''
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())
'''
'''
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)
'''
'''
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)
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)
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"
'''
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)
'''
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)
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()