Report Bug

Qus

What will be the output of the following Python code?

import random

random.choice(2,3,4)

Qusनिम्नलिखित Python कोड का आउटपुट क्या होगा?


A. An integer other than 2, 3 and 4
B. Either 2, 3 or 4
C. Error
D. 3 only


Solution
C. Error



Explanation
The code shown above displays the incorrect syntax of the function random.choice(). This functions takes its numeric parameter in the form of a list. Hence the correct syntax world be: random.choice([2,3,4]).
CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad