Sunteți pe pagina 1din 25

ID

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

22

23

24
25

26

27
28
29
30

31
32
33

34

35
36
37

38
39
40
41
42
43
44

45
46

47

48

49
50

51

52

53

54

55

56

57

58

59
60
Question
What is output for : a=['he','she','we']' '.join(a)
What is the output of following code : [ (a,b) for a in range(3) for b in range(a) ]
In the following options which are python libraries which are used for data analysis and scientific computations
What is output for : 2 * 2 **3
What command is used to insert 6 in a list ‘‘L’’ at 3rd position ?
Which of the following is more accurate for the following declaration? x = Circle()
Which method is used to display a warning message in Python?
In Python we can create a popup menu. Select the code to display a popup menu?
What will be the output of the following Python code? print("Hello {name1} and {name2}".format(name1='foo', nam
What will be the output of the following Python code? print("Hello {0!r} and {0!s}".format('foo', 'bin'))
What will be the output of the following Python code? print("Hello {0} and {1}".format(('foo', 'bin')))
What will be the output of the following Python code? print("Hello {0[0]} and {0[1]}".format(('foo', 'bin')))
What will be the output of the following Python code snippet? print('The sum of {0} and {1} is {2}'.format(2, 10, 12))
What will be the output of the following Python code snippet? print('The sum of {0:b} and {1:x} is {2:o}'.format(2, 1
What will be the output of the following Python code snippet? print('{:,}'.format(1112223334))
What will be the output of the following Python code snippet? print('{:$}'.format(1112223334))
What will be the output of the following Python code snippet? print('{:#}'.format(1112223334))
What will be the output of the following Python code? print('{0:.2}'.format(1/3))
What will be the output of the following Python code? print('{0:.2%}'.format(1/3))
What will be the output of the following Python code? print('ab12'.isalnum())
What will be the output of the following code: print type(type(int))

What is the output of the following code :


L = ['a','b','c','d']
print "".join(L)
What is the output of the following segment :
chr(ord('A'))

What is the output of the following program :


y=8
z = lambda x : x * y
print z(6)
What is called when a function is defined inside a class?

Which of the following is the use of id() function in python?

What is the output of the following program :


import re
sentence = 'horses are fast'
regex = re.compile('(?P<animal>w+) (?P<verb>w+) (?P<adjective>w+)')
matched = re.search(regex, sentence)
print(matched.groupdict())
Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.pop(1)?
time.time() returns ________
Consider the results of a medical experiment that aims to predict whether someone is going to develop myopia based on some
heredity. In this case, the input dataset consists of the person’s medical characteristics and the target variable is binary: 1 for th
develop myopia and 0 for those who aren’t. This can be best classified as
What is the output of the following code :
print 9//2
Which function overloads the >> operator?
Which operator is overloaded by the or() function?

What is the output of the following program :


i=0
while i < 3:
print i
i++
print i+1
What is the output of the following program :
print "Hello World"[::-1]
Given a function that does not return any value, what value is shown when executed at the shell?
Which module in Python supports regular expressions?
What is the output of the following program :
print 0.1 + 0.2 == 0.3
Which of the following is not a complex number?
What does ~~~~~~5 evaluate to?
Given a string s = “Welcome”, which of the following code is incorrect?
________ is a simple but incomplete version of a function.
To start Python from the command prompt, use the command ______
Which of the following is correct about Python?

Which of these is not a core data type?


What data type is the object below ? L = [1, 23, ‘hello’, 1]

Which of the following function convert a string to a float in python?

Which of the following statement(s) is TRUE?

1.A hash function takes a message of arbitrary length and generates a fixed length code.
2.A hash function takes a message of fixed length and generates a code of variable length.
3.A hash function may give the same hash value for distinct messages.

What is the output of the following program :


def myfunc(a):
a=a+2
a=a*2
return a

print myfunc(2)
What is the output of the expression : 3*1**3
What is the output of the following program :
print '{0:.2}'.format(1.0 / 3)
What is the output of the following program :
print '{0:-2%}'.format(1.0 / 3)

What is the output of the following program :


i=0
while i < 3:
print i
i += 1
else:
print 0

What is the output of the following program :


i=0
while i < 5:
print(i)
i += 1
if i == 3:
break
else:
print(0)
What is the output of the following program :
print 'cd'.partition('cd')
What is the output of the following program :
print 'abef'.partition('cd')
What is the output of the following program :
print 'abcefd'.replace('cd', '12')

What will be displayed by the following code?


def f(value, values):
v=1
values[0] = 44
t=3
v = [1, 2, 3]
f(t, v)
print(t, v[0])

What is the output of the following code? Consider Python 2.7.


print tuple[1:3] if tuple == ( 'abcd', 786 , 2.23, 'john', 70.2 ) else tuple()

Is Python case sensitive when dealing with identifiers?


Explanation
The method join() takes list of string as input and returns string as output. It removes ', ' and add the given string wit
This is nested for loop. The output of first for loop will be the value for the next loop.
Numpy,Scipy,pandas are few libraries in python which are used for data analysis and scientific computations.
2**3 gives 2*2*2 i.e. 8, then 2*8 gives 16, since order of precedence is ** then*. ** implies ‘‘ raise to power’’.
listname.insert(x,y) method is used to insert a item at certain position in a list. x defines position at which the elemen
x is the object created by the constructor of the class Circle().
For the type of message user want to display on the window of python there is a type of code according to it. Examp

The arguments are accessed by their names.


!r causes the characters ‘ or ” to be printed as well.
IndexError, the tuple index is out of range.
The elements of the tuple are accessed by their indices.
The arguments passed to the function format can be integers also.
2 is converted to binary, 10 to hexadecimal and 12 to octal.
A comma is added after every third digit from the right.
$ is an invalid format code.
The number is printed as it is.
.2 specifies the precision.
The symbol % is used to represent the result of an expression as a percentage.
The string has only letters and digits.
The type() function returns the class of the argument the object belongs to. Thus, type(int) returns which is of the typ

depicts a null string and the join function combines the elements of the list into a string.

ord() function converts a character into its ASCII notation and chr() converts the ASCII to character.

lambdas are concise functions and thus, result = 6 * 8

Each object in Python has a unique id. The id() function returns the object’s id.

This function returns a dictionary that contains all the matches.


pop(i) removes the ith index element from the list
Regression: It is a statistical analysis which is used to establish relation between a response and a predictor variable. It is mainly
Decision Tree: Decision tree is a computational method which works on descriptive data and records the observations of each
Clustering: It is a method of grouping more similar objects in a group and the non-similar objects to other groups.
Association Rules: It uses if-then reasoning method using the support-confidence technique to give a result.
According to the question Decision Tree is the most suitable technique that can be used to get best result of the experiment.

The ‘//’ operator in Python returns the integer part of the floating number.
rshift() overloads the >> operator
or() function overloads the bitwise OR operator

There is no operator ++ in Python

[::] depicts extended slicing in Python and [::-1] returns the reverse of the string.
Python explicitly defines the None object that is returned if no value is specified.
re is a part of the standard library and can be imported using: import re.

Neither of 0.1, 0.2 and 0.3 can be represented accurately in binary. The round off errors from 0.1 and 0.2 accumulate and henc
l (or L) stands for long.
~x is equivalent to -(x+1).
strings are immutable in Python

Class is a user defined data type

[ ] defines a list
float(x) − Converts x to a floating-point number

Hash function is defined as any function that can be used to map data of arbitrary size of data to a fixed size data.. The values r
Statement 1 is correct
Yes, it is possible that a Hash Function maps a value to a same location in the memmory that’s why collision occurs and we hav
eg : we have hash function, h(x) = x mod 3

Python creates blocks of code based on the indentation of the code. Thus, new indent defines a new scope.
Precedence of ** is higher than that of 3, thus first 1**3 will be executed and the result will be multiplied by 3.

.2 defines the precision of the floating point number.

The % converts the 0.33 to percentage with respect to 1.0

The else part is executed when the condition in the while statement is false.

The else part is not executed if control breaks out of the loop.

The entire string has been passed as the separator hence the first and the last item of the tuple returned are null strings.

The separator is not present in the string hence the second and the third elements of the tuple are null strings.
The first substring is not present in the given string and hence nothing is replaced.

The value of t=3 is passed in funcion f(value,values) , v [list] is passed as values in the same function. The v is stored in values a

Case is always significant.


Answer No.
B
D
D
C
A
B
C
A
A
B
C
A
A
B
A
D
C
B
C
A
B

A
D

A
C
E
B

C
D
B

A
D
A

B
C
A
C
A
C
C

D
A

C
C

D
A
Choice1
['heshewe']
[ (1,0),(2,1),(3,2)]
Numpy
12
L.insert(2,6)
Now you can assign int value to x.
Tkinter.message.showmessage('message here')
Menu.post(250,250)
Hello foo and bin
Hello foo and foo
Hello foo and bin
Hello foo and bin
The sum of 2 and 10 is 12
The sum of 2 and 10 is 12
1,112,223,334
1,112,223,334
1,112,223,334
0
0
1
type ‘int’

Error

48
Module

Id returns the identity of the object

{‘animal’: ‘horses’, ‘verb’: ‘are’, ‘adjective’: ‘fast’}


[3, 4, 5, 20, 5, 25, 1, 3]
the current time
Regression

4.5
more()
||

021324

dlroW olleH
int
re

1
k = 2 + 3j
5
print s[0]
Stub
execute python
It supports automatic garbage collection.

Lists
List

int(x [,base])

I only

8
27

0.333333

0.33

01230

0120

(‘cd’)

(‘abef’)

ab1ef2

11

( ‘abcd’, 786 , 2.23, ‘john’, 70.2 )


yes
Choice 2
'heshewe'
[ (0,0),(1,1),(2,2)]
Scipy
64
L.insert(3,6)
x contains a reference to a Circle object.
Tkinter.message.sshowwarning('message here')
Menu.post()
Hello {name1} and {name2}
Hello ‘foo’ and foo
Hello (‘foo’, ‘bin’) and (‘foo’, ‘bin’)
Hello (‘foo’, ‘bin’) and (‘foo’, ‘bin’)
Error
The sum of 10 and a is 14
111,222,333,4
111,222,333,4
111,222,333,4
0.33
0.33%
0
type ‘type’

None

14
Class

Every object doesn’t have a unique id

(‘horses’, ‘are’, ‘fast’)


[1, 3, 3, 4, 5, 5, 20, 25]
the current time in milliseconds
Decision Tree

4.3
gt()
|

012345

Hello Worl
bool
regex

0
k = complex(2, 3)
-11
print s.lower()
Function
go python
It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java

Dictionary
Dictionary

long(x [,base] )

II and III only

16
9

0.33

0.33%

0120

012

(”)

(‘abef’, ‘cd’, ”)

abcefd

1 44

abcd
no
Choice 3
['he she we']
[(1,0),(2,1),(2,1)]
Pandas
16
L.add(3,6)
x actually contains an object of type Circle.
Tkinter.messagebox.showwarning('message here')
Menu.display()
Error
Hello foo and ‘bin’
Error
Error
The sum of 0 and 1 is 2
The sum of 10 and a is c
1112223334
1112223334
1112223334
0.333333:.2
33.33%
None
Error

abcd

64
Another Function

All of the mentioned

‘horses are fast’


[3, 5, 20, 5, 25, 1, 3]
the current time in milliseconds since midnight
Clustering

4
ge()
//

Error

d
void
pyregex

Machine dependent
k = 2 + 3l
11
s[1] = ‘r’
A function developed using bottom-up approach
python
Both of the above

Tuples
Tuple

float(x)

I and III only

Indentation Error
3

0.333333:-2

33.33%

012

Error

(‘cd’, ”, ”)

(‘abef’, ”, ”)

ab1efd

31

(786, 2.23)
machine dependent
Choice 4
'he she we'
[ (1,0),(2,0),(2,1)]
All the above
36
L.append(2,6)
x contains an int value.
Tkinter.messagebox.showmessage('message here')
Menu.display_popup(250,250)
Hello and
Error
None of the mentioned
None of the mentioned
None of the mentioned
Error
Error
Error
Error
Error
33%
Error
0

[‘a’,’b’,’c’,’d’]

Error

None of the mentioned


Method

None of the mentioned

‘are’

[1, 3, 4, 5, 20, 5, 25]


the current time in milliseconds since midnight, January 1, 1970
Association Rules

Error
None of the mentioned
/

102435

Error
None
None of the mentioned

Error
k = 2 + 3J
-5
print s.strip()
A function developed using top-down approach
run python
None of the above

Class

Array

str(x)

II only

Runtime error
1

error

33%

Error

None of the above

(”, ‘cd’, ”)

Error

ab12ed2

3 44

None of the above


none of the mentioned
Choice 5

the current time in milliseconds since midnight, January 1, 1970 GMT (the Unix time)

S-ar putea să vă placă și