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
End of File
End of Line
End of Statement
End of program
100
-100
-101
101
What will be written to the file?
f = open("test.txt", "w")f.write("ABC")f.write("DEF")f.close()
ABC
DEF
ABCDEF
Error
What is the value of the following Python code?
>>>print(36 / 4)
9
4
9.0
4.0
0
1
10
1.0
list
tuple
class
dictionary
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
sets the file's current position at the offset
sets the file's previous position at the offset
sets the file's current position within the file
None of these
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.
readall()
read()
readcharacter()
readchar()
.py
.python
.p
int
null
None
An exception is thrown without the return statement
Read mode
Write mode
Append mode
Binary mode
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
8
True
False
readlines()
readline()
readlist()
What will the following code output?
a=‘INFOMAX’ a=10 print(type(a))
<class 'int'>
<class ‘str'>
<class ‘bool'>
Hello
949227
"2'
factorial()
print()
seed()
sqrt()
End of List
End of Loop
End of Language
Dictionary
String
Tuple
List
i = 2while True: if i%3 == 0: break print(i) i += 2
2 4 6 8 10 …
2 4
2 3
softspace
mode
closed
rename
Built in datatype
Derived datatype
Concrete datatype
Abstract datatype
Lists
Tuples
Class
Data is appended
Error occurs
Old content is erased
Nothing happens
Both of the above
None of the above
raw_input
input
eval
accept
Compiled only
Interpreted
Assembly
Machine
ab
rw
r+
w+
x = 'abcd'for i in range(len(x)): print(i)
a b c d
0 1 2 3
1 2 3 4
f.reads()
f.read()
f.read(all)
f.read( *)
bool
void
Interactive Mode
Script Mode
Combination of Interactive and Script modes
All of these
x = "abcdef" i = "a" while i in x: print('i', end = " ")
no output
i i i i i i … infinite Time
a a a a a a …
a b c d e f
load()
Required arguments
Keyword arguments
Default arguments
Variable-length arguments
What will be the output of the following code?
f=open("demo.txt","r")print(f.tell())
2
-1
What will be the output of the following pseudocode, where ^ represent XOR operation ?
Integer a, b, cset b = 4, a = 3c =a ^ bPrint c
3
5
7
Graphical
Cross-Platform
Platform Dependent
What is the return type of following function ?
def func1(): return 'mnp',22print(type(func1()))
f = open("data.txt", "a")
f = Open("data.txt", "ab")
f= new("data.txt", "a")
open("data.txt", "a")
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
_x=2
x=3
_xyz_=5
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
~
|
&
^
f.readlines()
f.readline()
f.line()
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 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