Rev 1 CS
Rev 1 CS
Section – A
1. State True or False
“Tuple is datatype in Python which contain data in key-value pair.”
7. Which of the following commands will remove the entire database from MYSQL?
(A) DELETE DATABASE (B) DROP DATABASE
(C) REMOVE DATABASE (D) ALTER DATABASE
8. _____ is a non-key attribute, whose values are derived from the primary key of
some other table.
(A) Primary Key (B) Candidate Key (C) Foreign Key ( D) Alternate Key
10. Which of the file opening mode will open the file for reading and writing
in binary mode.
a) rb b) rb+ c) wb d) a+
13. Which statement in MySql will display all the tables in a database?
a) SELECT * FROM TABLES; b) USE TABLES;
c) DESCRIBE TABLES; d) SHOW TABLES;
14. What will be the output of the following python expression? print(2**3**2)
a) 64 b) 256 c) 512 d) 32
15. Which function is used to display the total number of records from a table in
A database?
(A) total() (B) total(*) (C) return(*) (D) count(*)
16. What will be the output of the following python dictionary operation?
data = {'A':2000, 'B':2500, 'C':3000, 'A':4000}
print(data)
a) {'A':2000, 'B':2500, 'C':3000, 'A':4000} b) {'A':2000, 'B':2500, 'C':3000}
c) {'A':4000, 'B':2500, 'C':3000} d) It will generate an error.
Q17 and 18 are ASSERTION AND REASONING based questions.
(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
18. Assertion: CSV (Comma Separated Values) is a file format for data storage which
looks like a text file.
Reason (R): The information is organized with one record on each line and each
field is separated by semi-colon.
Section – B
19. Vivek has written a code to input a number and check whether it is even or odd number.
His code is having errors. Rewrite the correct code and underline the corrections made.
Def checkNumber(N):
status = N%2
return
#main-code
num=int( input(“ Enter a number to check :))
k=checkNumber(num)
if k = 0:
print(“This is EVEN number”)
else:
print(“This is ODD number”)
20. Write two points of difference between Bus topology and star topology.
OR
Write two points of difference between XML and HTML.
OR
Predict the output of the Python code given below:
L=[1,2,3,4,5]
Lst=[]
for i in range(len(L)):
if i%2==1:
t=(L[i],L[i]**2)
Lst.append(t)
print(Lst)
25. Differentiate between order by and group by clause in SQL with appropriate example.
OR
Categorize the following commands as DDL or DML:
INSERT, UPDATE, ALTER, DROP
Section – C
26. Write the output of the queries (i) to (vi) based on the table given below:
TABLE: CHIPS
27. Write a function countINDIA() which read a text file ‘myfile.txt’ and print the frequency
of the words ‘India’ in it (ignoring case of the word).
Example: If the file content is as follows:
INDIA is my country. I live in India. India has many states.
The countIndia() function should display the output as:
Frequency of India is 3
OR
Write a function countVowel() in Python, which should read each character of a text
File “myfile.txt” and then count and display the count of occurrence of vowels (including
small cases and upper case).
Example:
If the file content is as follows:
28. (A) Consider the following tables BOOKS and ISSUED in a database named “LIBRARY”.
Write SQL commands for the statements (i) to (iv).
Table: BOOKS
Table: ISSUED
BID QTY_ISSUED
HIST66 10
COMP11 5
LITR88 15
(i) Display book name and author name and price of computer type books.
(ii) To increase the price of all history books by Rs 50.
(iii) Show the details of all books in ascending order of their prices.
(iv) To display book id, book name and quantity issued for all books which have been issued.
29. Write a function lenFOURword(L), where L is the list of elements (list of words)
passed as argument to the function. The function returns another list named ‘indexList’
that stores the indices of all four lettered word of L.
For example:
If L contains [“DINESH”, “RAMESH”, “AMAN”, “SURESH”, “KARN”]
The indexList will have [2, 4]
30. A list contains following record of a student:
[StudentName, Class, Section, MobileNumber]
Write the following user defined functions to perform given operations on the stack
named ‘xiia’:
(i) pushElement() - To Push an object containing name and mobile number of students
who belong to class xii and section ‘a’ to the stack
(ii) popElement() - To Pop the objects from the stack and display them.
Also, display “Stack Empty” when there are no elements in the stack.
For example: If the lists of students details are:
[“Rajveer”, “99999999999”,”XI”, “B”]
[“Swatantra”, “8888888888”,”XII”, “A”]
[“Sajal”,”77777777777”,”VIII”,”A”]
[“Yash”, “1010101010”,”XII”,”A”]
33. A binary file data.dat needs to be created with following data written it in the
form of Dictionaries.
print(m,n,x)
x=20
change(10)
change(20)
OR (only in a part)
What will be the output of the following python program?
str = ""
name = "9@Days"
for x in name:
if x in "aeiou":
str+=x.upper()
elif not x.isalnum():
str+="**"
elif x.isdigit():
pass
else:
str+=x.lower()
print(str)
35. What is the advantage of using a csv file for permanent storage?
Write a Program in Python that defines and calls the following user defined functions:
(i) ADD() – To accept and add data of a teacher to a CSV file ‘teacher.csv’.
Each record consists of a list with field elements as tid, name and mobile to store
teacher id, teacher name and teacher mobile number respectively.
ii) COUNTRECORD() – To count the number of records present in the CSV
file named ‘teacher.csv’.
OR
Give any one point of difference between a binary file and a csv file.
Write a Program in Python that defines and calls the following user defined functions:
(i) add() – To accept and add data of an employee to a CSV file ‘employee.csv’.
Each record consists of a list with field elements as eid, name and salary to store
employee id, employee name and employee salary respectively.
(ii) search()- To display the records of the employee whose salary is more than 40000.