Local Batch 2
Local Batch 2
2.Which of the following TCP sockets is most commonly used for the web protocol
(HTTP)?
a)80
b)23
c)22
d)119
e)25
a)import tcp-socket
b)open socket
c)import tcp
d)import socket
e)_socket = true
4.In a client-server application on the web using sockets, which must come up
first?
<person>
<name>Chuck</name>
<phone type="intl">
+1 734 303 4456
</phone>
<email hide="yes" />
</person>
a)person
b)name
c)email
d)type
e)hide
6.What is the method to cause Python to parse XML that is stored in a string?
a)xpath()
b)parse()
c)extract()
d)fromstring()
e)readall()
a)Yes
b)No
a)count
b)upper
c)strip()
d)All of the above
11.
What will be the output of the following code snippet?
a = "4, 5"
nums = a.split(',')
x, y = nums
int_prod = int(x) * int(y)
print(int_prod)
a)20
b)45
c)54
d)4,5
12.
What will be the output of the following code snippet?
a)pYtHoN PrOgRaMmInG
b)Python Programming
c)python PROGRAMMING
d)PYTHON PROGRAMMING
def is_even(number):
message = f"{number} is an even number" if number % 2 == 0 else f"{number} is
an odd number"
return message
print(is_even(54))
a = [1, 2]
print(a * 3)
a)Error
b)[1,2]
c)[3,6]
d)[1,2,1,2,1,2]
a = [1, 2 , 3 , 4 , 5]
sum = 0
for ele in a:
sum+= ele
print(sum)
a)15
b)0
c)20
d)None of these
a = [1, 2, 3]
a = tuple(a)
a[0] = 2
print(a)
a)[2,2,3]
b)(2,2,3)
c)(1,2,3)
d)Error
17.
What will be the output of the following code snippet?
a)129
b)8
c)121
d)None of the above
round(4.576)
a) 4
b) 4.6
c) 5
d) 4.5
def addItem(listParam):
listParam += [1]
mylist = [1, 2, 3, 4]
addItem(mylist)
print(len(mylist))
a) 5
b) 8
c) 2
d) 1
x = 'abcd'
for i in range(len(x)):
print(i)
a) error
b) 1 2 3 4
c) a b c d
d) 0 1 2 3
i = 0
while i < 5:
print(i)
i += 1
if i == 3:
break
else:
print(0)
a) error
b) 0 1 2 0
c) 0 1 2
d) none of the mentioned
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
a) A[2][1]
b) A[1][2]
c) A[3][2]
d) A[2][3]
def foo(x):
x[0] = ['def']
x[1] = ['abc']
return id(x)
q = ['abc', 'def']
print(id(q) == foo(q))
a) Error
b) None
c) False
d) True
a)getcwd()
b)isdir()
c)isfile()
d)abspath()
a)isexists()
b)exists()
c)exist()
d)ifexist()
26.Which of these files (refresh in the browser to get the new data.)
a)spider.json
b)spjson.py
c)spreset.py
d)spdump.py
a)gmane.py
b)gmodel.py
c)gbasic.py
d)gword.py
31.Which of these data types is written the most versatile datatype in python.
(ONE OR MORE)
a)List
b)String
c)Int
d)Tuple
32.Code
L = ['a','b','c','d']
print("".join(L))L = ['a','b','c','d']
a)Error
b)None
c)abcd
d)['a','b','c','d']
33.Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.pop(1)?
A
[3, 4, 5, 20, 5, 25, 1, 3]
B
[1, 3, 3, 4, 5, 5, 20, 25]
C
[3, 5, 20, 5, 25, 1, 3]
D
[1, 3, 4, 5, 20, 5, 25]
>>>t=(1,2,4,3)
>>>t[1:-1]
a) (1, 2)
b) (1, 2, 4)
c) (2, 4)
d) (2, 4, 3)
d = {"john":40, "peter":45}
d["john"]
a) 40
b) 45
c) “john”
d) “peter”
37. What will be the output of the following Python code?
numberGames = {}
numberGames[(1,2,4)] = 8
numberGames[(4,2,1)] = 10
numberGames[(1,2)] = 12
sum = 0
for k in numberGames:
sum += numberGames[k]
print len(numberGames) + sum
a) 30
b) 24
c) 33
d) 12
40.What provides two way communication between two different programs in a network.
A. socket
B. port
C. http
D. protocol
L=[12,32,40]
print(L[3])
a)IndexError
b)Zero division Error
c)TypeError
d)No Error
44.Select the correct mode to open a file for appending as well as reading
a)a+
b)ar
c)rw
d)ar+
a)ftell()
b)fseek()
c)tell()
d)seek()
46.Code
import sqlite3
conn = sqlite3.connect('College.sqlite3')
cur = conn.cursor() line1
cur.execute('DROP TABLE IF EXISTS Student')line2
cur.execute('CREATE TABLE Student(StudentID INTEGER, StudentNName TEXT)')line3
courr.close() line4
a)5
b)6
c)7
str1 = 'Welcome'
print (str1[:6] + ' PYnative')
a)Welcome PYnative
b)WelcomPYnative
c)Welcom PYnative
d)WelcomePYnative
print(stringList[1] == myString)
print(stringList[1] is myString)
a)
True
False
b)
True
True
c)
False
True
d)
False
False