what is the output of the following code?
M=['b' *x for x in range(4)] print(M)
['', 'b', 'bb', 'bbb']
['b,'bb', "bbb', "bbbb']
['b','bb', bbb']
none of these
What is the output of the following?
print(max([1, 2, 3, 4.] [4, 5, 6], [7]))
[4,5, 6
[7]
[1, 2,3, 4]
7
What will be the output of the following Python code?
example = "helle" print(example.rfind("e"))
1
2
4
5
What will be the output of the following pseudo code?
Integer a,b set a=10,b=5 a=a mod(a-6) b=b mod(b-2) print a-b
0
8
File Found Error
File Not Exist Error
File Not Found Error
None of the above
What is the value of the following Python code?
>>>print(36 / 4)
9
9.0
4.0
What is the output of following Python code?
>>print(5*(2//3))
3
3.3
error
What is the output of the following code?
a=set('abc') b=set('cdef') print(a&b)
{'c'}
{'a','b','c','d','e','r'}
{c}
None of these
stack
macro
micro
union
Square
Circle
Parallelogram
Triangle
What will be the output of the following python code?
from math import * floor(11.7)
12
11
11.0
pi
anonymous
lambda
none of the above
val
raise
try
with
What will be the output of the following?
print(sum(1,2,3))
6
none
Execution
Decision
Statement
All of the above
Dictionary
String
Tuple
List
What will be the output of the following Python code
def func(a, b=5, c=10): print('a is', a, 'and b is', b, 'and c is', c) func(13, 17) func(a=2, c=4) func(5,7,9)
(A) a is 13 and b is 15 and c is 10
a is 2 and b is 5 and c is 4
a is 5 and b is 7 and c is 9
(B) a is 13 and b is 17 and cis 10
a is 2 and b is 4 and c is 4
a is 5 and b is 9 and c is 7
(C) a is 13 and b is 17 and c is 10
a is 2 and b is 5 and cis 4
(D) None of the above
option A
option B
option C
option D
list1=[1,3] list2=list1 list1[0]=4 print(list2)
[1, 4]
[1,3, 4]
[4,3]
[1,3]
What will be output for the following code ?
import numpy as np a=np.array([2,3,4,5]) print(a.dtype)
int32
int
float
Task Manager
Task Bar
Program Manager
Device Driver
What is the output of the following
y='klmn' for i in range(len(y)): print(y)
klmn klmn klmn klmn
k
kkk
None of the these
Segments
Modules
Units
All the above
len(["hello",2, 4, 6])
Error
from math import factorial print(math.factorial(5))
120
Nothing is printed
NameError: name 'math' is not defined
Error, the statement should be print factorial(5))
from package import all
from package import *
from package include all
from package include*
What will be the output of the following code snippet?
numbers = (4, 7, 19, 2, 89, 45, 72, 22) sorted_numbers = sorted(numbers) odd_numbers = [x for x in sorted_numbers if x% 2!=0] print(odd_numbers)
[7, 19, 45, 89]
[2, 4, 22, 72]
[4, 7, 19, 2, 89, 45, 72, 22]
[24, 7, 19, 22, 45, 72, 89]
Integer a, b, c Set b= 5, a = 1 c= a & b Print c
Choose the correct function declaration of fun1() so that we can execute the following two function calls successfully.
fun1(25, 75, 55) fun1(10, 20)
def fun1(**kwargs)
def fun1(args*)
No, it is not possible in Python
def fun1(*data)
Compiler
Interpreter
Assembler
x='abcd' for i in x: print(i.upper())
a BCD
abcd
A B CD
import
include
both (A) and (B)
What will be the output of the following expression
x=14 print(x>>2)
14
factorial()
print()
seed()
sqrt()
_x=2
x=3
_xyz_=5
get()
seek()
tell()
cur()
Provides a means of reuse of program code
Provides a means of dividing up tasks
Provides a means of reducing the size of the program
Provides a means of testing individual parts of the program
What is the datatype of x ?
import numpy as np a=np.array([1,2,3,4]) x=a.tolist()
array
tuple
list
Testing
Delivery
Idea
Development
d={3,4,5} for k in d: print(k)
{3, 4, 5},{3, 4, 5}, {3, 4, 5}
345
syntax error
arrow
circle
box
parallelogram
f.seek(-10, 0)
f.seek(10, 0)
f.seek(-10,1)
What is the output of the following code snippet?
print([i.lower() for i in "HELLO"])
hello
['h', 'e', 'l', 'l', 'o']
hel
HELLO
What will be the output of following?
Y=[2,5J,6] Y.sort()
[2,6,5J]
[5J,2,6]
[6,5J,2]
import numpy as np a=np.array([1,2,3,5,8]) b=np.array([0,3,4,2,1]) c=a+b c=c*a print(c[2])
10
21
28
break
pass
continue
Which of the following error is returned by the given code ?
f = open("test.txt","w") f.write(345)
Syntax Error
Type Error
String Error
Run Time Error
What will be the output of the following algorithm for a=5, b-8, c=6 ?
Step 1: Start Step 2: Declare variables a, b and c. Step 3 Read variables a, b and c. Step 4: If a < b If a <c Display a is the smallest number. Else Display c is the smallest number. Else If b <c Display b is the smallest number. Else Display c is the smallest number Step 5:Stop
a is the smallest number
b is the smallest number
c is the smallest number
stop
Control flow
Terminal
Processing
What is the output of following code ?
a = np.array([[1,2,3],[4,5,6]]) print(a.shape)
(2,3)
(3,2)
(1,1)
f.readlines()
f.readline()
f.read()
f.line()
Loop
Process
RAM
CPU
ROM
Control Unit
def s(n1): print(n1) n1=n1+2 n2=4 s(n2) print(n2)
6 4
4 6
4 4
6 6
x=123 for i in x: print(i)
1 2 3
123
What will be the output of following statement ?
>>>"m"+"n1"
'm+nl'
'mn1'
'm n1'
'm'
Both tuples and lists are immutable
Tuples are immutable while lists are mutable
Both tuples and lists are mutable
Tuples are mutable while lists are immutable
5 characters
5 words
5 lines
set
dict
m=0 while m<5: m+=1 if m==3: break else: print(0)
0 1 2 0
0 1 2
0 0 1 0 2
What will be output for the following code?
import numpy as np a=np.array([[1,2,3],[0,1,4]]) print (a.size)
To make a Matrix with all element 0
To make a Matrix with all diagonal element 0
To make a Matrix with first row 0
k^1
k**1
k^ ^1
k^*1
//
?
<
and
write mode
read mode
append mode
Both (A) And (B)
Numbering Python
Number In Python
Numerical Python
f.reads()
f.read(all)
f.read( *)
n=5 while n>0: n-=1 if n==2: continue print(n,end=' ')
5 4 3 1 0
4 3 1 0
4 3 2
Curly Braces
Round Brackets
Indentation
Semicolon
Subtracting two numbers
Comparing two data values
Providing output to the user
Adding two numbers
Java
C
PHP
tuple1=(5,1,7,6,2) tuple1.pop(2) print(tuple1)
(5,1,6,2)
(5,1,7,6)
(5,1,7,6,2)
Program
Flow chart
What will be the output of the following Python code ?
def display(b,n): while n>0: print(b,end='') n=n-1 display('z',3)
zzz
zz
Infinite loop
An exception is thrown
Diamond
A static variable
A global variable
A local variable
An automatic variable
A function that calls itself
A function that calls other functions
Both (A) and (B)
list1.sum(5)
list1.add(5)
listl.append(5)
list1.addelement(5)
import numpy as np
ary=np.array([1,2,3,5,8])
ary=ary+1
print(ary[1])
Quick response code
Same format in which the data is held in memory
ASCII format
Unicode format
.py
.pyth
.python
procedure
function
bug
Which of the following will delete key-value pair for key="tiger" in dictionary?
dic={"lion":"'wild","tiger":"'wild",'cat":"domestic","dog":"domestic"}
del dic("tiger"]
dic["tiger"].delete()
delete(dic.["tiger'])
del(dic.["tiger"])
d1={"abc":5,"def":6,"ghi":7} print(d1[0])
abc
{"abc":5}
Brackets
Catch
def power(x, y=2): r=1 for i in range(y): r=r*x return r print(power(3)) print(power(3,3))
Option A
Option B
Option C
Option D
colon
comma
semicolon
hyphen
Variable
File
Both of the above
Text file
Binary file
what will be output for the following code?
import numpy as np a=np.array([1,2,3,5,8]) print(a.ndim)
what is 'f' in the following statement?
f=open("Data.txt","r")
file name
file handle
Mode of file
file handling
Batter Programming
Optimized Coding
Systematic testing
_val
_try_
write
writelineas
dump
pickle
What will following code segment print
if True or True: if False and True or False: print('A') elif False and False or True and True: print('B') else: print('C') else: print('D')
A
B
D
end
beginning
anywhere in between the file
count()
upper()
strip()
List of tuple
Tuple of List
Array of Tuples
Invalid Type
What will be the output of the following code?
import numpy as np a=np.array([1,2,3]) print(a.ndim)