




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Important for exams as well as future in computer science
Typology: Exams
1 / 144
This page cannot be seen from the preview
Don't miss anything!





























































































क्षेत्रीय कायाालय , जम्मू , नज़दीक राजकीय विककत्सालय , गााँधी नगर
जम्मू - 180004
Regional Office, Jammu, Near Govt. Hospital,
Gandhi Nagar, Jammu- 180004
General Instructions:
Section A 1 Write full form of CSV. 1 2 Which is valid keyword? a. Int b. WHILE c.While d.if
3 Which of the following is not a valid identifier name in Python? a) 5Total b) _Radius c) pie d)While
4 Consider the following expression: 51+4-3**3//19- Which of the following will be the correct output if the expression is evaluated? a. 50 b. 51 c. 52 d. 53
5 Select the correct output of the code: Str=“Computer” Str=Str[-4:] print(Str*2) a. uter b. uterretu c. uteruter d. None of these
6 Which module is imported for working with CSV files in Python? a. csv b. python-csv connector c. CSV d. python.csvconnector
7 Fill in the blank: _____ command is used to update records in the MySQL table. (a) ALTER (b) UPDATE (c) MODIFY (d) SELECT
8 Which command used to fetch rows from the table in database? (a) BRING (b) FETCH (c) GET (d) SELECT
9 Which of the following statement(s) would give an error after executing the following code? print(9/2) # Statement- print(9//2) # Statement-
x=*- 1 print "Number made positive:"x execmain() 20 Write two advantages of star topology and bus topology each.
OR
Briefly explain HTML and HTTP.
21 a. Find output generated by the following code: mystr = “Hello I am a Human.” print(mystr[::-3])
b. Write the output of the code given below: p= q= p=q// p=q* q+=p print(p,q)
22 Differentiate between DDL and DML with one Example each. 2 23 a. Give the full form of the following: i. URL ii. FTP
b. What is the use of HTTP?
24 Predict the output of the following code:
def CALLME(n1=1,n2=2): n1=n1*n n2+= print(n1,n2) CALLME() CALLME(3)
OR
mylist = [2,14,54,22,17] tup = tuple(mylist) for i in tup: print(i%3, end=",")
25 Answer the following : i) Name the package imported for connecting Python with MySQL database. ii) What is the purpose of cursor object?
OR
What is primary key in MySQL database? Give an example.
Section-C
26 a. Consider the following tables Trainer and Course:
What will be the output of the following statement? SELECT * FROM TRAINER NATURAL JOIN COURSE;
b. Write the Outputs of the MySQL queries (i) to (iv) based on the given above tables: i. SELECT DISTINCT(CITY) FROM TRAINER WHERE SALARY>80000; ii. SELECT TID, COUNT(), MAX(FEES) FROM COURSE GROUP BY TID HAVING COUNT()>1; iii. SELECT T.TNAME, C.CNAME FROM TRAINER T, COURSE C WHERE T.TID=C.TID AND T.FEES<10000; iv. SELECT COUNT(CITY),CITY FROM TRAINER GROUP BY CITY;
27 Write a method/function COUNTLINES_ET() in python to read lines from a text file REPORT.TXT, and COUNT those lines which are starting either with ‘E’ or starting with ‘T’ and display the Total count separately. For example: If REPORT.TXT consists of “ENTRY LEVEL OF PROGRAMMING CAN BE LEARNED FROM PYTHON. ALSO, IT IS VERY FLEXIBLE LANGUGAE. THIS WILL BE USEFUL FOR VARIETY OF USERS.” Then, Output will be: No. of Lines with E: 1 No. of Lines with T: 1 OR Write a method/ function SHOW_TODO() in python to read contents from a text file ABC.TXT and display those lines which have occurrence of the word ‘‘TO’’ or ‘‘DO’’. For example : If the content of the file is “THIS IS IMPORTANT TO NOTE THAT SUCCESS IS THE RESULT OF HARD WORK. WE ALL ARE EXPECTED TO DO HARD WORK. AFTER ALL EXPERIENCE COMES FROM HARDWORK.”
The method/function should display:
Section-D 31 Prithvi Training Institute is planning to set up its centre in Jaipur with four specialized blocks for Medicine, Management, Law courses along with an Admission block in separate buildings. The physical distances between these blocks and the number of computers to be installed in these blocks are given below. You as a network expert have to answer the queries raised by their board of directors as given in (i) to (v).
i. Suggest the most suitable location to install the main server of this institution to get efficient connectivity. ii. Suggest by drawing the best cable layout for effective network connectivity of the blocks having server with all the other blocks. iii. Suggest the devices to be installed in each of these buildings for connecting computers installed within the building out of the following: Modem, Switch, Gateway, Router iv. Suggest the most suitable wired medium for efficiently connecting each computer installed in every building out of the following network cables: Coaxial Cable, Ethernet Cable, Single Pair, Telephone Cable v. Suggest the type of network implemented here.
32 (a) Write the output of following python code:
def result(s): n = len(s) m='' for i in range(0, n): if (s[i] >= 'a' and s[i] <= 'm'): m = m + s[i].upper() elif (s[i] >= 'n' and s[i] <= 'z'): m = m + s[i-1] elif (s[i].isupper()): m = m + s[i].lower() else: m = m + '#' print(m) result('Cricket')
(b) Avni is trying to connect Python with MySQL for her project. Help her to write the python statement on the following: i. Name the library, which should be imported to connect MySQL with Python. ii. Name the function, used to run SQL query in Python. iii. Write Python statement of connect function having the arguments values as : Host name :192.168.11. User : root Password: Admin Database : MYPROJECT OR (a) Find the output
Msg1="WeLcOME" Msg2="GUeSTs" Msg3="" for I in range(0,len(Msg2)+1): if Msg1[I]>="A" and Msg1[I]<="M": Msg3=Msg3+Msg1[I] elif Msg1[I]>="N" and Msg1[I]<="Z": Msg3=Msg3+Msg2[I] else: Msg3=Msg3+"*" print(Msg3) b) Your friend Jagdish is writing a code to fetch data from a database Shop and table name Products using Python. He has written incomplete code. You have to help him write complete code: import __________ as m # Statement- 1 object1 = m.connect( host="localhost", user="root", password="root", database="Shop" ) object2 = object1._____ # Statement- 2 query = '''SELECT * FROM Products WHERE NAME LIKE "A%";''' object2._____(query) # Statement- 3 object1.close() 33 What is the advantage of using pickle module? Write a program to write into a CSV file “one.csv” Rollno, Name and Marks separated by comma. It should have header row and then take input from the user for all following rows. The format of the file should be as shown if user enters 2 records. Roll.No,Name,Marks 20,Ronit, 56,Nihir, OR What is difference between tell() and seek() methods? Write a program to read all content of “student.csv” and display records of only those students who scored more than 80 marks. Records stored in students is in format : [Rollno, Name, Marks]
i. What should be written in Line-1? ii. In which mode should Priti open the file to print the data? iii. What should be written in Line-2 and Line-3?
General Instructions:
SECTION A
1 State True or False “The characters of string will have two-way indexing.”
2 Which of the following is the valid variable name? (a) f%2 (b) 20ans (c) ans (d) $ans
3 What will be the output of the following code? D1={1: “One”,2: “Two”, 3: “C”} D2={4: “Four”,5: “Five”} D1.update(D2) print (D1) a) {4:’Four’,5: ‘Five’} b) Method update() doesn’t exist for dictionary c) {1: “One”,2: “Two”, 3: “C”} d) {1: “One”,2: “Two”, 3: “C”,4: ‘Four’,5: ‘Five’}
4 Evaluate the expression given below if A=16 and B=15. A % B // A a) 1 b) 0.0 c) 0 d) 1.
5 Select the correct output of the following code : s=“I#N#F#O#R#M#A#T#I#C#S” L=list(s.split(‘#’)) print(L)
a) [I#N#F#O#R#M#A#T#I#C#S] b) [‘I’, ‘N’, ‘F’, ‘O’, ‘R’, ‘M’, ‘A’, ‘T’, ‘I’, ‘C’, ‘S’] c) [‘I N F O R M A T I C S’] d) [‘INFORMATICS’]
6 Which of the following are the modes of both writing and reading in binary format in file? a) wb+ b) w c) w+ d) wb
7 Fill in the blank _____________ command is used to modify the attribute datatype or size in a table structure. a) update b) alter c) insert d) None of these
8 Which of the following clause is used to sort records in a table? a) GROUP
16 To create a connection between MYSQL database and Python application connect() function is used. Which of the following are mandatory arguments required to connect any database from Python. a) Username, Password, Hostname, Database Name, Port b) Username, Password, Hostname c) Username, Password, Hostname, Database Name d) Username, Password, Hostname, Port
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct choice as (a) Both A and R are true and R is the correct explanation for A (b) Both A and R are true and R is not the correct explanation for A (c) A is True but R is False (d) A is false but R is True 17 Assertion (A):- All the keyword arguments passed must match one of the arguments accepted by the function Reasoning (R):- You cannot change the order of appearance of the keyword.
18 Assertion (A): CSV file is a human readable text file where each line has a number of fields, separated by commas or some other delimiter. Reason (R): writerow() function can be used for writing into writer object.
19 Raman has written a code to find its sum of digits of a given number passed as parameter to function sumdigits(n). His code is having errors. Rewrite the correct code and underline the corrections made. def sumdigits(n): d= for x in str(n): d=d+x return d n=int(input(‘Enter any number”)) s=sumdigits(n) print(“Sum of digits”,s)
20 Write two points of difference between Switch and Router. OR Write two points of difference between Web Server and Web Browser.
21 (a) Given is a Python List declaration: list= [10, 20, 30, 40, 50, 60, 70, 80] print(list[ : : 2]) (b) Write the output of the code given below: squares = {1: 1, 2: 4, 3: 9, 4: 16, 5: 25} print(squares.pop(4))
22 Explain the use of ‘Primary Key’ in a Relational Database Management System. Give example to support your answer.
23 (a) Write the full forms of the following: (i) POP3 (ii) TCP/IP (b) What is the use of VoIP?
24 Predict the output of following code: def fun(x): x[0] = 5 return x g = [10,11,12] print(fun(g),g)
test_list = [5, 6, 7] test_tup = (9, 10) res = tuple(list(test_tup) + test_list) print(str(res)) 25 Differentiate between char and varchar in SQL with appropriate examples. OR What are different types of SQL Aggregate Functions? Give two examples.
26 (a) Consider the following tables – Uniform and Cost: Uniform UCODE UNAME UCOLOR 1 Shirt White 2 Pant Grey 3 Tie Blue 4 Shocks Blue
Cost UCODE SIZE PRICE 1 L 580 1 M 600 2 L 800 2 M 810
What will be the output of the following statement? SELECT * FROM UNIFORM U JOIN COST C ON U.Ucode=C.Ucode;
(b) Write the output of the queries (i) to (iv) based on the table “Product”, showing details of products being sold in a grocery shop. Pcode Pname Uprice Manufacturer P01 Washing Powder 120 Surf P02 Toothpaste 54 Colgate P03 Soap 25 Lux P04 Toothpaste 65 Pepsodent P05 Soap 38 Dove P06 Shampoo 245 Dove
i) SELECT PName, Average (UPrice) FROM Product GROUP BY Pname; ii) SELECT DISTINCT Manufacturer FROM Product; iii) SELECT COUNT (DISTINCT PName) FROM Product; iv) SELECT PName, MAX(UPrice), MIN(UPrice) FROM Product GROUP BY PName;
27 Write a function countwords() in Python that counts the number of words containing digits in it present in a text file “myfile.txt”. Example: If the “myfile.txt” contents are as follows: This is my 1st class on Computer Science. There are 100 years in a Century. Student1 is present in the front of the line. The output of the function should be: 3 OR Write a function countwords() in Python, which should count the occurrences of word ‘me’ and ‘my’ in the text file ‘myfile.txt’.
30 A list contains following record of a student: [Rno, Name, Dob, Class] Write the following user defined functions to perform given operations on the stack named ‘status’: (i) Push_element() - To Push an record of student to the stack (ii) Pop_element() - To Pop the objects from the stack and display them. Also, display “Stack Empty” when there are no elements in the stack. OR Write a function in Python, Push(book) where, book is a dictionary containing the details of a book in form of {bookno : price}. The function should push the book in the stack which have price greater than 300. Also display the count of elements pushed into the stack. For example: If the dictionary contains the following data: Dbook={"Python": 350 ,"Hindi":200,"English":270,"Physics":600, “Chemistry”:550} The stack should contain Chemistry Physics Python The output should be: The count of elements in the stack is 3
31 Eduminds University of India is starting its first campus in a small town Parampur of central India with its centre admission office in Delhi. The university has three major buildings comprising of Admin Building, Academic Building and Research Building in the 5 km area campus. As a network expert, you need to suggest the network plan as per (a) to (e) to the authorities keeping in mind the distance and other given parameters.
Expected wire distances between various locations: Research Building to Admin Building 90m Research Lab to Academic Building 80m Academic Building to Admin Building 15m Delhi Admission Office to Parampur Campus
1450km
Expected number of computers to installed at various locations in the university are as follows: Research Building 20 Academic Building 150 Admin Building 35 Delhi Admission Office 5 a. Suggest the authorities, the cable layout amongst various blocks inside university campus for connecting the buildings b. Suggest the most suitable place (i.e. block) to house the server of this university with a suitable reason c. Suggest an efficient device from the following to be installed in each of the blocks to connect all the computers d. Suggest the placement of a Repeater (if any) in the network with justification. e. Suggest the most suitable (very high speed) service to provide data connectivity between Admission Building located in Delhi and the campus located in Parampur. 32 a) Write output of the following code: value = 50 def display(N): global value value = 25 if N%7==0: value = value + N else: value = value - N print(value, end="#") display(20) print(value)
b) The code given below inserts the following record in the table Employee: Empno – integer EName – string Desig – integer Salary – integer Note the following to establish connectivity between Python and MYSQL: Username is root Password is Password The table exists in a MYSQL database named Bank. The details (Empno, Ename, Design and Salary) are to be accepted from the user. Write the following missing statements to complete the code: Statement 1 – to form the cursor object Statement 2 – to query string. Statement 3- to execute insert query for employee table import mysql.connector mydb=mysql.connector.connect(host='localhost',user='root',passwd='Password',database='bank') mycursor=_________________ # statement eno=int(input('enter Employee no')) nm=input('enter Employee name') d=input('enter Designation) s=int(input(‘Enter salary’)) rtup=(eno,n,d,s)
Give a difference between dump and load function. Write a program in Python that defines and calls the following user defined functions: i. Add(): to add the record of an animal to a csv file “animal.csv”. Each record should be with field elements [animalname, animaltype, animalfood] ii. Search(): to print all the animal names who eat grass as their food. SECTION E 34 Arjun creates a table Employee with a set of records to maintain their Inventory. After
creation of table, he entered data of 7 employees in the table.
EMPNO NAME DEPT SALARY
1021 Radhika sales 5000
1022 Anu dev 12000
1023 Rajesh support 8000
1024 Arunag dev 20000
1026 Manisha sales 7000
1027 Disha support 4000
1035 Sanjay dev 34000
(a) Identify the attribute best suitable to be declared as a primary key
(b) If two columns and two rows are added what will be the degree and cardinality of the
table Employee
(c) i) Insert the following data into the attributes empID, empName and empDept
respectively
in the given table SUDENT empID = 1042, empName = “Abhinav” and empDept =
“support”
ii) Write a command display structure of table employee.
OR
(c) i) Write a command to add new column bonus to Employee Table
ii) Write SQL statement to update the Bonus of all employees by 20% of salary.
35 Aditya is a Python programmer. He has written a code and created a binary file student.dat with rollno, name, class and marks. The file contains 10 records. He now has to search record based on rollno in the file student.dat
As a Python expert, help him to complete the following code based on the requirement given above: import _______ #Statement 1 def searchrec(): r=int(input('Enter roll no of student to be searched')) f=open(______________________) # staement found=False try: while True:
data=_______________ # statement 3 for rec in data: if r==_______: # staement found=True print('Name: ',rec[1]) print('Class : ',rec[2]) print('marks :',rec[3]) break except Exception: f.close() if found==True: print('Search successful') else: print('Record not exist') (i) Which module should be imported in the program? (Statement1) (ii) Write the correct statement required to open a file student.dat in the required mode (Statement 2) (iii) Which statement should Aditya fill in Statement 3 for reading data from binary file s tudent.dat. Also Write the correct comparison to check existence of record (Statement4).