Signup/Sign In

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
list2[2]=888

print ("List 3 elements")

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

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:

try:
	print(14/0)
	print("88"+1)
except (NameError,TypeError):
	print("Invalid input")

Mark the correct answer.
Q. In a quiz, Python string was provided:
sample="HelloWorld".
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:

int_a=3
float_a=3.0
if int_a<float_a:
	print("False")
elif int_a > float_a:
	print("True")

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 :

var1=90
def example1():
	print(var1)
	var1=100
	print("Value of var1:",var1)
var2=55
def example2():
	global var2
	var2=88
	print("Value of var2 inside:",var2)
example1()
example2()
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
arr1=[2,6]
arr1.extend([3,45])
print("Step1:",arr1)
arr2 = arr1*2
print("Step2:",arr2)
print("Step3:",arr1[0:3])

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 manage.py allows to start the server,whereas,the database.py allows syncing,to the database.
Mark the correct answer.

Related Tests: