Program@@ NW Xerox
Program@@ NW Xerox
PROGRAM:
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.: