JOBSEEKERS
Login
Sign Up
Jobseeker
Employer
Staffing Firm
Direct Client
Python interview questions part 39
Python interview questions part 39
Back
Take as many assements as you can to improve your validate your skill rating
Total Questions: 20
1. The output of the following snippet of code is either 1 or 2. State whether this statement is true or false. import random random.randint(1,2)
A. TRUE
B. FALSE
C.
D.
Show Correct Answer
Correct Answer is :
TRUE
2. What is the output of the code shown below? import random random.choice(2,3,4)
A. An integer other than 2, 3 and 4
B. Either 2, 3 or 4
C. Error
D. 3 only
Show Correct Answer
Correct Answer is :
Error
3. What is the output of the code shown below? import random random.choice([10.4, 56.99, 76])
A. Error
B. Either 10.4, 56.99 or 76
C. Any number other than 10.4, 56.99 and 76
D.
Show Correct Answer
Correct Answer is :
Either 10.4, 56.99 or 76
4. 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
Show Correct Answer
Correct Answer is :
either s, u or n
5. What is the output of the following function, assuming that the random module has already been imported? random.uniform(3,4)
A. Error
B. Either 3 or 4
C. Any integer other than 3 and 4
D. Any decimal value between 3 and 4
Show Correct Answer
Correct Answer is :
Any decimal value between 3 and 4
6. What is the output of the function shown below if the random module has already been imported? random.randint(3.5,7)
A. Error
B. Any integer between 3.5 and 7, including 7
C. Any integer between 3.5 and 7, excluding 7
D. The integer closest to the mean of 3.5 and 7
Show Correct Answer
Correct Answer is :
Error
7. Which of the following functions helps us to randomize the items of a list?
A. seed
B. randomise
C. shuffle
D. uniform
Show Correct Answer
Correct Answer is :
shuffle
8. What is the output of the code shown below? random.seed(3) random.randint(1,5) 2 random.seed(3) random.randint(1,5)
A. 3
B. 2
C. Any integer between 1 and 5, including 1 and 5
D. Any integer between 1 and 5, excluding 1 and 5
Show Correct Answer
Correct Answer is :
2
9. What is the interval of the value generated by the function random.random(), assuming that the random module has already been imported?
A. (0,1)
B. (0,1]
C. [0,1]
D. [0,1)
Show Correct Answer
Correct Answer is :
[0,1)
10. Which of the following is a possible outcome of the function shown below? random.randrange(0,91,5)
A. 10
B. 18
C. 79
D. 95
Show Correct Answer
Correct Answer is :
10
11. Both the functions randint and uniform accept ____________ parameters.
A. 0
B. 1
C. 3
D. 2
Show Correct Answer
Correct Answer is :
3
12. The randrange function returns only an integer value. State whether true or false.
A. TRUE
B. FALSE
C.
D.
Show Correct Answer
Correct Answer is :
TRUE
13. Which of the following options is the possible outcome of the function shown below? random.randrange(1,100,10)
A. 32
B. 67
C. 91
D. 80
Show Correct Answer
Correct Answer is :
91
14. What is the output of this function, assuming that the random library has already been included? random.shuffle[1,2,24]
A. Randomized list containing the same numbers in any order
B. The same list, that is [1,2,24].
C. A list containing any random numbers between 1 and 24
D. Error
Show Correct Answer
Correct Answer is :
Error
15. What the does random.seed(3) return?
A. TRUE
B. None
C. 3
D. 1
Show Correct Answer
Correct Answer is :
None
16. Which of the following cannot be returned by random.randrange(4)?
A. 0
B. 3
C. 2.3
D. none of the mentioned
Show Correct Answer
Correct Answer is :
2.3
17. Which of the following is equivalent to random.randrange(3)?
A. range(3)
B. random.choice(range(0, 3))
C. random.shuffle(range(3))
D. random.select(range(3))
Show Correct Answer
Correct Answer is :
random.choice(range(0, 3))
18. The function random.randint(4) can return only one of the following values. Which?
A. 4
B. 3.4
C. error
D. 5
Show Correct Answer
Correct Answer is :
error
19. Which of the following is equivalent to random.randint(3, 6)?
A. random.choice([3, 6])
B. random.randrange(3, 6)
C. 3 + random.randrange(3)
D. 3 + random.randrange(4)
Show Correct Answer
Correct Answer is :
3 + random.randrange(4)
20. Which of the following will not be returned by random.choice(“1 ,”)?
A. 1
B. (space)
C. ,
D. none of the mentioned
Show Correct Answer
Correct Answer is :
none of the mentioned
Similar Interview Questions
Search for latest jobs
Find Jobs