0% found this document useful (0 votes)
58 views7 pages

Program@@ NW Xerox

The document contains a Python program to create lists, assign indexes, create a dictionary and perform operations on series and data frames. It also contains programs to handle exceptions, read and write files using with statement.

Uploaded by

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

Program@@ NW Xerox

The document contains a Python program to create lists, assign indexes, create a dictionary and perform operations on series and data frames. It also contains programs to handle exceptions, read and write files using with statement.

Uploaded by

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

Department of Computer Science and Engineering

GE3171 - Problem Solving and Python Programming Lab


Name:

PROGRAM:

print("***CREATE ALPHABET LIST***")


alphabets=[]
n=int(input("enter no. of elements: "))
for i in range(0,n):
alphabets.append(input("enter a alphabet: "))
print(alphabets)
print("***ASSIGN INDEX FOR ALPHABET LIST***")
index=[]
q=int(input("enter no. of elements: "))
for i in range(0,q):
index.append(input("enter a index value: "))
print(index)
print("***CREATE NUMERIC VALUES LIST***")
numeric_values=[]
m=int(input("enter no. of elements: "))
for i in range(0,m):
numeric_values.append(int(input("enter a numeric value: ")))
print(numeric_values)
print("***CREATE ANIMALS LIST***")
list_animals=[]
p=int(input("enter no. of elements: "))
for i in range(0,p):
list_animals.append(input("enter a animal: "))
print(list_animals)
print("***ASSIGNING DICTIONARY WITH 4 COLUMNS***")
data={"NAME":["PRIYA","DEVI","SAI"],
"MARK":[456,478,496],
"GROUP":["1ST","2ND","3RD"],
"SUB DIFF":["BIO","MATHS","COMPUTER SCI"]}
print(data)
import pandas as pd
x=pd.Series(alphabets)
print(x)
y=pd.Series(numeric_values,index)
print(y)
z=pd.Series
v=pd.DataFrame(data)
print(v)
s=pd.DataFrame(data,index=['p','q','r'])
print(s)

Page No.:
Department of Computer Science and Engineering
GE3171 - Problem Solving and Python Programming Lab
Name:

OUTPUT:

Page No.:
Department of Computer Science and Engineering
GE3171 - Problem Solving and Python Programming Lab
Name:

PROGRAM:

try:
a=int(input("enter a no. for a : "))
b=int(input("enter a no. for b : "))
c=a/b
except:
print("exception would occur")
else:
print("divsion of a and b :",c)

OUTPUT:

Page No.:
Department of Computer Science and Engineering
GE3171 - Problem Solving and Python Programming Lab
Name:

PROGRAM:

try:
age=int(input("enter the age : "))
if(age>=18):
print("eligible to vote")
else:
print("not eligible to vote")
except:
print("invalid input was given")

OUTPUT:

Page No.:
Department of Computer Science and Engineering
GE3171 - Problem Solving and Python Programming Lab
Name:

PROGRAM:

f=open("demo.txt","rt")
data=f.read()
words=data.split()
print(len(words))
f.close()

OUTPUT:

Page No.:
Department of Computer Science and Engineering
GE3171 - Problem Solving and Python Programming Lab
Name:

PROGRAM:

with open("in.txt") as f:
with open("out.txt","w") as f1:
for line in f:
f1.write(line)
f.close()

OUTPUT:

Page No.:
Department of Computer Science and Engineering
GE3171 - Problem Solving and Python Programming Lab
Name:

Page No.:

You might also like