You are on page 1of 2

Set -1

Read a text file line by line and display each word separated by a ‘#’. 8 marks

file = open("C:\\Users\\saran\OneDrive\\Desktop\\exam cs\\readlines.txt", 'r')


lines = file.readlines ( )
print(lines)
for line in lines :
words = line.split( )
for word in words :
print(word+"#", end =" ")
file.close ( )

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


Table: Persons
Customer
Id Customer Name
Contact
Name City
Postal
code Country
1 Arun Madhu Berlin 12209 Germany
2 Abhilash Ana Trujillo
Mexico
D.F 5021 Mexico
i. Write a SQl Query to add a column named “DateOfBirth” should be of datatype
date in the“Persons” table.
ii. Write a SQl Query to display all the rows of Person table.
iii. Write a Sql Query to change the data type of the column named “DateOfBirth” in
the “Persons” table into year.
iv. Write a SQL Query to Sort Customer Name in Descending order

create database persons;

use persons;

create table persons(customerid varchar(30), customername varchar(30),contactname


varchar(30),city varchar(30),postalcode varchar(30),country varchar(30));

Alter table persons add dob date;

select * from persons;

alter table persons modify dob year;

select * from persons order by customername desc;

insert into persons value(1,'Arun','Madhu','Berlin',12209,'Germany',2006);

insert into persons value(2,'Abhilash','Ana Trujilla','Mexico


D.F',5021,'Mexico',2005);

You might also like