You are on page 1of 50

# GIET ENGINEERING COLLEGE

1(A)
*AIM::Write A Python program Using Print
Statement

PROGRAM::
n=("Akhila")
print("Name is:::",n)

OUTPUT::

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
1(B)
AIM:Write A Python Program Using Input Statement

PROGRAM:
amt=int(input("enter amount:::"))
if amt>10000:
disc=amt*0.10
print("Discount amount is::",disc)
else:
disc=amt*0.05
print("Discount amount is::",disc)
print("amount to be paid::",(amt-disc))

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE

OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
(3)
AIM:Write A Program To Print Even Number Or
Not(without using if statement)

PROGRAM:
x=int(input("Enter A Number::"))
while(x%2==0):
print(x,"Is A Even Number")
break
else:
print(x,"Is Not A Even Number")

OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
(4)
AIM:Write A Program To Print The Numbers from 0
To n(using while)

PROGRAM:
import random
n=int(input("Enter A Number::"))
while True:
for i in range(0,n+1):
print(i)
n=n-1
break

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
(5)
AIM:Write A Program To Print To Odd Numbers In A
Given Range(using for)

PROGRAM:

## n=int(input ("Enter Number::"))

for x in range(1,n+1):
if(x%2!=1):
continue
print("Odd Number Is::",x)

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
6(a)
AIM:Write A Program Using Break Statement

PROGRAM:
import random
min=int(input("Enter Minimum Value::"))
max=int(input("Enter Maximum Value::"))
while True:
dice=random.randrange(min,max)
print("Random Num Is::",dice)
if(Input()=='q'):
break
print("BYE")

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
6(B)
AIM::Write A Program Using Continue statement

PROGRAM:
sub=("Python","Ds","Cg","DLD","Rp","Mfcs")
for x in sub:
if(x=='Rp'):
continue
print("Name Of The Subject=",x)

OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
(7)
AIM:Write A Program For Parking Fee

PROGRAM:
a=0
b=0
c=0
q=0
tot=0
tot1=0
tot2=0
while True:
if(n==a):
h=int(input("Enter No.of Hours:"))
m=h*15

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
print("Parking Fee",m)
tot=tot+m
a=a+1
continue
if(n==b):
h=int(input("Enter No.of Hours:"))
l=h*5
print("Parking Fee",l)
tot1=tot1+l
b=b+1
continue
if(n==c):
h=int(input("Enter No.of Hours:"))
k=h*15
print("Parking Fee",k)
tot2=tot1+k

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
c=c+1
continue
if(n==q):

