# Python/Python Mcq Set 15 Sample Test,Sample questions

1. import random

2.random.h

3. import.random

4. random.random

1.(0.0, 1.0)

2. (1.0, 0.0)

3.(0.5, 1)

4. (0.5, 1.0)

1.(0,1)

2. (0,1]

3.[0,1]

4. [0,1)

1. Error

2. 2017-06-18

3. 18-06-2017

4.06-18-2017

1. 10

2.18

3.79

4.95

## Question: What will be the output of the following Python code? import random random.choice(2,3,4)

1.An integer other than 2, 3 and 4

2.Either 2, 3 or 4

3. Error

4.3 only

## Question: Which of the following functions can be used to find the coordinated universal time, assuming that the datetime module has already been imported?

1.datetime.utc()

2.datetime.datetime.utc()

3.datetime.utcnow()

4.datetime.datetime.utcnow()

1.0

2.1

3.3

4.2

## Question: Point out the error (if any) in the code shown below if the system date is 18th June, 2017? tday=datetime.date.today() bday=datetime.date(2017,9,18) till_bday=bday-tday print(till_bday)

1. 3 months, 0:00:00

2. 90 days, 0:00:00

3. 3 months 2 days, 0:00:00

4.92 days, 0:00:00

## Question: The sleep function (under the time module) is used to ____

1. Pause the code for the specified number of seconds

2. Return the specified number of seconds, in terms of milliseconds

3.Stop the execution of the code

4.Return the output of the code had it been executed earlier by the specified number of seconds

1.0,0

2.0,1

3. 1,0

4.1,1

## Question: What does math.sqrt(X, Y) do?

1.calculate the Xth root of Y

2. calculate the Yth root of X

3.error

4.return a tuple with the square root of X and Y

## Question: What does the function math.frexp(x) return?

1.a tuple containing the mantissa and the exponent of x

2. a list containing the mantissa and the exponent of x

3.a tuple containing the mantissa of x

4.a list containing the exponent of x

## Question: What is returned by int(math.pow(3, 2))?

1. 6

2.9

3. error, third argument required

4.error, too many arguments

## Question: What is returned by math.expm1(p)?

1. (math.e ** p) – 1

2.math.e ** (p – 1)

3. error

4.none of the mentioned

1.True

2.False

3.None

4.error

1. True

2. False

3.None

4.error

## Question: What is the default base used when math.log(x) is found?

1.e

2.10

3.2

4.none of the mentioned

## Question: What is the output of print(math.trunc(‘3.1’))?

1. 3

2.3.0

3. error

4.none of the mentioned

## Question: What is the result of math.fsum([.1 for i in range(20)])?

1. 2.0

2. 20

3.2

4.2.0000000000000004

1. 3.0

2. 3

3.0.1

4.1

## Question: What is the result of sum([.1 for i in range(20)])?

1. 2.0

2.20

3.2

4.2.0000000000000004

## Question: What is the value of x if x = math.ldexp(0.5, 1)?

1.1

2.2.0

3.0.5

4.none of the mentioned

1. 2

2.2.0

3.(2, -2)

4. (2.0, -2.0)

1. True

2.False

3.None

4. error

1. t[1]

2.tm_year

3. t[0]

4.t_year

1.August

2. Aug

3. 08

4.8

1.18-06-2017

2.06-18-2017

3.2017-06-18

4.error

1.6

2.1

3.0

4.7

1.Wed

2.Wednesday

3. 2

4.3

1.2017-16-19

2.2017-06-9

3.2017-06-29

4. error

1. inf

2.nan

3. 0

4.0.01 to 20%

1.Error

2.2017-07-24

3.2017-7-24

4. 24-7-2017

## Question: What will be the output of the following Python code? import random random.choice([10.4, 56.99, 76])

1.Error

2.Either 10.4, 56.99 or 76

3. Any number other than 10.4, 56.99 and 76

4. 56.99 only

## Question: What will be the output of the following Python code? import time for i in range(0,5): print(i) time.sleep(2)

1.After an interval of 2 seconds, the numbers 1, 2, 3, 4, 5 are printed all together

2.After an interval of 2 seconds, the numbers 0, 1, 2, 3, 4 are printed all together

3. Prints the numbers 1, 2, 3, 4, 5 at an interval of 2 seconds between each number

4. Prints the numbers 0, 1, 2, 3, 4 at an interval of 2 seconds between each number

## Question: What will be the output of the following Python code? import time t=(2010, 9, 20, 8, 15, 12, 6) time.asctime(t)

1. ‘20 Sep 2010 8:15:12 Sun’

2. ‘2010 20 Sept 08:15:12 Sun’

3. ‘Sun Sept 20 8:15:12 2010’

4. error

## Question: What will be the output of the following Python code? import time t=(2010, 9, 20, 8, 45, 12, 6, 0, 0) time.asctime(t)

1. ‘Sep 20 2010 08:45:12 Sun’

2.‘Sun Sep 20 08:45:12 2010’

3.’20 Sep 08:45:12 Sun 2010’

4. ‘2010 20 Sep 08:45:12 Sun’

## Question: What will be the output of the following Python code? import time time.asctime()

1. Current date only

2.UTC time

3.Current date and time

4.Current time only

1.32

2.67

3.91

4.80

## Question: What will be the output of the following Python code? random.seed(3) random.randint(1,5) 2 random.seed(3) random.randint(1,5)

1.3

2.2

3. Any integer between 1 and 5, including 1 and 5

4.Any integer between 1 and 5, excluding 1 and 5

## Question: What will be the output of the following Python code? import time time.time()

1.The number of hours passed since 1st January, 1970

2.The number of days passed since 1st January, 1970

3. The number of seconds passed since 1st January, 1970

4.The number of minutes passed since 1st January, 1970

## Question: What will be the output of the following Python code? print(math.isinf(float('-inf')))

1. error, the minus sign shouldn’t have been inside the brackets

2.error, there is no function called isinf

3.True

4.False

## Question: What will be the output of the following Python function (random module has already been imported)? random.choice('sun')

1. sun

2. u

3.either s, u or n

4.error

## Question: What will be the output of the following Python function if the random module has already been imported? random.randint(3.5,7)

1. Error

2.Any integer between 3.5 and 7, including 7

3. Any integer between 3.5 and 7, excluding 7

4. The integer closest to the mean of 3.5 and 7

## Question: What will be the output of the following Python function, assuming that the random library has already been included? random.shuffle[1,2,24]

1.Randomized list containing the same numbers in any order

2.The same list, that is [1,2,24]

3.A list containing any random numbers between 1 and 24

4. Error

## Question: What will be the output of the following Python function, assuming that the random module has already been imported? random.uniform(3,4)

1.Error

2. Either 3 or 4

3. Any integer other than 3 and 4

4.Any decimal value between 3 and 4

## Question: Which of the following aren’t defined in the math module?

1. log2()

2. log10()

3.logx()

4.none of the mentioned

1.seed

2. randomise

3.shuffle

4.uniform

1. e ** p

2. math.e ** p

3.p ** e

4.p ** math.e

## Question: Which of the following will throw an error if used after the following Python code? tday=datetime.date.today() bday=datetime.date(2017,9,18) t_day=bday-tday

1.print(t_day.seconds)

2.print(t_day.months)

3. print(t_day.max)

4.print(t_day.resolution)

## More MCQS

##### R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!