To include the use of functions which are present in the random library, we must use the option:
1. import random
2.random.h
3. import.random
4. random.random
What is returned by math.modf(1.0)?
1.(0.0, 1.0)
2. (1.0, 0.0)
3.(0.5, 1)
4. (0.5, 1.0)
What is the interval of the value generated by the function random.random(), assuming that the random module has already been imported?
1.(0,1)
2. (0,1]
3.[0,1]
4. [0,1)
What will be the output of the following Python code? import datetime d=datetime.date(2017,06,18) print(d)
1. Error
2. 2017-06-18
3. 18-06-2017
4.06-18-2017
What will be the output of the following Python code? random.randrange(0,91,5)
1. 10
2.18
3.79
4.95
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
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()
Both the functions randint and uniform accept ____________ parameters.
1.0
2.1
3.3
4.2
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
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
The value returned when we use the function isoweekday() is ______ and that for the function weekday() is ________ if the system date is 19th June, 2017 (Monday).
1.0,0
2.0,1
3. 1,0
4.1,1
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
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
What is returned by int(math.pow(3, 2))?
1. 6
2.9
3. error, third argument required
4.error, too many arguments
What is returned by math.expm1(p)?
1. (math.e ** p) – 1
2.math.e ** (p – 1)
3. error
4.none of the mentioned
What is returned by math.isfinite(float(‘inf’))?
1.True
2.False
3.None
4.error
What is returned by math.isfinite(float(‘nan’))?
1. True
2. False
3.None
4.error
What is the default base used when math.log(x) is found?
1.e
2.10
3.2
4.none of the mentioned
What is the output of print(math.trunc(‘3.1’))?
1. 3
2.3.0
3. error
4.none of the mentioned
What is the result of math.fsum([.1 for i in range(20)])?
1. 2.0
2. 20
3.2
4.2.0000000000000004
What is the result of math.trunc(3.1)?
1. 3.0
2. 3
3.0.1
4.1
What is the result of sum([.1 for i in range(20)])?
1. 2.0
2.20
3.2
4.2.0000000000000004
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
What is the value of x if x = math.sqrt(4)?
1. 2
2.2.0
3.(2, -2)
4. (2.0, -2.0)
What is x if x = math.isfinite(float(‘0.0’))?
1. True
2.False
3.None
4. error
What will be the output if we try to extract only the year from the following Python code? (time.struct_time(tm_year=2017, tm_mon=6, tm_mday=25, tm_hour=18, tm_min=26, tm_sec=6, tm_wday=6, tm_yday=176, tm_isdst=0)) import time t=time.localtime() print(t)
1. t[1]
2.tm_year
3. t[0]
4.t_year
What will be the output of the following Python code if the system date is 18th August, 2016? tday=datetime.date.today() print(tday.month())
1.August
2. Aug
3. 08
4.8
What will be the output of the following Python code if the system date is 18th June, 2017 (Sunday)? import datetime tday=datetime.date.today() print(tday)
1.18-06-2017
2.06-18-2017
3.2017-06-18
4.error
What will be the output of the following Python code if the system date is 18th June, 2017 (Sunday)? tday=datetime.date.today() print(tday.weekday())
1.6
2.1
3.0
4.7
What will be the output of the following Python code if the system date is 21st June, 2017 (Wednesday)? tday=datetime.date.today() print(tday.isoweekday())
1.Wed
2.Wednesday
3. 2
4.3
What will be the output of the following Python code if the system date is: 6/19/2017 tday=datetime.date.today() tdelta=datetime.timedelta(days=10) print(tday+tdelta)
1.2017-16-19
2.2017-06-9
3.2017-06-29
4. error
What will be the output of the following Python code? >>> -float('inf') + float('inf')
1. inf
2.nan
3. 0
4.0.01 to 20%
What will be the output of the following Python code? import datetime d=datetime.date(2016,7,24) print(d)
1.Error
2.2017-07-24
3.2017-7-24
4. 24-7-2017
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
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
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
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’
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
What will be the output of the following Python code? random.randrange(1,100,10)
1.32
2.67
3.91
4.80
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
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
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
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
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
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
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
Which of the following aren’t defined in the math module?
1. log2()
2. log10()
3.logx()
4.none of the mentioned
Which of the following functions helps us to randomize the items of a list?
1.seed
2. randomise
3.shuffle
4.uniform
Which of the following is the same as math.exp(p)?
1. e ** p
2. math.e ** p
3.p ** e
4.p ** math.e
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)