inputfile = open('input.
txt', 'r')
outputfile = open('[Link]', 'w')
lines = [Link]()
print('Number of lines in the file is:', len(lines))
cleanedlines = []
for line in lines:
line = [Link]()
[Link](line)
[Link]()
for line in cleanedlines:
[Link](line + '\n')
def DIVEXP(a, b):
assert a > 0, "a should be greater than 0"
try:
c = a / b
except ZeroDivisionError:
print('HandledzeroDivisionError')
return c
print(DIVEXP(1, 2))
print(DIVEXP(-10, 3))
print(DIVEXP(5, 0))
print(DIVEXP(15, 3))
import zipfile
import os
file_path = [ ]
directory = 'C:\\jnnce'
for root, directories, files in [Link](directory):
for filename in files:
filepath = [Link](root, filename)
file_path.append(filepath)
zipobject = [Link]('C:\\[Link]','w')
for file in file_paths:
[Link](file)
[Link]()
print('All files zipped successfully')
class complex:
def __init__(self, r=0, i=0):
[Link] = r
[Link] = i
def input(self):
[Link] = int(input('Enter the real num: '))
[Link] = int(input('Enter the imag num: '))
def display(self):
print([Link], "+", [Link], "i", sep='')
def addcomplex(self, c1, c2):
c3 = complex()
[Link] = [Link] + [Link]
[Link] = [Link] + [Link]
return c3
o1 = complex(1, 2)
o2 = complex(3, 4)
o3 = complex()
o3 = [Link](o1, o2)
[Link]()
compobj = []
sum = complex()
n = int(input('Enter number of objects: '))
for i in range(n):
ob = complex()
print('Enter complex number', i + 1)
[Link]()
[Link](ob)
for i in range(n):
[Link] = [Link] + compobj[i].real
[Link] = [Link] + compobj[i].imag
print('Complex numbers are:')
for i in range(n):
compobj[i].display()
print('Sum of complex numbers is:')
[Link]()
class student:
def __init__(self, name = '', usn = '', marks = [0,0,0,0]):
[Link] = name
[Link] = usn
[Link] = marks
def getmarks(self):
print('enter details of student')
[Link] = input('enter student name:')
[Link] = input('enter student USN:')
[Link][0] = int(input('enter Python marks:'))
[Link][1] = int(input('enter Java marks:'))
[Link][2] = int(input('enter Com AT marks:'))
def display(self):
[Link][3] = [Link][0] + [Link][1] + [Link][2]
print('Student details are:')
print('Student name:', [Link])
print('Student USN:', [Link])
print('Python marks:', [Link][0])
print('Java marks:', [Link][1])
print('Com AT marks:', [Link][2])
print('Percentage:', [Link][3] / 3)
s = student()
[Link]()
[Link]()