Interactive Mode
Script Mode
Combination of Interactive and Script modes
All of these
It is used for object serialization
It is used for object de-serialization
change the string value to number
extract the list element in simple variable
raise
goto
try
except
What will be the output of the following Python code snippet?
print(not(3>4))print(not(1&1))
True True
True False
False True
False False
5 characters
5 words
5 lines
None of the above
1995
1972
1981
1991
What will be the output of the following Python code?
i = 1while False: if i%2 == 0: break print(i) i += 2
1
1 3 5 7 …
1 2 3 4 …
Nothing will be printed
Required arguments
Keyword arguments
Default arguments
Variable-length arguments
.python
.py
.p
.pyt
def foo(x): x = ['def', 'abc'] return id(x)q = ['abc', 'def']print(id(q) == foo(q))
True
False
None
Error
int
bool
void
a_=3
_a=3
a?=3
File Found Error
File Not Exist Error
File Not Found Error
None of these
What will be the output of the following expression ?
x =4print(x<<2)
4
16
6
2
Infinite
NULL
What is the output of the following program:
i = 0while i < 3: print (i) i=i+1 print (i+1)
0 2 1 3 2 4
0 1 2 3 4 5
Infinite loop
0 1 2 3
Read mode
Write mode
Append mode
Binary mode
100
-100
-101
101
x = 'abcd'for i in range(len(x)): print(i)
a b c d
error
1 2 3 4
32
64
35
29
Python Interpreter.
Python compiler
Python Volatile machine
Portable virtual machine
os.rename(existing_name, new_name)
fq.name = ‘new_name.txt’
os.rename(fp, new_name)
os.set_name(existing_name, new_name)
What is the output of the following code?
x = 50def func (x): x = 2func (x)print ('x is now', x)
x is now 50
x is now 2
x is now 100
x = 'abcd'for i in range(len(x)): print(i.upper())
write
output
send
dump
softspace
mode
closed
rename
It is used for object deserialization
All of the mentioned
None of the mentioned
null
An exception is thrown without the return statement
x = 'abcd' for i in range(len(x)): print(x) x = 'a'
a
abcd abcd abcd abcd
a a a a
none of the mentioned
What will be the output after the following statements?
a = 0b = 3while a + b < 8: a += 1 print(a, end='')
0 1 2 3 4
1 2 3 4 5 6
1 2 3 4 5
in
is
assert
All
x = "abcdef"i = "i"while i in x: print(i, end=" ")
no output
i i i i i i …
a b c d e f
abcdef
\a
\t
\n
\b
What is the return type of following function ?
def func1(): return 'mnp',22print(type(func1()))
List
Dictionary
String
Tuple
0
Null
Arbitary value
Read two words from file
Read two line from file
Read two character / two bytes
count the number of '2' in file
Free and Open Source
Freeware
Open source
Shareware
The variables used inside function are called local variables.
The local variables of a particular function can be used inside other functions, but these cannot be used in global space.
The variables used outside function are called global variables.
In order to change the value of global variable inside function, keyword global is used.
Both Interactive Mode or Script Mode
None of These
Curly Braces
Round Brackets
Indentation
Semicolon
def foo(): total += 1 return totaltotal = 0print(foo())
f.read(5)
f.read()=5
f.readline(5)
f.readlines(5)
Expression
Portability
Reliability
What does the following code print ?
if 2 + 5 == 8: print("TRUE")else: print("FALSE")print("TRUE")
TRUE
TRUE FALSE
TRUE TRUE
FALSE TRUE
What is the value of the following Python code?
>>>print(36 / 4)
9
9.0
4.0
Passing –O when running python
Assertions are disabled by default
Both A and B are wrong
Assertions cannot be disabled in python
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 the following code output?
x=0if x: print("True")else: print("False")
write()
append()
add()
insert()