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)
eval
nonlocal
assert
finally
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.
open_file()
file_open()
open()
read_file()
f.readlines()
f.readline()
f.read()
f.line()
What will be the output of the following Python code?
i = 0while i < 3: print(i) i += 1else: print(0)
0 1 2 3 0
0 1 2 0
0 1 2
error
File Found Error
File Not Exist Error
File Not Found Error
None of the above
Passing –O when running python
Assertions are disabled by default
Both A and B are wrong
Assertions cannot be disabled in python
ab
rw
r+
w+
What will be the output of the following code?
f=open("demo.txt","r")print(f.tell())
1
2
-1
0
for i in range(5): if i == 5: break else: print(i)else: print("Here")
0 1 2 3 4 Here
0 1 2 3 4 5 Here
0 1 2 3 4
1 2 3 4 5
What will be the output of the following code ?
f=open("demo.txt","w+")f.write("Welcome to python")f.seek(5)a=f.read(5)print(a)
Welco
me to
Welcome to Python
e to
Read two words from file
Read two line from file
Read two character / two bytes
count the number of '2' in file
Built in datatype
Derived datatype
Concrete datatype
Abstract datatype
Comma Space Value
Comma Separated Value
Common spaced Value
Compact Structure View
x = 'abcd'for i in range(len(x)): print(i)
a b c d
0 1 2 3
1 2 3 4
try
Brackets
Indentation
Catch
What is the output of the following code?
def s(n1): print(n1) n1=n1+2n2=4s(n2)print(n2)
6 4
4 6
4 4
6 6
32
64
35
29
none
write mode
read mode
append mode
Both (A) And (B)
x = ['ab', 'cd'] for i in x: x.append(i.upper()) print(x)
[‘AB’, ‘CD’]
[‘ab’, ‘cd’, ‘AB’, ‘CD’]
[‘ab’, ‘cd’]
Infinite Loop
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
End of File
End of Line
End of Statement
End of program
10
1.0
f.read(5)
f.read()=5
f.readline(5)
f.readlines(5)
Graphical
Cross-Platform
Platform Dependent
All of these
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
None of these
os.rename(existing_name, new_name)
fq.name = ‘new_name.txt’
os.rename(fp, new_name)
os.set_name(existing_name, new_name)
End of List
End of Loop
End of Language
list
tuple
class
dictionary
What will the following code output?
a=‘INFOMAX’ a=10 print(type(a))
<class 'int'>
<class ‘str'>
<class ‘bool'>
Error
Use multiple write() statements.
Use writelines() method.
Use writeLine() method.
Use append() method.
i = 1while True: if i%7 == 0: break print(i) i += 1
1 2 3 4 5 6 7
none of the mentioned
a+
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()
Dictionary
String
Tuple
List
>=
<=
=
!=
Comments
Expressions
Tokens
Flow of control
Required arguments
Keyword arguments
Default arguments
Variable-length arguments
What will be the output after following statements?
x = 2if x < 5: print(x)else: pass
2 3 4
None of These
f.reads()
f.read(all)
f.read( *)
English
PHP
C
All of the above
i = 2while True: if i%3 == 0: break print(i) i += 2
2 4 6 8 10 …
2 4
2 3
Number
Slice
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
Lists
Tuples
Class
4
8
16
end
beginning
anywhere in between the file
read()
readline()
readlines()
load()