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:
- Pyramid
- Flask
- Scipy
- web2py
Features :
- It has modules for interpolation,linear algebra, image processing etc.
- It is neither a mega-framework nor a micro-framework.
- It relies on rapid development and follows a MVC architecture.
- 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:
- print(sample[:-2])
- print(sample[-2:])
- 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:
- datetime module
- math module
- calendar module
- numbers module
Functions list is:
- timegm
- tzinfo
- ceil,fabs
- complex
Choose the right option.
|
|
|
|
Q. In an exam following statements were provided.
- Pickling is same as serialization.
- Pickling throws errors,when it is pickling data,that,may be insecure or malicious.
- Pickling and Unpickling,allows to send data,from one server to another easily.
- 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).
- When a resource is requested by an user,Django takes care of the controller part and commands interaction between the view and model.
- Django doesn't works well with XML. It does works easily with JSON though.
- Django stores hashed passwords in cookies.
- In django,the manage.py allows to start the server,whereas,the database.py allows syncing,to the database.
Mark the correct answer.
|
|
|
|