Monday, 13 January 2025

Create a CSV file by entering user-id and password, read and search the password for given user-id.

 #Program

import csv
def write():
    f=open("details.csv","w",newline='')
    wo=csv.writer(f)
    wo.writerow(["UserId","Password"])
    while True:
        u_id=input("Enter User-Id : ")
        pswd=input("Enter Password:")
        data=[u_id,pswd]
        wo.writerow(data)
        ch=input("Do you want to enter more records (Y/N) :")
        if ch in 'Nn':
            break

    f.close()

def read():
    f=open("details.csv","r")
    ro=csv.reader(f)
    for i in ro:
        print(i)
    f.close()
    
def search():
    f=open("details.csv","r")
    Found=0
    u=input("Enter user - id to search :")
    ro=csv.reader(f)
    next(ro)
    for i in ro:
        if i[0]==u:
            print(i[1])
            Found=1

    f.close()
    if Found==0:
        print("Sorry.....No record Found..")
    
    
write()
read()
search()


Output

















Tuesday, 10 September 2024

SQL-2



 Consider the tables Admin and Transport given below:

Table: ADMIN

Table: TRANSPORT







CREATE TABLE ADMIN(S_ID VARCHAR(5) PRIMARY KEY,S_NAME VARCHAR(10), ADDRESS VARCHAR(10), S_TYPE VARCHAR(15));






DESC ADMIN;








INSERT INTO ADMIN(S_ID,S_NAME,ADDRESS,S_TYPE)VALUES ('S001','SANDYA','ROHINI','DAY BOARDER');

INSERT INTO ADMIN(S_ID,S_NAME,ADDRESS,S_TYPE)VALUES('S002','VEDANSHI','ROTHAK','DAY SCHOLAR');

INSERT INTO ADMIN(S_ID,S_NAME,ADDRESS,S_TYPE)VALUES('S003','VIBHU','RAJ NAGAR','NULL');

INSERT INTO ADMIN(S_ID,S_NAME,ADDRESS,S_TYPE)VALUES('S004','ATHARVA','RAMPUR','DAY BOARDER');

SELECT * FROM ADMIN;







CREATE TABLE TRANSPORT(S_ID VARCHAR(5) PRIMARY KEY, BUS_NO VARCHAR(6), STOP_NAME VARCHAR(17));

DESC TRANSPORT;






INSERT INTO TRANSPORT(S_ID,BUS_NO,STOP_NAME)VALUES('S002','TSS10','SARAI KALE KHAN');

INSERT INTO TRANSPORT(S_ID,BUS_NO,STOP_NAME)VALUES('S004','TSS12','SAINIK VIHAR');

INSERT INTO TRANSPORT(S_ID,BUS_NO,STOP_NAME)VALUES('S005','TSS10','KAMLA NAGAR');

SELECT * FROM TRANSPORT;







Write SQL queries for the following:

(i)  Display the student name and their stop name from the table Admin and Transport.

Ans.   SELECT S_NAME,STOP_NAME FROM ADMIN,TRANSPORT WHERE ADMIN.S_ID=TRANSPORT.S_ID;






(ii) Display the number of students whose S_TYPE is not known.

Ans. SELECT COUNT(*) FROM ADMIN WHERE S_TYPE IS NULL;







(iii) Display all details of the students whose name starts with 'v',

Ans. SELECT * FROM ADMIN WHERE S_NAME LIKE 'V%';








(iv) Display student id and address in alphabetical order of student name, from the table Admin.

Ans. SELECT S_ID, ADDRESS FROM ADMIN ORDER BY S_NAME;







SQL-1

 create database CSIP;

us CSIP;

consider the table ORDERS given below and write the output of the SQL queries that follow


CREATE TABLE ORDERS(ORDNO INTEGER PRIMARY KEY, ITEM VARCHAR(12),QTY INTEGER, RATE INTEGER, ORDATE DATE);





DESC ORDERS;\






INSERT INTO ORDERS(ORDNO,ITEM,QTY,RATE,ORDATE) VALUES(1001,'RICE',23,120,'2023-09-10');

INSERT INTO ORDERS(ORDNO,ITEM,QTY,RATE,ORDATE) VALUES(1002,'PULSES',13,120,'2023-10-18');

