Professional Documents
Culture Documents
Question : Vivek is a software developer with a reputed firm. He has been given the task to
computerize the operations for which he is developing a firm which will accept customer data as
follows: The data to be entered is: Name, Age, Items Bought, Total Amount.
Q.1 Choose the most appropriate data type to store the above information inthe
given sequence.
A. string, tuple,float,integer B. string, integer, dictionary,integer
C.string, integer,tuple,float D. string, integer, list,dictionary
Q.2 Now the data of each customer needs to be organized in such that the items
bought followed by the itemprice.
A.List B.Dictionary C.NestedDictionary D.Tuple
Q.3 Now to calculate total bill amount of customers, Vivek can use which data
type to store thesum.
A.Integer B.Float C.List D.Tuple
Q.4 In order to calculate the total bill amount for 15 customers, Vivek
Statement 1. May use a variable of the type float to store the sum.
Statement 2. May use a loop to iterate over the values
Question :
print("Enter Marks Obtained in 5 Subjects: ")
markOne =int(input())
markTwo = int(input())
markThree = int(input())
markFour = int(input())
markFive =int(input())
tot = markOne+markTwo+markThree+markFour+markFive
1
avg = tot/5
Question : Ravi is looking for his dream job but has some restrictions. He loves Delhi and
would take a job there if he is paid over Rs.40,000 a month. He hates Chennai and demands at
least Rs. 1,00,000 to work there. In any another location he is willing to work for Rs. 60,000 a
month. The following code shows his basic strategy for evaluating a job offer. Code:
pay=
location=
2
if location == "Mumbai":
print ("I’ll take it!") #Statement 1
elif location =="Chennai":
if pay < 100000:
print("Noway") #Statement2
else:
print("I am willing!") #Statement3
elif location == "Delhi" and pay > 40000:
print("I am happy to join") #Statement 4
elif pay >60000:
print("I accept the offer") #Statement5
else:
print("No thanks, I can find something better") #Statement6
On the basis of the above code, choose the right statement which will be executed when different
inputs for pay and location are given.
Question :Vimal prepare a code for different conditions and take different inputs in variable
str1. What will be the output for the different inputs given below:
str1=" "
str2=""
I=0
while I<len(str1):
if str1[I]>="A" and str1[I]<="M":
str2=str2+str1[I+1]
elif str1[I]>="0" and str1[I]<="9":
str2=str2+str1[I-1]
else:
str2=str2+"*"
3
I=I+1
print(str2)
Question : If a user change its passing parameter of function calling display( ). What will be the
output of the following code.
defdisplay(a):
a1=""
for i in range(0,len(a)):
if(a[i].isspace()):
a1=a1+"*"
elif(a[i].isdigit()):
a1=a1+"&"
elif(a[i].isalpha()):
a1=a1+a[i].upper()
print(a1)
display(" ")
4
Q.24 If Output : a = [1,2,3,4,5,[6,7,8,9]] , Which of the following option
would you choose?
a. a.append(b) B.a.extend(b) C. Any ofthe above D. None of these
Question: Suppose you are defining a tuple given below: tup = (1, 2, 3, 4, 5)
Q.25 You want to update the value of this tuple at 2nd index to 10. Which of the
following option will you choose?
a. tup(2)=10 B.tup[2]=10 C.tup{2}=10 D. None ofthese
Q.26 You want to check the index of value 5. Which of the following option will you
choose?
a. tup.index(5) B.tup=index(5) C.tup.index(4) D.tup=index(4)
Q.27 You want to check the minimum value of tup. Which of the following option will
you choose?
a. min=tup() B.tup=min(1) C.tup=min() D.min(tup)
Q.28 You want to check the length of tup. Which of the following option will you
choose?
a. len.tup B.len(tup) C.len=tup D. None ofthese
Q.29 You want to delete tup. Which of the following option will youchoose?
a. delete(tup) B.remove(tup) C.del tup D.tup.remove()
Q.31 Which of the following function calls will cause Error while invoking/calling the
below function definition?
def test(a,b,c,d)
A.test(1,2,3,4) B.test(4,5,6,7)
C.test(a=1,b=2,c=3,d=4) D.test(a=1,2,3,4)
Q.32 Which of the following function calls can be used to invoke/calling the below
function definition?
def test(a,b,c,d)
A.test(1,2,3,4) B.test(a=1,2,3,4)
C.test(a=1,b=2,c=3,4) D.test(a=1,b=2,3,4)
5
Q.33 What is a variable defined outside all the function referred to as?
a. A static variable B. A global variable
C. A local variable D. An automatic variable
a. 10 15 B.15 C. 10 D. 15 20
6
Q.38 Which type of argument used in #Invoke2?
a. PositionalArgument B. DefaultArgument
C. KeywordArgument D. Variable lengthArgument
Q.39 What will be the output of following code:
def func(a=10,b=20):
return a+b
print(func(a=1))
print(func(b=1))
Q.51 Priya is creating an inventory management project for her father. She has to maintain a
price list and create a module for stock management. She is confused in choosing the
data type she has to work with. Which data type will you suggest her?
A. List B. Tuple C. Dictionary D. Files
Q.52. On working with list data type, Meena is facing a problem. On certain condition she is
creating a duplicate copy of list for backup purpose using the code list2=list1. But she
couldn’t effectively maintain the list as whatever changes made in the new list is
affecting the old list. What is the problem with her code?
a. She created a shallow copy. b.She created a deep copy.
c. She violated the mutability concept. d. Both lists took different memory location.
Q.53. Based on the situation given in question no.52, what modification can be done on the
code to meet the requirement.
A. list2=list(list1)
B. list1= list(list2)
C. list1=copy(list2)
D. list2=list.copy(list1)
Q.54 Ranjit created a sequence of data in form of tuple. Now he wants to add few more
elements to the same tuple. What will happen when he does so?
a. The operation is carried successfully.
b. The operation is aborted due to error
c. The operation leads to an exception
d. A tuple is created with additional elements in a new memory space.
8
Q.56 Which of the following is not a valid string operation in Python?
a. ‘abc’+’abc’
b. ’abc’*3
c. ‘abc’+3
d. ‘abc’.upper()
Q.58 Which of the following statement is not correct regarding the file access modes?
a. ‘r+’ opens a file for both reading and writing. Fileobject points to its beginning.
b. ‘w+’opens a file for both writing and reading. Adds at the end of the existing file
if it exists and creates a new one if it does not exist.
c. ‘wb’opens a file for reading and writing in binary format. Overwrites the file if it
exists and creates a new one if it does not exist.
d. ‘a’opens a file for appending.
Q.59 The file pointer is at the start of the file if the file exists. Which of the following
statements correctly explain the function of seek () method?
A. tells the current position within the file.
B. determines if you can move the file position or not.
C. indicates that the next read or write occurs from that position in a file.
D. moves the current file position to a given specified position.
Q.63.After making a first call to Rohan whose number is 8124596780 how will he add it to the
dictionary?
a. Call_register*‘Rohan’+=8124596780
b. Call_register.push*‘Rohan’+=8124596780
c. Call_register[8124596780]+=‘Rohan’
d. Call_register['Rohan']=8124596780
Q.64. How can he show the entire call history to his manager at end of the day?
A. Call_register.get()
B. Call_register.items()
C. Call_register.keys()
D. Call_register(keys)
Q.65 When the manager wants to check only the names of the customer he called, then how can
he generate it.
A. Call_register.get()
B. Call_register.items()
C. Call_register.keys()
D. Call_register.values()
Q. 66 Assertion - close () method closes the file and frees the memory space acquired by that
file.
Reason - one should always close their files, in some cases, due to buffering, changes made to a
file may not show until the file is closed.
A - Both A and R are true and R is the correct explanation of A.
B - Both A and R are true but R is not the correct explanation of A.
C - A is true but R isfalse.
10
D - A is false but R istrue.
Q.67 Assertion - The with statement simplifies the working with files but does not support
exception handling.
Reason – The with statement will automatically close the file after the nested block of
code.
A - Both A and R are true and R is the correct explanation of A.
B - Both A and R are true but R is not the correct explanation of A.
Q-71 Assertion - A CSV file is a type of plain text file that uses specific structuring to
arrange tabular data.
Reason - A CSV file is a simple text file where each line contains a list of values
11
delimited by commas.
Q-72 Assertion - In a function header, any parameter cannot have a default value unless all
parameters appearing on its right have their default values.
Reason - Non- default arguments cannot follow default arguments.
Q-73 Assertion- Having keyword arguments after positional arguments will result into
error. Reason – an argument list must contain positional arguments followed by any
keyword arguments.
Q-75 Assertion- One should avoid using global statements in python program
Reason – Global statements cannot be reverted in a program
12
run. A - Both A and R are true and R is the correct explanation
of A.
B - Both A and R are true but R is not the correct explanation of A.
C - A is true but R is false.
D - A is false but R is true.
Preethi wants to read the contents of a file “test.csv” which is stored in ‘d:’ drive. She has
written the code partially. Help her to complete
import ________ # line1
f=open(______________) # line2
data=__________(f) # line3
for row in _____ : # line4
print(row) # line5
______ #line6
Q.77.What argument she should pass inside the open () function inline2?
A. “test.csv”,”r”
B. “test.csv”,”rb”
C. “d:/test.csv”,”r”
D. “d:/Test.csv”,”r”
Q.78. Help her to create a csv object in line3 by choosing the correct option.
A. csv.reader
B. csv.writer
C. csv.readrows
D. csv.Writerows
Q.79. Complete the header part of the for loop with the appropriate option.
A. test
B. f
C. data
D. csv
Q.80. Fill line6 with the correctoption.
A. csv.close()
13
B. close()
C. f.close()
d. close(f)
Vinay is writing a program to search for the details a particular student. He has got difficulties in
completing the code. Help him to complete it.
import __________ as P # line 1
L=[ ]
rno=int(input(“Enter the rno to search:”))
______ open(‘student’,rb) as ______: # line 4
L=___________(f) # line 5
for x in ______: # line 6
if x[0]==roll:
print(“name=”,x[1])
print(“total=”,x[5])
_______ # line 10
else :
print(“not found”)
Q.81. What module should be imported by Keerthi inline1?
A. pickle
B. csv
C. binary
D. Pickle
Q.82. Complete the open()statement
A. filehandle,filename
B. filename,filehandle
C. with,filehandle
D. with,f
Q.83. Help sunil to complete line5.
A. P.load()
B. pickle.load()
C. f.dump()
D. pickle.dump()
Q.84. The iterating variable x has to be iterated over,
A. P
B. L
C. f
D. rb
Q.85. Complete line 10 with a relevant jump statement.
A. continue
B. goto
C. break
14
D. exit
a) x is now 15
b) x is now 2
c) x is now 100
d) None of the mentioned
a. 11 b. 11.0 c. 9.0 d. 9
(2+3)**3-6/2
a. 121 b.121.0 c. 122.0 d. none
Q.90 What is the order of precedence of the arithmetic operations given below in python?
1. () 2.** 3. * 4. / 5. + 6. –
>>>int('101',2)
>>>int('A',16)
a. 10 5 b. 5 10 c. 1.01 A d . NONE
16
d.none
a. -46 4 b. 3 45 c. 4 -46 d. 3 46
print(vc,cw)
myfile.close()
a. 7 19 b. 19 7 c. 4 5 d. none
17