What will be the output of the following Python code?
x = "abcdef"i = "a"while i in x: print(i, end = " ")
no output
i i i i i i …
a a a a a a …
a b c d e f
int
bool
void
None
def foo(x): x = ['def', 'abc'] return id(x)q = ['abc', 'def']print(id(q) == foo(q))
True
False
Error
x = ['ab', 'cd'] for i in x: x.append(i.upper()) print(x)
[‘AB’, ‘CD’]
[‘ab’, ‘cd’, ‘AB’, ‘CD’]
[‘ab’, ‘cd’]
Infinite Loop
end
beginning
anywhere in between the file
None of the above
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
_x=2
x=3
_xyz_=5
os.rename(existing_name, new_name)
fq.name = ‘new_name.txt’
os.rename(fp, new_name)
os.set_name(existing_name, new_name)
0
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
Yes
No
if / else not used in python
None of the above.
What will be the output?
def fun(a,b=5,c=10): print(a+b+c)fun(2,c=20)
27
17
22
x = 10def fun(): global x x = 20fun()print(x)
10
20
4
5
1
End of List
End of Line
End of Loop
End of Language
def foo(): return total + 1total = 0print(foo())
error
none of the mentioned
Flexibility
Portability
Reliability
Integer
Complex Number
String
a
f
w
t
33
45
35
30
what is 'f' in the following statement?
f=open("Data.txt","r")
file name
file handle
Mode of file
file handling
x = "abcdef" i = "a" while i in x: print('i', end = " ")
i i i i i i … infinite Time
Compiled only
Interpreted
Assembly
Machine
val
raise
try
with
What is the output?
f = open("test.txt", "w")f.write("Python")print(f.tell())f.close()
6
7
Lists
Dictionary
Tuples
Class
csv.reader(file)
csv.read(file)
csv.readcsv(file)
csv.readcsvdata(file)
What will be the output after following statements?
x = 2if x < 5: print(x)else: pass
2 3 4
1 2 3 4
2
None of These
What will the following code output?
x=0if x: print("True")else: print("False")
.python
.py
.p
.pyt
What will be the output of the following Python code ?
def display(b,n): while n>0: print(b,end='') n=n-1display('z',3)
zzz
zz
Infinite loop
An exception is thrown
list
tuple
class
dictionary
Passing –O when running python
Assertions are disabled by default
Both A and B are wrong
Assertions cannot be disabled in python
float
str
set
Free and Open Source
Freeware
Open source
Shareware
What is the value of the following Python code?
>>>print(36 / 4)
9
9.0
4.0
i = 1while True: if i%2 == 0: break print(i) i += 2
1 2
1 2 3 4 5 6 …
1 3 5 7 9 11 … infinite time
student
s12
123
_123
One
Two
Three
Any Number of Times
f.readlines()
f.readline()
f.read()
f.line()
End Of Folder
Exit Open File
End Of File
Error On File
Positional
Keyword
Default
Variable
pi
anonymous
lambda
none of the above
What will be the output of the following expression ?
x =4print(x<<2)
16
Python Interpreter.
Python compiler
Python Volatile machine
Portable virtual machine
ab
rw
a+
r+
dict
32
3
8