Q. In an exam, following code snippets were provided:
def sum(abc=1,xyz):
return abc+xyz
sum(41)
def hello(hellotext):
print(hellotext,"namaste")
hello('Hello is same as')
Mark the correct print outputs.
Q. A developer wrote the following code snippet:
def main():
print ("This is the main function")
print ("Lets call print from main")
The output desired was -
This is the main function
Lets call print from main
But he was not getting it. Which of the following options,should be applied?
Q. Below are given a few scenarios.
He gave them the following example :
class House:
pass
print(House.area)
dict_eg={1:1,2:2}
dict_eg[3]
import maths
Mark the correct answer.
Q. In an interview,a fresher was given the following code snippet:
flavors=['mango','butterscotch','strawberry']
flavors[2:]=['chocolate','almond','vanilla']
print(flavors)
multi=[[[11,21],[31,41],51],[61,71]]
print(multi[0][1][1])
Choose the correct answer.
Q. Below are mentioned a few key points:
- Mainly used for data analysis,graphical models , statistics etc.
- Most of its code is slow.
- Ease of preparation,of new models,like matrix computation etc.
- It gets integrated with applications efficiently.
Mark,which language has a dominance,in the above points (R or Python)
|
|
|
|
Q. A developer was practicing some code snippets. He came across the following:
import nltk
from nltk.stem import PorterStemmer
examplewords=['waiting','waits','awaits','waited']
ps=PorterStemmer()
for word in examplewords:
print(f"{word}: {ps.stem(word)}")
Mark the correct output of the same.
Q. In an exam,following code snippets, were provided:
import re
rhyme = """twinkle
twinkle
little"""
result2 = re.findall(r"^\w", rhyme, re.MULTILINE)
print(result2)
import re
match=re.search('^\w*nts','All tennis tournaments?')
print(match.group())
Mark the appropriate syntax, to do the above.(NOTE: np is the numpy object).
Q. In an exam,developers were given a few descriptions,about Python compilers and interpreters:
- With this compiler, Python scripts can interact with .NET objects.
- We can run the python code,on any machine,that has JVM,because of this compiler.We can also extend Java classes.
- With this framework,one can develop, client-side web applications,that can run in a browser.
Mention the names that map to them. Mark the appropriate answer.
Q. Below are given a few statements,about the Python main function:
- Python sets,special variable(__name__) to have value (__main__), when source file is run as a main program.
- Python modules can be used as standalone programs,because of "if__name__== "__main__". But they cannot be treated as reusable modules.
- When the main function is executed, interpreter will read the "if" statement,and,check if __name__ is equal to __main__.
- It is important to take care of indentation,after declaring the main function,else,one can get an Indentation error.
Mark them as Valid(V) or Invalid(In).
|
|
|
|
Q. A lead was explaining to his team,theory about Python memory management. Below are a few mentioned points:
- A private heap space manages the memory in Python.It is the place where all objects and data structures,are located.
- Python memory manager,allocates space,for python objects on the heap
- Python is unique,as its interpreter allows a programmer some access to the private heap.
- There is a inbuilt garbage collector,that recycles unused memory,and,makes it available to the heap.
Mark which of them are True or False.
|
|
|
|