Basics of Core Java

This Test will cover complete Python with very important questions, starting off from basics to advanced level.
Q. In a language processing application,a developer was working,on the following code:

import nltk

from nltk.stem import WordNetLemmatizer


What is the output expected?
Q. Below are a few points mentioned, about the internal working of an interpreter:
1) The __________ breaks the line of code into tokens
2) The __________ uses the tokens,to prepare a structure,that shows,relation between tokens.
3) The __________ turns the token structure,in code objects.
4) The __________ runs the code objects.
Mark the correct option.
Q. In an interview,code snippets of some built-in functions,were given:



Mark their correct output.
Q. A fresher,was given the task,of converting a few functions, in Python,to lambda expressions:

import math

def cube_root(x):
    return math.pow(x,1/3)

def add_three(x,y,z):
    return x+y+z

Mark the correct lambda expressions.

Q. In an exam,following code snippet was provided:

class Sum:
    def __init__(self,sum):
        self.sum = sum
class Number(Sum):
    def __init__(self,sum):
        self.value = sum*2
    def show(self):
objsum = Number(8)   

Mark the correct output of the same.
Q. In an interview,freshers were asked,to mark the following statements,as Valid or InValid:
1) The *args allows,zero number of extra arguments.
2) The *args and **kwargs, when used together, should be in the order:

def somefunc(fnargs,*args,**kwargs):
    Using **kwargs before *args,will throw an error.

3) **kwargs is used,to pass a keyworded,variable length argument list.
4) **kwargs can be compared,to a set object,such that,when we iterate over it,the elements are orderly printed.
Q.Below are a few statements made,either about xrange or range function:
1) A particular range, is shown on demand,hence,it is also called as "lazy evaluation".
2) It returns the list of numbers,created using the range() function.
3) Here,the variable,storing the range returned,takes more memory
4) Operations related to the 'list',cannot be applied,on an object here.
Mark them appropriately.
Q. In a technical competition, participants had to face a rapid fire round, about Python facts:
They were supposed to answer the questions as Yes or No.
1) Python does not have any data types, for characters,as they are treated as strings.
2) Try and catch, is used for exception handling.
3) A do-while loop,is present in Python.
4) Python is not a compiled language.
Mark the correct output.
Q. A developer was working,with the 'numpy' library,for performing some mathematical operations. Consider the following code snippet-

import numpy as np 

array1 = np.arange(12)
array2 = array1[3:11:4] 




Mark the correct answer.

Q. In an exam,following code snippets were provided:


from collections import Counter


from collections import Counter


Having second thoughts for any code related question?

Try executing the code in our Code Playground