Use multiple write() statements.
Use writelines() method.
Use writeLine() method.
Use append() method.
extern
static
global
nonlocal
Number
String
List
Slice
What will be the output?
def fun(a, b=5): print(a+b)fun(10, 20)
15
30
25
Error
os.rename(existing_name, new_name)
fq.name = ‘new_name.txt’
os.rename(fp, new_name)
os.set_name(existing_name, new_name)
r
rb
w
r+
seek()
read()
close()
tell()
What will be the output of the following Python code?
x = 'abcd'for i in range(len(x)): print(i.upper())
a b c d
0 1 2 3
error
1 2 3 4
x = 'abcd'for i in range(len(x)): print(i)
5
1
10
0
w+
a
x
x = "abcdef"while i in x: print(i, end=" ")
a b c d e f
abcdef
i i i i i i …
readall()
readcharacter()
readchar()
Integer
Complex Number
None
What will be the output of the following pseudocode, where ^ represent XOR operation ?
Integer a, b, cset b = 4, a = 3c =a ^ bPrint c
4
3
7
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
What will be the output of the following Python code snippet?
x = 'abcd'for i in range(len(x)): i.upper()print (x)
none of the mentioned
100
-100
-101
101
int
bool
void
Write
Read
Append
Read and Write Both
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.
file_object=open(file_name,mode)
open(file_object,file_name,mode)
file_open(file_object,file_name,mode)
file_object=file_open(file_name,mode)
True
False
Infinite
NULL
33
45
35
What is the output of following code?
x = 1y = 2z = 3print(x < y < z == True)
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.
or
equal
and
not
What is the output of following?
for i in range(5): if i == 3: continue print(i, end=" ")
0 1 2 3 4
0 1 2 4
0 1 2
Yes
No
if / else not used in python
Class
Dictionary
Tuple
f = open('data.txt'); f.read()
f = open('data.txt','r'); f.read(n)
myfile = open('data.txt'); f.readline()
f= open('data.txt'); f.readlines()
f.readlines()
f.readline()
f.read()
f.line()
ar+
null
An exception is thrown without the return statement
What will be printed?
i = 0
while i < 3: i += 1 if i == 2: continue print(i, end=" ")else: print("END")
1 2 3 END
1 2 3
1 3
1 3 END
32
64
29
What will be the output of following?
Y=[2,5J,6]Y.sort()
[2,6,5J]
[5J,2,6]
[6,5J,2]
1.0
f = open("test.txt", "w")f.write("Python")f.seek(0)print(f.read())
Python
Empty String
UnsupportedOperation Error
Required Argument
Keyword Argument
Default Argument
Decimal Argument
What will be the output of the following expression ?
x =4print(x<<2)
16
6
2
Tells you the current position within the file.
Tells the size of file you read
Tells the start position of the file.
Tells the end position of the file.
reference_point indicates the current position of the file object
reference_point indicates the starting position of the file object
reference_point indicates the ending position of the file object
None of the above
write
output
send
dump
It is used for object serialization
It is used for object deserialization
All of the mentioned
None of the mentioned
f.seek(-10, 0)
f.seek(10,0)
f.seek(-10, 1)
x = "abcdef"i = "i"while i in x: print(i, end=" ")
no output
float
dict
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
None of these
It is used for object de-serialization
change the string value to number
extract the list element in simple variable