print("*************************************
**************************")
print("\t\t\t@@@PARKING RECORD@@@")
print("No.of Buses=",a)
print("No.of Bikes=",b)
print("NO.of Cars=",c)
print("Totol Parking Fee Collected For
Buses=",tot)
print("Totol Parking Fee Collected For
Bikes=",tot1)
print("Totol Parking Fee Collected For
Cars=",tot2)
print("TOTOL AMOUNT IS:::",tot+tot1+tot2)

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
break

OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
(8)
AIM:Write A Program To Announce Random Winner

PROGRAM:
import random
s="kumari ramu akhila teja".split()
print("WINNER
IS::",s[random.randrange(0,len(s)+1)])

OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
9(A)
AIM:Write A Program Using Keyword Arguments

PROGRAM:
def disp(n,m,c,p):
print("pin=",p)
print("name=",n)
print("contact=",c)
print("mail",m)
disp(m="sudha@gmail.com",n="akhila",c=9900887
7,p="515")
OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
9(B)
AIM:Write A Program Using Variable Argument

PROGRAM:
def disp(x,*y):
print(x)
print(y)
disp("Akhila Rani","Studying In GIET","With
Pin:17T91A0515")
OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
9(C)
AIM:Write A Program Using Default Arguments

PROGRAM:
def disp(name,course="Btech"):
print("Name Of The Student Is",name)
print("Course Of The Student Is",course)
disp("Akhila","Bsc")

OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE

(4)
AIM:Write A Program To Print The Numbers From 0
To n(using while statement )

PROGRAM:
import random
n=int(input("Enter A Number::"))
while True:
for i in range(0,n+1):
print(i)
n=n-1
PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:
GIET ENGINEERING COLLEGE
break

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE

OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
(11)
AIM:Write A Program Using Dictionary

PROGRAM:
cse={501:{"Name=":"Akhila","Email=":"akhila@.gma
il.com"},502:{"Name=":"Bhanu","Email=":"bhanu@.
gmail.com"}}
for i,j in cse.items():
print("Id=",i)
for key in j:
print(key,j[key])

OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
(12)
AIM:Write AProgram On Matrix Addition Using
Multi Insertion List

PROGRAM:
x=[[11,35,45],[5,34,23],[20,43,44]]
y=[[5,67,34],[45,34,23],[33,54,67]]
result=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(len(x)):
for j in range(len(x[0])):
result[i][j]=x[i][j]+y[i][j]
for r in result:
print(r)

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
13(A)
AIM:Write A Program Using Filtter Method

PROGRAM:
sub=["Python","Mfcs","Cg","Dld","Php","android","J
ava"]
def idsub(sub):
sub21=["Python","Mfcs","Cg","Dld"]
if(sub in sub21):
return True
else:
return False
subjects=filter(idsub,sub)
for i in subjects:
print(i)

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
13(B)
AIM:Write A Program Using Map Method

PROGRAM:
cse=["Python","Mfcs","Ds"]
def up(cse):
return cse.upper()
output=map(up,cse)
for i in output:
print(i)

OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
15
AIM:Write A Program On ATM Application

PROGRAM:
class bank:
def __init__(self):
print("Account Created")
def deposit(self):
m=int(input("Enter Amount to be created"))
self.balence=m
print("Balence=",self.balence)
def withdraw(self):
n=int(input("Enter amount to withdraw"))
p=int(input("Enter the pin number:"))
if(p==2132):
if(n>self.balence):

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
print("Insufficient fund")
else:
self.balence-=n
print("Availbel balence=",self.balence)
else:
print("Enter valid pin")
a=bank()
a.deposit()
a.withdraw()

OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
16(A)
AIM:Write A Program On Single Inheritance

PROGRAM:
import random
class A:
x=random.randrange(1,20)
class B(A):
def disp(self):
if(B.x%2==0):
print(B.x,"Is An Even Number")
else:
print(B.x,"Is An Odd Number")
b=B()
b.disp()

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
16(B)
AIM:Write A Program On Multilevel Inheritance

PROGRAM:
import random
class A:
x=random.randrange(1,20)
class B(A):
y=random.randrange(1,20)
class C(B):
def sum(self):
z=(c.x+c.y)
print(C.x,C.y)
print("Sum Of 2 Numbers Is =",z)

c=C()

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
c.sum()

OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
16(C)
AIM:Write A Program On Hierarical Inheritance

PROGRAM:
a=[]
global s
class A:
def marks(self):
s1=int(input("Enter s1 marks::"))
a.append(s1)
s2=int(input("Enter s2 marks::"))
a.append(s1)
s3=int(input("Enter s3 marks::"))
a.append(s3)
class B(A):
def sum_marks(self):

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
self.marks()
print("TOTOL MARKS=",sum(a))
class C(A):
def high_marks(self):
print("HIGHEST MARKS =",max(a))
b=B()
b.sum_marks()
c=C()
c.high_marks()

OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
20(A)
AIM:Write A Program On ZERODIVISIONEXCEPTION

PROGRAM:
x=10
y=0
try:
print(x/y)
except ZeroDivisionError:
print("Division Is Not Possible")
print("Bye")

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
20(B)
AIM:Write A Program On Multiple Exceptions

PROGRAM:
x=200
y=[1,15,36]
a=500
b=0
try:
print(x)
print(y[1])
print(a/b)
except ZeroDivisionError:
print("Division Is Not Possible")
except IndexError:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
except NameError:
print("Bye Exceptions")

OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
22
AIM:Write A Program On List Box

PROGRAM:

## from Tkinter import *

root=Tk()
def swap1():
s=l1.curselection()
x=l1.get(s)
l1.delete(s)
l2.insert(s,x)
def swap2():
s=l2.curselection()
x=l2.get(s)
l2.delete(s)

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
l1.insert(s,x)
l1=Listbox(root)
l1.insert(1,"PYTHON")
l1.insert(2,"CG")
l1.insert(3,"DLD")
l2=Listbox(root)
l2.insert(1,"MFCS")
l2.insert(2,"RP")
l2.insert(3,"DS")
b1=Button(root,text=">>>>",command=swap1)
b2=Button(root,text="<<<<",command=swap2)
l1.pack()
b1.pack()
b2.pack()
l2.pack()
root.mainloop()

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE
OUTPUT:

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

GIET ENGINEERING COLLEGE

## PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:

qwertyuiopasdfghjklzxcvbnmqwertyui
GIET ENGINEERING COLLEGE
opasdfghjklzxcvbnmqwertyuiopasdfgh
jklzxcvbnmqwertyuiopasdfghjklzxcvb
nmqwertyuiopasdfghjklzxcvbnmqwer
tyuiopasdfghjklzxcvbnmqwertyuiopas
GIET ENGINEERING COLLEGE

dfghjklzxcvbnmqwertyuiopasdfghjklzx
[Type the document subtitle]

cvbnmqwertyuiopasdfghjklzxcvbnmq
[Pick the date]

wertyuiopasdfghjklzxcvbnmqwertyuio
priya

pasdfghjklzxcvbnmqwertyuiopasdfghj
klzxcvbnmqwertyuiopasdfghjklzxcvbn
mqwertyuiopasdfghjklzxcvbnmqwerty
uiopasdfghjklzxcvbnmqwertyuiopasdf
ghjklzxcvbnmqwertyuiopasdfghjklzxc
vbnmqwertyuiopasdfghjklzxcvbnmrty
uiopasdfghjklzxcvbnmqwertyuiopasdf
ghjklzxcvbnmqwertyuiopasdfghjklzxc
PIN N0:17T91A0515 PYTHAN PROGRAMMING LAB PAGE N0:
GIET ENGINEERING COLLEGE