Python 3.4 Fiverr Skills Тест

Which of the following options are the correct general socket methods?

s.send()
socket.gethostname()
s.bind()
s.accept()

Which of the following options is a correct syntax of the "AttlistDeclHandler" method?

AttlistDeclHandler(elname, attname, base, required)
AttlistDeclHandler(elname, attname, base, default, systemId)
AttlistDeclHandler(elname, attname, type, base)
AttlistDeclHandler(elname, attname, type, default, required)

What will be the correct output of the following Python language code?
from collections import OrderedDict
od = OrderedDict()
od['a'] = 1
od['b'] = 2
od['c'] = 3
od['d'] = 4

for key, value in od.items():
    print("10")
od.pop('c')
for key, value in od.items():
    print("01")
od['c'] = 3
for key, value in od.items():
    print(key, value+2)

10
10
10
10
01
01
01
a 3
b 4
d 6
c 5

10
10
10
10
01
01
01
01
a 3
b 4
d 5
c 6

10
10
10
10
01
01
01
a 1+2
b 2+2
d 3+2
c 4+2

10
10
10
10
01
01
01
a 1+2
b 2+2
d 4+2
c 3+2

What will be the correct output of the following Python code?
class St:
    stm = 'B'
    stm = 'A'
    def __init__(self, r):
        self.r = r
a = St(101)
b = St(102)
 
print(a.stm)
print(b.stm)
print(a.r)
print(St.stm)

A
A
102
A

B
B
102
B

B
B
101
B

A
A
101
A

Analyse the given Python code and choose the correct output from the given options.
pdata = 50
try:
    pdata = pdata/0
except ZeroDivisionError:
    print('0 ', end = '')
else:
    print('1', end = '')
try:
    pdata = pdata/5
except:
    print('1', end = '')
else:
    print('0', end = '')

0 1
0 0
1 0
1 1

The items() method in Python is used for returning the list with all dictionary keys and values.

True
False

This question is based on the graphic shown below.
Choose the correct output of the given Python code.

5 2
8 2
5 3
8 3

Analyse the given Python code and answer the question that follows.
import math

a = math.pi/6
b = 3
c = 4
print (math.tan(a))
print ("result = ", end="")
print (math.hypot(b,c))

What will be the correct output of the above Python code?

0.4773502691896257
result = 4.0

0.5773502691896257
result = 5.0

0.6773502691896257
result = 6.0

0.7773502691896257
result = 7.0

Which of the following port numbers is used for the Telnet protocol in Python?

20
23
25
70

Find the output of the following Python code and choose the correct answer from the given options.
n1 = 1.5
n2 = 6.3
s = float(n1) + float(n2)
print('{0}'.format(s))
s //= 3
print(s)

7.8
23

4 7.8
10.8

7.8
9.0

7.8
2.0

In relation to the exceptions in Python, which of the given exceptions is raised when a generated error code does not fall into any category?

NotImplementedError
TypeError
RuntimeError
SystemError

This question is based on the graphic shown below.
The Python code given in Figure 1 of the image was supposed to give the output that is given in Figure 2, but lines number 14 and 24 are coded incorrectly. Choose the correct lines from the following options that will replace both the lines to obtain the desired output.

Line 14: a -= 1
Line 24: while e>=1:

Line 14: a += 1
Line 24: while d>=1:

Line 14: a += 1
Line 24: while e>=1:

Line 14: a -= 1
Line 24: while d>=1:

This question is based on the graphic shown below.
Choose the correct output of the given Python code.

True

False

true
Angee

False
Angee

0

1

0
Angee

1
Angee

Which two of the following interface objects cannot have child nodes?

NodeList
ProcessingInstruction
Node
Element
Comment

Which of the following options is not a server socket method?

bind()
listen()
connect()
accept()

What will be the correct output of the following Python code?
List = [5, 2, 3, 4, 2, 6, 2, 2, 2, 1]

print(sum(List)+List.count(1)+len(List)+List.index(2)+List.index(2,2)+min(List)+max(List))

50
51
52
54.5
52.4

