What is the output of the function shown below random module has already been imported )? random choice ( Sun ) *?

121 What is the output of the code shown below if the system date is 18th August, 2016?

tday=datetime.date.today()

print(tday.month())

View Answer

122 What is the output of the following code, if the time module has already been imported?

def num(m):

t1 = time.time()

for i in range(0,m):

print(i)

t2 = time.time()

print(str(t2-t1))

num(3)

A 1 2 3 The time taken for the execution of the code

B 3 The time taken for the execution of the code

C 1 2 3 UTC time

D 3 UTC time

View Answer

Answer: 1 2 3 The time taken for the execution of the code

123 What is the output of the code shown below?

l=[-2, 4]

m=map(lambda x:x*2, l)

print(m)

A [-4, 16]

B Address of m

C Error

D None of the given choices

View Answer

124 What is the output of the following?

def to_upper(k):

k.upper()

x = ['ab', 'cd']

print(list(map(to_upper, x)))

A [‘AB’, ‘CD’].

B [‘ab’, ‘cd’].

C none of the mentioned

D errort

View Answer

Answer: none of the mentioned

125 What is the output of the following?

x = [12, 34]

print(len(''.join(list(map(str, x)))))

View Answer

126 What is the output of the following?

x = abcd

print(list(map(list, x)))

A [‘a’, ‘b’, ‘c’, ‘d’].

B [‘abcd’].

C [[‘a’], [‘b’], [‘c’], [‘d’]].

D none of the mentioned

View Answer

Answer: none of the mentioned

127 Is the output of the function abs() the same as that of the function math.fabs()?

A sometimes

B always

C never

D none of the mentioned

View Answer

128 What is returned by math.isfinite(float(‘nan’))?

A True

B False

C None

D error

View Answer

129 What is the default base used when math.log(x) is found?

A e

B 10

C 2

D none of the mentioned

View Answer

130 What does os.getlogin() return?

A name of the current user logged in

B name of the superuser

C gets a form to login as a different user

D all of the above

View Answer

Answer:name of the current user logged in

131 What is the output of the line of code shown below?

pickle.HIGHEST_PROTOCOL

View Answer

132 Which of the following is true about top-down design process?

A The details of a program design are addressed before the overall design

B Only the details of the program are addressed

C The overall design of the program is addressed before the details

D Only the design of the program is addressed

View Answer

Answer: The overall design of the program is addressed before the details

133 What is the output of the function shown below (random module has already been imported)?

random.choice('sun')

A sun

B u

C either s, u or n

D error

View Answer

134 Which of the following will not be returned by random.choice(“1 ,”)?

A 1p

B (space)

C ,

D none of the mentioned

View Answer

Answer: none of the mentioned

135 What is the output of this code?

import sys

eval(sys.stdin.readline())

"India"

A India5

B India

C ‘India\n’

D ‘India’

View Answer

136 Which of the following functions does not accept any arguments?

A position

B fillcolor

C goto

D setheading()

View Answer

137 What is the output of the following code?

import turtle

t=turtle.Pen()

t.right(90)

t.forward(100)

t.heading()

A 0.0

B 90.0

C 270.0

D 360.0

View Answer

138 The output of the code shown is similar to the alphabet _______________

import turtle

t=turtle.Pen()

t1=turtle.Pen()

t2=turtle.Pen()

t.forward(100)

t1.forward(100)

t2.forward(100)

t1.left(90)

t1.forward(75)

t2.right(90)

t2.forward(75)

View Answer

139 Which of these definitions correctly describes a module?

A Denoted by triple quotes for providing the specification of certain program elements

B Design and implementation of specific functionality to be incorporated into a program

C Defines the specification of how it is to be used

D Any program that reuses code

View Answer

Answer: Design and implementation of specific functionality to be incorporated into a program

140 Which of the following is not an advantage of using modules?

A Provides a means of reuse of program code

B Provides a means of dividing up tasks

C Provides a means of reducing the size of the program

D Provides a means of testing individual parts of the program

View Answer

Answer: Provides a means of reducing the size of the program

Advertisement

What is the output of the function shown below random module has already been imported )? random choice (' Sun ') *?

5. What will be the output of the following Python function (random module has already been imported)? Explanation: The above function works with alphabets just as it does with numbers. The output of this expression will be either s, u or n.

What will be the output of random random?

The random() method returns a random floating number between 0 and 1.

What does import random do in Python?

import random imports the random module, which contains a variety of things to do with random number generation. Among these is the random() function, which generates random numbers between 0 and 1.

What is the random module in Python?

Python Random module is an in-built module of Python which is used to generate random numbers. These are pseudo-random numbers means these are not truly random. This module can be used to perform random actions such as generating random numbers, print random a value for a list or string, etc.