Python Online Practice Test - 8

This Test will cover complete Python with very important questions, starting off from basics to advanced level.
Q. In an interview,following code snippets were provided. The lists present were:

import copy

list1 = [2,5,[8,0],7]
list2 = [3,9,1] 
list3 = copy.copy(list1)
list4 = copy.deepcopy(list2) 
list1[2][0] = 777

print ("List 3 elements")

for i in range(0,len(list3)):
    print (list3[i],end=" ") 

print ("List 4 elements - ")

for i in range(0,len( list4)):
    print (list4[i],end=" ")

Mark the correct print outputs.
Q. Match the Python frameworks with their descriptions:
  1. Pyramid
  2. Flask
  3. Scipy
  4. web2py
Features :
  1. It has modules for interpolation,linear algebra, image processing etc.
  2. It is neither a mega-framework nor a micro-framework.
  3. It relies on rapid development and follows a MVC architecture.
  4. It does not have form validation and doesn't needs certain tools or libraries.
Mark the correct answer.
Q. In an interview,freshers were provided with following code snippet:

except (NameError,TypeError):
	print("Invalid input")

Mark the correct answer.
Q. In a quiz, Python string was provided:
The following string operations were mentioned:
  1. print(sample[:-2])
  2. print(sample[-2:])
  3. print(sample[:1])
Mark the correct answer.

Q. Below are provided a few code snippets:

if int_a<float_a:
elif int_a > float_a:

Mark the correct output of the same.
Q. Below are provided a few code snippets:

string_first = "NEW CAR"
string_second = "new car"
if(string_first < string_second):
	print("My cars!")
elif(string_first > string_second):
	print("NOT my cars!!")

Mark the correct output of the same.
Q. In a quiz competition,following code snippet was given :

def example1():
	print("Value of var1:",var1)
def example2():
	global var2
	print("Value of var2 inside:",var2)
print("Value of var2 outside:",var2)

Mark the correct output of the same.
Q. Match the Python modules with the functions present in them:
  1. datetime module
  2. math module
  3. calendar module
  4. numbers module
Functions list is:
  1. timegm
  2. tzinfo
  3. ceil,fabs
  4. complex
Choose the right option.
Q. In an exam following statements were provided.
  1. Pickling is same as serialization.
  2. Pickling throws errors,when it is pickling data,that,may be insecure or malicious.
  3. Pickling and Unpickling,allows to send data,from one server to another easily.
  4. One can start pickling data,by importing the 'pickle' module.
Mark the correct answer.

Q. A peer once asked a developer, the output of the following code snippet.

import array
arr2 = arr1*2

Mark the correct Output.
Q. A lead was explaining to his team the pros and cons of the Django framework. Which of the points put forth are valid(V) or Invalid(In).
  1. When a resource is requested by an user,Django takes care of the controller part and commands interaction between the view and model.
  2. Django doesn't works well with XML. It does works easily with JSON though.
  3. Django stores hashed passwords in cookies.
  4. In django,the allows to start the server,whereas,the allows syncing,to the database.
Mark the correct answer.

Having second thoughts for any code related question?

Try executing the code in our Code Playground