Python interview questions part 39

Python interview questions part 39

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)

Correct Answer is : TRUE

2. What is the output of the code shown below? import random random.choice(2,3,4)

Correct Answer is : Error

3. What is the output of the code shown below? import random random.choice([10.4, 56.99, 76])

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')

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)

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)

Correct Answer is : Error

7. Which of the following functions helps us to randomize the items of a list?

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)

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?

Correct Answer is : [0,1)

10. Which of the following is a possible outcome of the function shown below? random.randrange(0,91,5)

Correct Answer is : 10

11. Both the functions randint and uniform accept ____________ parameters.

Correct Answer is : 3

12. The randrange function returns only an integer value. State whether true or false.

Correct Answer is : TRUE

13. Which of the following options is the possible outcome of the function shown below? random.randrange(1,100,10)

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]

Correct Answer is : Error

15. What the does random.seed(3) return?

Correct Answer is : None

16. Which of the following cannot be returned by random.randrange(4)?

Correct Answer is : 2.3

17. Which of the following is equivalent to random.randrange(3)?

Correct Answer is : random.choice(range(0, 3))

18. The function random.randint(4) can return only one of the following values. Which?

Correct Answer is : error

19. Which of the following is equivalent to random.randint(3, 6)?

Correct Answer is : 3 + random.randrange(4)

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

Correct Answer is : none of the mentioned

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon