Professional Documents
Culture Documents
Set 4
Set 4
1)
Create a CSV file by entering user-id and password, read and search the password
for given user id.
import csv
#user -id and password list
List=[["user1", "password1"],
["user2", "password2"],
["user3", "password3"],
["user4", "password4"],
["user5", "password5"]]
#opening the file to write the records
f1=open("userInformation.csv","w",newline="\n")
# Here, you create a CSV writer object called writer associated with the file f1.
writer=csv.writer(f1)
writer.writerows(List)
f1.close()
#opening the file to read the records
f2=open("userInformation.csv","r")
rows=csv.reader(f2)
userId=input("Enter the user-id:" )
flag = True
for record in rows:
if record[0]== userId:
print("The password is:",record[1])
flag= False
break
if flag:
print("User-id not found")
2)
Write a SQL queries for (i) to (iv) 4 marks.
Table: Salary
Fname Lname Income
John Smith 30000
Franklin Wong 40000
joyce English 80000
Ramesh Narayan 3800
James Borg 55000
Jennifer Wallance 43000
Ahmad jabbar 25000
Alicia Zeala 25000
use lulu;
ii. Write a Sql Query to display whose income is more than 20000.
select Fname from salary where income>20000;