This question is based on the graphic shown below.
Find the output of the python code given in Figure 1 of the image and choose the correct answer from the options given in Figure 2 of the same image.

(i)
(ii)
(iii)

What will be the correct output of the following Python code?
x = 5.2
x **= 3
print(x)

125
140.608
45
15.602

What will be the correct output of the following Python code?
import bisect

# initializing list
li = [1, 3, 4, 4, 4, 6, 7]

print ("Output = ", end="")
print (bisect.bisect(li, 4)+bisect.bisect_left(li, 4)+bisect.bisect_right(li, 4, 0, 4))

Output = 10
Output = 11
Output = 12
Output = 13

What will be the correct output of the following Python code?

def f():
    print (s)
    s = "Me too."
    print (s)

s = "Hi"
f()
print (s)


Hi
Me Too.

Hi
Me Too.
Hi

Me Too.
Hi
Hi

Code will give a compilation error.

Which of the given shell expressions in Python 3.4.2 will give an error?

 >>>'hi';
>>>'hello';
>>>Good morning;
>>>''Good evening'';

This question is based on the graphic shown below.
What will be the correct output of the given Python code?

dasyunr12
rnuysad12
dasyonr6
rnoysadI6

Which of the following lines of code results in a compilation error?
1. c1 = { 'A' : 'B', 'C' : 19 }
2.  c2 = { 'ID' , 47 }
3.  sequ = ('A', 'C', 'D')
4.  c1.update(c2)
5.  print (str(c1))
6.  ct = dict.fromkeys(sequ,5)
7.  print (str(ct))

Line number 1
Line number 2
Line number 4
Line number 6

Which of the following Python/C API functions will NOT always return NULL?

PyObject* PyErr_Format(PyObject *exception, const char *format, ...)
PyObject* PyErr_SetFromErrno(PyObject *type)
PyObject* PyErr_SetFromErrnoWithFilename(PyObject *type, const char *filename)
PyObject* PyErr_SetFromWindowsErr(int ierr)
PyObject* PyErr_SetExcFromWindowsErrWithFilename(PyObject *type, int ierr, const char *filename)
PyObject* PyErr_NewException(char *name, PyObject *base, PyObject *dict)

When does the string method: isalnum() return true?

When the string contains at least one character and all the characters in it are alpha-numeric.
When the string is empty.
When the string contains alphabetical characters along with at least one special character.
When the string contains numeric characters along with at least one special character.

What will be the output of the following function in Python 3.4 shell?
float('1e-003')

0.01
0.003
0.001
0.03

In relation to the exceptions in Python, which of the given exceptions is raised when an identifier is NOT found in the global or local namespace?

LookupError
IndexError
KeyError
NameError

What will be the output of the following program?
i = [12, 9, 14]
k = [7, 16, 11]
for j in i[:]:
   for m in k[:]:
      if(j%m == 0):
         j = j // 2
         m = m / 2
         print (j, m)
      else:
         j = j + m
         m = m - j
         print (j, m)

19 -12
35 -19
46 -36
16 -9
8 8
19 -8
7 3.0
21 -7
34 23

19 -12
35 -19
46 -35
16 -9
8 8
19 -8
7 3.5
73 -7.5
34 23

19 -12
35 -19
47 -35
16 -19
8 -8.0
19 -8.5
7 3.5
23 -7
34 23

19 -12
35 -19
46 -35
16 -9
8 8.0
19 -8
7 3.5
23 -7
24 -22

This question is based on the graphic shown below.
What will be the output of the given Python code?

first= Ajay , Second: 100000
first= Amit , Second: 200000

first= Ajay , Second: 100000
first= Amit , Second: 200000
value = 2

first= Ajay , Second: 100000
first= Amit , Second: 200000
value = 3

It will give an error.

What will be the output of the following program?
def country(*abc):

  if len(abc) == 1:
    item = abc[0]
    def f(obj):
      return obj[item]
  else:
    def f(obj):
      return tuple(obj[item] for item in abc)
  return f

selection = []
selection = country(slice(2, None))('AUSTRALIA')
print (selection)

AU
USTARLIA
STRALIA
ALIA

