7 th lab programm
7 th lab programm
workbook = openpyxl.Workbook()
sheet = workbook.active
sheet['A1'] = "Name"
sheet['B1'] = "Age"
sheet['C1'] = "Fees"
# Data to be written
names = ["AKASH S", "AMOGH C", "AMRUTHA P", "B A SYED AFTAB", "CHANDANA L",
"CHANDU PRAKASH REDDY V S", "CHETHAN S", "DEEPTHI R", "G M THARUN", "GOWTHAM K
M"]
ages = [18, 20, 21, 23, 24, 19, 22, 18, 25, 26]
fees = [5000, 6000, 7000, 8000, 9000, 10000, 4000, 2000, 3000, 1000]
for i in range(len(names)):
workbook.save("ISE_and_Robotics.xlsx")
import openpyxl
import pandas as pd
workbook = openpyxl.load_workbook('ISE_and_Robotics.xlsx')
sheet = workbook.active
data = []
print(df.head(5))
________________________________________________________________________________
sheet.append(new_row)
workbook.save('ISE_and_Robotics.xlsx')
# Delete row
sheet.delete_rows(3)
workbook.save('ISE_and_Robotics.xlsx')
# Collect data from the 'Fees' column (assuming it's the 3rd column)
fees = []
fees.append(row[0])
# Aggregate Functions
total_sum = sum(fees)
min_value = min(fees)
max_value = max(fees)
# Print Results
9.Complex Class Demo Define a function which takes TWO objects representing complex numbers
and returns new complex number with a addition of two complex numbers. Define a suitable class
‘Complex’ to represent the complex number. Develop a program to read N (N >=2) complex numbers
and to compute the addition of N complex numbers. Objective:
• Define a suitable class ‘Complex’ to represent the complex number. Develop a program to read N
(N >=2) complex numbers and to compute the addition of N complex numbers. By two objects.
class Complex:
self.real = real
self.imag = imag
def read(self):
def show(self):
print(f"({self.real}) + i({self.imag})")
def main():
c.read()
for c in comp_list:
c.show()
sum_obj = Complex()
for c in comp_list:
sum_obj = sum_obj.add(c)
if __name__ == "__main__":
main()