Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
42 views5 pages

Revision For 1st Pre-Board

Uploaded by

vizagtrip202
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views5 pages

Revision For 1st Pre-Board

Uploaded by

vizagtrip202
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Revision For 1st Pre-Board

1. What will be the output:


a=[5,10,15,”Ram",10.5]
for i in a:
print(i)

output
5
10
15
Sita
10.5

2. Which of the following option is not correct?

a) if we try to read a text file that does not exist, an error occurs.
b) if we try to read a text file that does not exist, the file gets created. 
c) if we try to write on a text file that does not exist, no error occurs.
d) if we try to write on a text file that does not exist, the file gets created.
3. Ramesh is trying to read data from a csv file “data.csv”. Consider the following code.
import ______________ # Statement1
with open (“_______________”,”r”) as obj: # Statement2
fobj=csv.______________(obj) # Statement3
for i in ___________:# Statement4
print(____) # Sstatement5

 Identify the missing code in Statement1.


a) csv b) pickle c) dump d) load
 Identify the missing code in Statement2.
a) data.txt b) data.csv c) data.bin d) data.rtf
 Identify the missing code in Statement3.
a) writer b) reader c) writerow d) load
 Identify the missing code in Statement4.
a) obj b) csv c) fobj d) i
 Identify the missing code in Statement5.
a) i b) csv c) fobj d) obj

4. What is the significance of the tell() method?


a) Tells the path of file
b) Tells the current position of the file pointer within the file 
c) Tells the end position within the file
d) Checks the existence of a file at the desired location

5. What will be the output of the below code?


a=[5,10,15,”Ram",10.5]
for i in range(len(a)):
print(a[i])
Output:
5
10
15
Sita
10.5

6. Which of the following is not a function / method of csv module in Python?


a. read()
b. reader()
c. writer()
d. writerow()

7. Which of the following is not a DDL command?


a. Create
b. Alter
c. Drop
d. Delete
8. Which of the following is not a DML command?
a. Select
b. Insert
c. Update
d. Commit

9. What will be the output:


Mylist=[1,2,3]
Mylist[-1]=30
print(Mylist)
Output:
[1, 2, 30]

10. What is the output of the following Python code:


Name="Aum Valley School,TIG"
x=Name.partition(" ")
print(x)
a) ('Aum', 'Valley School,TIG',’ ‘)
b) ('Aum', ' ', 'Valley School,TIG') 
c) (' ', 'Aum', 'Valley School,TIG')
d) ('Aum', ' ', 'Valley School’,’TIG')

 Q. 11 and Q. 12 are ASSERTION (A) and REASONING (B) 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.

11. Assertion (A): To use a function from a particular module, we need to import the
module.
Reason(R): import statement can be written anywhere in the program before using a function
from that module.

Ans: (a)

12. Assertion (A): A stack is a LIFO structure.


Reason (R): Any new element pushed into the stack always its positioned at the index after
the last existing element in the stack.

Ans: (a)

13. Assume that the position of the file pointer is at the beginning of 2rd line in a text file.
Which of the following option can be used to read all the remaining lines?
a) myfile.read()
b) myfile.read(n)
c) myfile.readline()
d) myfile.readlines()

14. Which of the following options can be used to read the first line of a text file Myfile.txt?
a. myfile = open('Myfile.txt'); myfile.read()
b. myfile = open('Myfile.txt','r'); myfile.read(n)
c. myfile = open('Myfile.txt'); myfile.readline()
d. myfile = open('Myfile.txt'); myfile.readlines()

15. Predict the out of the below code:


L=[13,18,11,16,18,14]
a=L.index(18)
print(a)
Output:
1
16. Which of the following statement is incorrect in the context of binary files?
a. Information is stored in the same format in which the information is held in memory.
b. No character translation takes place
c. Every line ends with a new line character 
d. pickle module is used for reading and writing

17. Which clause is used with SELECT statement to display data in a sorted form with respect
to a specified column.
a) Having
b) Where
c) Order by
d) Distinct

18. Sahil has just created a table named “Employee” containing column Ename, Department
and Salary. After creating the table, he realized that he has forgotten to add a primary key
column in the table. Help him in writing an SQL command to add a primary key on Empid
of integer type to the table “Employee”. Thereafter, write the command to insert the
following record in the table.
Empid: 909
Ename: Akash
Department: Production
Salary: 1000

Ans:
1. Alter table Employee add Empid integer primary key;
2. Insert into Employee values(“Akash”,”Production”,1000,909)
Or
Insert into Employee(Empid,Ename,Department,Salary)
Values(909, “Akash”,”Production”,1000)

19. Predict the output of the below code:


list1=["Rahul",10,33.0,'Ram']
list2=[1,2,3,4]
list1.extend(list2)
print(list1)
Output:
['Rahul', 10, 33.0, 'Ram', 1, 2, 3, 4]

20. Ishika is working in a database named SPORT in which she created a table named
“Sports” containing columns Soprtid, SoprtName, No_of_players and Category.After
creating the table she realized that the attribute, Category has to be deleted from the table
and a new attribute “Sport_Type” of string data type has to be added. This attribute
“Sport_Type” cannot be left blank. Help Riya to write the SQL command to complete
both the tasks.
Ans:
 To delete the attribute Category:
 Alter table Sports drop Category;

 To add the attribute Sport_Type:


 Alter table Sports add Sport_Type char(10) not null;

21. Which of the following statement opens a binary file “record.dat” in write mode and
writes data from a list lst1 = [1,2,3,4] on the binary file?
 a) myfile=open('record.dat','wb')
pickle.dump(lst1,myfile)
b) myfile=open('record.dat','wb')
pickle.dump(myfile,lst1)
c) myfile=open('record.dat','wb+')
pickle.dump(myfile,lst1)
d) myfile=open('record.dat','ab')
pickle.dump(myfile,lst1)

22. What will be the output:


Fruits={"Apple":350,"Orange":250,"Grapes":220}
for i in Fruits:
print(i,':',Fruits[i])# it will displayed key with value.
print()# use to add a blank line.
Output:
Apple : 350
Orange : 250
Grapes : 220

23. Ritesh is trying to write a tuple tup1 = (1,2,3,4,5) on a binary file test.bin. Consider the
following code written by him.
import _______ #Statement 1
tup1 = (1,2,3,4,5)
myfile = open("___________",'________') #Statement2 and #Statement3
pickle._______ #Statement 4
____________.close() #Statement 5

 Identify the missing code in Statement1.


a) csv b) pickle c) dump d) load

 Identify the missing code in statement2


a) test.dat b) test.docx c) test.bin d) test.html

 Identify the missing code in Statement3.


a) w+ b) wb c) r+ d) rb
 Identify the missing code in Statement4.
a) dump(myfile,tup1) b) dump(tup1, myfile) 
c) write(tup1,myfile) d) load(myfile,tup1)

 Identify the missing code in Statement5.


a) tup1 b) pickle c) close d) myfile

24. _________ is the value which is passed to the function and ________ is the value which
is being received.
a. Function, Module
b. Argument, Parameter 
c. Parameter, Argument
d. None of the above
25. Python function default follows the _______ argument system.
a. Name Argument
b. Positional Argument
c. Default Argument
d. None of the above

 Note: practice the above question answers in your paper for good practice and read the DBMS
part such as DDL and DML. Any queries ask me

You might also like