0% found this document useful (0 votes)
6 views

CS Practical File

Uploaded by

marwansayeed123
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

CS Practical File

Uploaded by

marwansayeed123
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Practical file questions 18-25

-------------------------------------------------------------------------------------------------------------------------------------

Q18. Design a Python application that fetches all the records from Pet table of menagerie database.

import mysql.connector as a

mydb = a.connect(host="localhost",user="root",password="portal express", database = "menagerie")

cur = mydb.cursor()

run = "select * from PET "

cur . execute(run)

data = cur.fetchall()

for i in data :

print(i)

mydb.close()

Q19. Design a Python application that inserts the records in STUDENT table of MYDB database.

import mysql.connector as my

mydb = my.connect(host = "localhost", user = "root", password = "12345", database = "MYDB")

mycon = mydb.cursor()

name = input("Enter Name :-")

roll = input("Enter Roll :-")

class = input("Enter Class :-")

mycon.execute("INSERT INTO student VALUES ('{}', '{}', '{}',)".format (name, roll, class))

mydb.commit()

mydb.close()

Q20. Design a Python application that DELETE the record from STUDENT table of MYDB database.

import mysql.connector as my

mydb = my.connect(host = "localhost", user = "root", password = "12345", database = "mydb")

mycon = mydb.cursor()

roll = input("Enter Roll :-")

mycon.execute("DELETE from STUDENT where roll=('{}',)". format(roll))

mydb.commit()

mydb.close()

Q21. Design a Python application that UPDATES the record from STUDENT table of MYDB database.
import mysql.connector as my

mydb = my.connect(host = "localhost", user = "root", password = "12345", database = "mydb")

mycon = mydb.cursor()

name = input("Enter Name :-")

roll = input("Enter Roll :-")

class = input("Enter Class :-")

mycon.execute("UPDATE student set name='{}' class= '{}', where roll='{}', ".format (name, class, roll))

mydb.commit()

mydb.close()

Q-22.Design a Python application that fetches only those records from Student table of mydb
database where roll is 10.

import mysql.connector as a

mydb = a.connect(host="localhost",user="root",password="12345", database = "mydb")

cur = mydb.cursor()

run = "select * from Student where roll = 10 "

cur . execute(run)

data = cur.fetchall()

for i in data :

print(i)

mydb.close()

Q-23. Design a Python application to obtain a search criteria from user and then fetch records based
on that from empl table.

import mysql.connector

db_con = mysql.connector.connect(host = "localhost",user = "root", passwd = "fast",

database = "employeedb")

cursor = db_con.cursor()

search_criteria = input("Enter search criteria : ")

sql1 = "SELECT * FROM EMPL WHERE {}".format(search_criteria)

cursor.execute(sql1)

records = cursor.fetchall()

print("Fetched records:")

for record in records:


print(record)

db_con.close()

Q-24. Design a Python application to obtain a total rows from STUDENT table and fetch top 4 records
by using fetchmany() function.

import mysql.connector

db_con = mysql.connector.connect(host = "localhost",user = "root",passwd = "fast",database =


"SCHOOL")

cursor = db_con.cursor()

sql1 = "SELECT * FROM STUDENT”

cursor.execute(sql1)

records = cursor.fetchmany(4)

count=cursor.rowcount

print(“Total Number of Record:”,count)

print("Fetched records:")

for record in records:

print(record)

db_con.close()

Q-25 . Expertia Professional Global (EPG) is an online corporate training provider


company for IT related courses. The company is setting up their new campus in
Mumbai. You as a network expert have to study the physical locations of various
buildings and the number of computers to be installed. In the planning phase, provide
the best possible answers for the queries (i) to (iv) raised by them.

Building to Building Distance (in m) :

From To Distance

Admin. Building Finance Building 60

Admin. Building Faculty Studio Building 120

Finance Building Faculty Studio Building 70

Computers to be Installed in each Building :


Buildings Computers

Admin. Building 20

Finance Building 40

Faculty Studio Building 120

(i) Suggest the most appropriate building, where EPG should plan to install the server.

(ii) Suggest the most appropriate building cable layout to connect all three buildings for
efficient communication.

(iii) Which type of network out of the following is formed by connecting the computers
of the buildings?

1. LAN
2. MAN
3. WAN

(iv) Which wireless channel out of the following should be opted by EPG to connect to
students of all over the world ?

1. Infrared
2. Microwave
3. Satellite

Answer

(i) EPG should install the server in Faculty Studio Building as it houses the maximum
number of computers. Thus, it will reduce cable cost and keep maximum traffic local.

(ii) The most appropriate building cable layout to connect all three buildings for
efficient communication is given below:

Administrative Building - Finance Building - Faculty Studio Building

(iii) LAN network is formed as the distance between the three buildings is less than 1
km.

(iv) Satellite communication should be opted by EPG to connect to students of all over
the world.

You might also like