0% found this document useful (0 votes)
18 views11 pages

Assiment 1

The document outlines a series of tasks for creating and managing a College database using SQLite, including creating tables, inserting records, and displaying data. It also includes instructions for creating and manipulating CSV and text files, as well as using the Pandas library to create DataFrames from lists and dictionaries. Additionally, it covers tasks related to sales data management, including inserting records, exporting data to CSV, and plotting sales trends using Python.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views11 pages

Assiment 1

The document outlines a series of tasks for creating and managing a College database using SQLite, including creating tables, inserting records, and displaying data. It also includes instructions for creating and manipulating CSV and text files, as well as using the Pandas library to create DataFrames from lists and dictionaries. Additionally, it covers tasks related to sales data management, including inserting records, exporting data to CSV, and plotting sales trends using Python.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

1. Create College database and perform following tasks.

1. Create a database called College.

2. Establish connection with the database using SQLite code.

3. Create following table STAFF using SQLite and then close the connection.
STAFF(sid INTEGER Primary key, sname text(20), city text(20),age INTEGER)

4. Establish connection with the database COLLEGE.


5. Insert ten staff records using SQLite code for Staff table.

6. Display all records of the Staff table using cursor.

7. Extract name of staff, age and city name that are from Surat.
8. Using cursor, write Python code to display all staff from the table using fetchall() method.
9. Display first three records from the staff table using fetchone() method.

2. Write a Python code to create data file (CSV) file using CSV module:

1. Use open() method of the CSV module to create and open Staff.csv file in “w” mode. The
Staff.csv fill will contain (sid, sname, city, age) attributes.

2. Write a python code to store five records using writerow() method in CSV file. Make sure to add
first row containing the title of the attributes.
3. Write a python code to open the csv file in ‘r’ mode. (Read mode). Using reader() method
to display all records available from the data file using for loop.
3. Problem: Create Text file and store records in the text file using pipe ( | ) as separator. Tasks:

1. Create ‘Staff.txt’ file using W+ mode.

2. Insert five records consists of two attributes ( staff_id and Staff_name) using write() method. Close
the file at end.

3. Open the file in Read (‘r’) mode and read the file using read()method. Display the content of the
file using read() method. Close the file.

4. Open the file in Read (‘r’) mode and read the file using readline()method. Display the content
of the file using readline() method. Close the file.
4. Use of Dataframe and creating Dataframe from List, Dictionary and CSV file. (Use Pandas
library)

1. Create a list consists of ten names. Use the list to store the list elements in DataFrame.
Display the created dataframe.

2. Create DataFrame from Dictionary which is consists of lists. Create following dictionary
consists of three keys and each of them contain corresponding list of values.

3. d = {'Staff':['Meni', 'Krishi', 'Devaan', 'Dhyan'],


i. 'City':['Pune', 'Delhi', 'Surat',
'Houston'], 'Age':[22, 16, 5, 13]}
4. Store above dictionary in dataframe and display the created dataframe.
5. Create CSV file for Items selling for 6 months and add atleast 5 records for 5 different Items.

Item_name Jan Feb Mar Apr May Jun

Create Python script to perform following task.

1. Read data in Dataframe.

2. Add columns and calculate total_sell, average_sell.


3. Plot Total sell and average sell together on bar chart with proper Legends, titles and labels.

4. Explain final dataframe to csv named sell_analyasis.csv.

6. Sales (sid, year, totalsales)

Create above table into a SQLite database with appropriate constraints.


1. Insert at least 10 records into the sales table.

2. Export sales table data into sales.csv file.


3. Write a python scripts that read the sales.csv file and plot a line chart that shows totalsales of the
year. Also decorate the chart with appropriate title, lables, colours etc.

You might also like