INSERT INTO ORDERS(ORDNO,ITEM,QTY,RATE,ORDATE) VALUES(1003,'RICE',25,110,'2023-11-17');

INSERT INTO ORDERS(ORDNO,ITEM,QTY,RATE,ORDATE) VALUES(1004,'WHEAT',28,120,'2023-12-25');

INSERT INTO ORDERS(ORDNO,ITEM,QTY,RATE,ORDATE) VALUES(1005,'PULSES',16,110,'2024-01-15');

INSERT INTO ORDERS(ORDNO,ITEM,QTY,RATE,ORDATE) VALUES(1006,'WHEAT',27,55,'2024-04-15');

INSERT INTO ORDERS(ORDNO,ITEM,QTY,RATE,ORDATE) VALUES(1007,'WHEAT',25,60,'2024-04-30');


SELECT * FROM ORDERS;


(i) SELECT ITEM, SUM(QTY) FROM ORDERS GROUP BY ITEM;

Ans.


(ii) SELECT ITEM, QTY FROM ORDERS WHERE  ORDATE BETWEEN '2023-11-01' AND '2023-12-31';

Ans.






(iii) SELECT  ORDNO, ORDATE FROM ORDERS WHERE ITEM = 'WHEAT' AND RATE >=60;
Ans.














Sunday, 3 July 2022

Create a data frame for examination result and display row labels, column labels data types of each column and the dimensions.

 


















import pandas as pd

result_data= {

    'Eng':[90,85,72,69,86],

    'Phy':[85,82,73,56,96],

    'Chem':[88,65,70,36,35],

    'Maths':[90,56,45,36,42],

    'Comp Sci':[85,85,65,23,66],

    'Marks':[406,450,390,480,450],

    'Percentage':[96.5,85.2,48,79,68]

    }

result_df=pd.DataFrame(result_data,

        index=["Amit","Soham","Mohan","Neha","Sachin"])

print(result_df)

print(result_df.index)

print(result_df.column)

print(result_df.dtypes)

print(result_df.ndim)

print(result_df.size)

print(result_df.shape)

print(result_df.T)

Monday, 4 April 2022

12th IP Practical list 2024-25

 




Data Handling

1. Create a panda’s series from a dictionary of values and a ndarray: Click here (Reference video: Click Here)

 

2. Given a Series, print all the elements that are above the 75th percentile. Click here (Reference video Click Here)

 

3. Create a Data Frame quarterly sales where each row contains the item category, item name, and expenditure. Group the rows by the category and print the total expenditure per category.Click here  (Reference video: Click Here )

 

4. Create a data frame for examination result and display row labels, column labels data types of each column and the dimensions. Click Here

 

5. Filter out rows based on different criteria such as duplicate rows. click Here (Reference video: Click Here)

 

6. Importing and exporting data between pandas and CSV file.Click Here


7. Find the sum of each column with Lowest mean Click here (Reference Video: click here)

8. Locate the 3 largest values in a dataframe click Here (Reference video: click here)

9. Subtract the mean of row from each element of the row in a DataFrame: Click here (Reference video: click here)

10. Replace all negative values in a DataFrame with a 0. click here (Reference video: click here)

11. Replace all missing values in a DataFrame with a 999. Click Here  (Reference video:  click here)

______________________________________________

5.2 Visualization

1. Given the school result data, analyses the performance of the students on different parameters, e.g subject wise or class wise. Click Here

2. For the Data frames created above, analyze, and plot appropriate charts with title and legend.

3. Take data of your interest from an open source (e.g. data.gov.in), aggregate and summarize it. Then plot it using different plotting functions of the Matplotlib library. Click Here

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

5.3 Data Management

\c;

create database urname;

use urname;

1. Create a student table with the student id, name, and marks as attributes where the student id is the primary key.


2. Insert the details of a new student in the above table.

3. Delete the details of a student in the above table.










4. Use the select command to get the details of the students with marks more than 80.






5. Find the min, max, sum, and average of the marks in a student marks table.








6. Create a customer table with the customer ID, customer Name and country as attributes.








7. Insert the details of a new customer in the above table.










8. Find the total number of customers from each country in the table (customer ID, customer Name, country) using group by.







9. Write a SQL query to order the (student ID, marks) table in descending order of the marks.






10. SQL Queries:-1 .ONE TABLE Click Here 

11. SQL Queries:-2 – TWO TABLES. Click Here