You are on page 1of 2

SET 5

1. Write a Python script that inserts two records, each containing Roll_no, Name,
and
Marks, into a CSV file.

import pickle
file = open ("C:\\Users\\saran\\OneDrive\\Desktop\\exam cs\\4.txt", "wb+")
dic = { }
n = int (input ("Enter number of students : ") )
for key in range (n) :
roll_no = int (input ("Enter roll no") )
name = input ("Enter name : ")
marks = int (input ("Enter your marks : ") )
dic [roll_no] = { }
dic [roll_no] ["name"] = name
dic [roll_no] ["marks"] = marks
print(dic)
pickle. dump (dic, file)
file. close ( )

Write a SQL queries for (i) to (iv) 4 marks.


Table: Student
Slno Name Age
1 Smith 16
2 Wong 14
3 English 14
4 Narayan 15
5 Borg 16
6 Wallance 15
7 jabbar 17
8 Zeala 18

create database student;

use student;

create table student(Slno varchar(30),Name varchar(30),Age varchar(30));

insert into student value(1,'Smith',16);


insert into student value(2,'Wong',14);

insert into student value(3,'English',14);

insert into student value(4,'Narayan',15);

insert into student value(5,'Borg',16);

insert into student value(6,'Wallance'15);

insert into student value(7,'Jabbar',17);

insert into student value(8,'Zeala',18);

i. Write a SQL query to add column “class” and the Datatype is Varchar.
Alter table student add class varchar(30);

ii. Write SQL Query to display all the record in the table.
select * from student;

iii. Write a SQL Query to update Name as Ravi whose Sl.no is 2.


update student set name ="Ravi" where slno=2;

iv. Write a SQL Query to Drop the student table.


drop table student;

You might also like