Find the output of the following Python code and choose the correct answer from the given options.
ast = [2, 1, 3, 5, 3, 8]
ast.sort()
print (end="")
for i in range(0, len(ast)):
    print(ast[i]*2, end=" ")
print("\r")
ast.reverse()
print (end="")
for i in range(1, len(ast)):
    print(ast[i]+3, end=" ")

2 4 6 6 10 16
8 6 6 5 4

2 4 6 6 10 16
11 8 6 6 5 4

1 2 3 3 5 8
11 8 6 6 5 4

2 4 6 6 10 16
8 6 6 5 4 2

This question is based on the graphic shown below.
Consider the Python code in Figure 1 of the given image and choose its correct output from Figure 2.

(a)
(b
(c)

This question is based on the graphic shown below.
In Python 3.4.2 shell, what will be the output of the given code?

[-1, 435, 1123.5, 5678.2]
[-1, 1123.5, 5678.2]
[-1, 1, 5678.2]
[-1, 1, 1123.5, 5678.2]

Which two of the following dictionary objects return "0" on success and "-1" on failure?

int PyDict_SetItem(PyObject *p, PyObject *key, PyObject *val)PyObject*
PyDict_GetItemWithError(PyObject *p, PyObject *key)
PyObject* PyDict_New()
int PyDict_DelItemString(PyObject *p, const char *key)

This question is based on the graphic shown below.
If the id's of 'a1', 'a2' and 'a3' in the given Python code are 3012123901, 3012123902 and 3012123903 respectively, then what will be the output of the code?

3012123901 3012123901 3012123901
ajus angee

3012123901 3012123902 3012123901
ajus angee
ajus angee

ajus angee
ajus angee

ajus angee

In which of the following modes of files, the 'tell()' function returns an opaque number that gives the current position of the file object?

binary mode
text mode
both binary and text modes

This question is based on the graphic shown below.
Analyse the Python code given in Figure 1 of the image and choose the correct answer from the options given in Figure 2 of the same image.

(i)
(ii)
(iii)
(iv)

Analyse the given Python code and answer the question that follows.
import math

a = -10
b = 5.5
c = 15
d = 5

print (math.copysign(6.5, -10))
print (end="")
print (math.gcd(5,15))

What will be the correct output of the above Python code?

-4.5
5

-5.5
10

-6.5
5

-6.5
10

In Python, which of the following options is the correct exception that is raised when the next() method of an iterator does not point to any object?

SystemExit
StandardError
StopIteration
None of the above.

What will be the correct output of the following Python code?

class X(object):
    def __init__(self,a):
        self.num = a
    def dbup(self):
        self.num *= 2

class Y(X):
    def __init__(self,a):
        X.__init__(self, a)
    def tpup(self):
        self.num*= 3

obj = Y(4)
print(obj.num*2/1)

obj.dbup()
print(obj.num*3/2)

obj.tpup()
print(obj.num/2*3)

 6.0
12.0
34.0

8.0
12.0
36.0

8.0
12.0
34.0

6.0
12.0
36.0

Which of the following modules are used with the FTP protocol in Python?

ftplib
smtplib
urllib
httplib

What will be the correct output of the following Python language code?
import multiprocessing

result = []
def s_p(mp):
    global result
    for num in mp:
        result.append(num * num+1)
    print("{}".format(result))
if __name__ == "__main__":
    mp = [1,2,3,4]
    p1 = multiprocessing.Process(target=s_p, args=(mp,))
    p1.start()
    p1.join()
    print("{}".format(result))

[2, 5, 10, 17]
[]

[2, 5, 10, 17]

[1, 2, 3, 4, 2, 5, 10, 17]

[1, 2, 3, 4, 2, 5, 10, 17]
[]

What will be the correct output of the following Python code?
def abc(n):
   if n <= 1:
       return n
   else:
       return(abc(n-1) + abc(n-2))
       print("1")
nterms = 13
if nterms <= 0:
   print("0")
else:
   for i in range(nterms):
       x=abc(i)
   print(x+11)

0
1
155
177

Python 3.4 Fiverr Skills Тест 2020