Compilation/interpretation phase
Logical analysis
Program execution only
Documentation phase
What will be the output of the following Python code?
i = 2while True: if i%3 == 0: break print(i) i += 2
2 4 6 8 10 …
2 4
2 3
error
Graphical
Cross-Platform
Platform Dependent
All of these
Integer
Complex Number
None
String
w+
a
x
r+
colon
comma
semicolon
hyphen
4
8
16
32
f.reads()
f.read()
f.read(all)
f.read( *)
True
False
Error
ab
rw
a > b
b == 0
while (b != 0)
a == b
What is the value of the following Python code?
>>>print(36 / 4)
9
9.0
4.0
csv.reader(file)
csv.read(file)
csv.readcsv(file)
csv.readcsvdata(file)
What will be the output?
f = open("test.txt", "w")f.write("Python")f.seek(0)print(f.read())
Python
Empty String
UnsupportedOperation Error
int
bool
void
What will be printed?
x = 5def f(): global x x = 10f()print(x)
5
10
execute python
go python
python
run python
What is the output?
f = open("test.txt", "w")f.write("Python")print(f.tell())f.close()
6
7
0
i = 1while True: if i%2 == 0: break print(i) i += 2
1
1 2
1 2 3 4 5 6 …
1 3 5 7 9 11 … infinite time
.py
.python
.p
None of these
read binary
write binary
append binary
read write
What is the output of the following code ?
def fun(a, b=6): a=a+b print(a)fun(5, 4)
11
Python is proprietary software.
Python is open-source software.
Python is hardware dependent.
Python cannot run on Linux.
What is the return type of following function ?
def func1(): return 'mnp',22print(type(func1()))
List
Dictionary
Tuple
extern
static
global
nonlocal
What is the output of following?
f = open("test.txt", "r")f.seek(0)print(f.tell())
File size
Variable names in Python cannot start with number. However, it can contain number in any other position of variable name.
Variable names can start with an underscore.
Data type of variable names should not be declared.
None of the above.
for i in range(5): if i == 3: continue print(i, end=" ")
0 1 2 3 4
0 1 2 4
1 2 3 4
0 1 2
yes
no
machine dependent
none of the mentioned
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
x = 'abcd'for i in range(len(x)): print(i.upper())
a b c d
0 1 2 3
f = open("data.txt", "a")
f = Open("data.txt", "ab")
f= new("data.txt", "a")
open("data.txt", "a")
float
str
set
def fun(a, b=5): print(a+b)fun(10, 20)
15
30
25
One
Two
Three
Any Number of Times
What will be the output after the following statements?
a = 0b = 3while a + b < 8: a += 1 print(a, end='')
1 2 3 4 5 6
1 2 3 4 5
Hello
949227
"2'
x = 10def fun(): global x x = 20fun()print(x)
20
def disp(*arg): for i in arg: print(i)disp(name="Rajat", age="20")
TypeError
Rajat 20
Name age
or
equal
and
not
31 characters
63 characters
No limit but 79 characters for better redability
All of the above.
in
is
assert
All
Number
Slice
33
45
35
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}
What is the output of below program ?
def say(message, times =1): print(message * times)say("Hello")say("Word",5)
Hello WordWordWordWordWord
Hello Word 5
Hello Word,Word,Word,Word,Word
Hello HelloHelloHelloHelloHello
What will be the output after following statements?
x = 2if x < 5: print(x)else: pass
2 3 4
2
None of These