MCQs Practice Portal - thefunword.com

Python MCQ Quiz Hub

Python Mcq Set 16

Choose a topic to test your knowledge and improve your Python skills

What the does random.seed(3) return?





✅ Correct Answer: 2

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





✅ Correct Answer: 3

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





✅ Correct Answer: 2

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





✅ Correct Answer: 3

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





✅ Correct Answer: 4

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





✅ Correct Answer: 4

Which of the following will never be displayed on executing print(random.choice({0: 1, 2: 3}))?





✅ Correct Answer: 1

What does random.shuffle(x) do when x = [1, 2, 3]?





✅ Correct Answer: 3

Which type of elements are accepted by random.shuffle()?





✅ Correct Answer: 2

What is the range of values that random.random() can return?





✅ Correct Answer: 4

Which of the following functions is not defined under the sys module?





✅ Correct Answer: 3

What will be the output of the following Python code, if the code is run on Windows operating system? import sys if sys.platform[:2]== 'wi': print("Hello")





✅ Correct Answer: 2

What will be the output of the following Python code, if the sys module has already been imported? sys.stdout.write("hello world")





✅ Correct Answer: 3

What will be the output of the following Python code? import sys sys.stdin.readline() Sanfoundry





✅ Correct Answer: 1

What will be the output of the following Python code? import sys eval(sys.stdin.readline()) "India"





✅ Correct Answer: 4

What will be the output of the following Python code? import sys eval(sys.stdin.readline()) Computer





✅ Correct Answer: 1

What will be the output of the following Python code? import sys sys.argv[0]





✅ Correct Answer: 2

What will be the output of the following Python code? import sys sys.stderr.write(“hello”)





✅ Correct Answer: 4

To obtain a list of all the functions defined under sys module, which of the following functions can be used?





✅ Correct Answer: 4

The output of the function len(sys.argv) is _____





✅ Correct Answer: 2

What does os.name contain?





✅ Correct Answer: 1

What does print(os.geteuid()) print?





✅ Correct Answer: 2

What does os.getlogin() return?





✅ Correct Answer: 1

What does os.close(f) do?





✅ Correct Answer: 3

What does os.fchmod(fd, mode) do?





✅ Correct Answer: 1

Which of the following functions can be used to read data from a file using a file descriptor?





✅ Correct Answer: 2

Which of the following returns a string that represents the present working directory?





✅ Correct Answer: 1

What does os.link() do?





✅ Correct Answer: 2

Which of the following can be used to create a directory?





✅ Correct Answer: 1

Which of the following can be used to create a symbolic link?





✅ Correct Answer: 1

What will be the output shape of the following Python code? import turtle t=turtle.Pen() for i in range(0,4): t.forward(100) t.left(120)





✅ Correct Answer: 3

The number of lines drawn in each case, assuming that the turtle module has been imported: Case 1: for i in range(0,10): turtle.forward(100) turtle.left(90) Case 2: for i in range(1,10): turtle.forward(100) turtle.left(90)





✅ Correct Answer: 1

The command which helps us to reset the pen (turtle):





✅ Correct Answer: 4

Fill in the blank such that the following Python code results in the formation of an inverted, equilateral triangle. import turtle t=turtle.Pen() for i in range(0,3): t.forward(150) t.right(_____)





✅ Correct Answer: 2

What will be the output shape of the following Python code? import turtle t=turtle.Pen() for i in range(1,4): t.forward(60) t.left(90)





✅ Correct Answer: 4

What will be the output of the following Python code? import turtle t=turtle.Pen() for i in range(0,4): t.forward(100) t.left(90) t.penup() t.left(90) t.forward(200) for i in range(0,4): t.forward(100) t.left(90)





✅ Correct Answer: 2

Which of the following functions does not accept any arguments?





✅ Correct Answer: 1

What will be the output of the following Python code? import turtle t=turtle.Pen() t.goto(300,9) t.position()





✅ Correct Answer: 1

What will be the output of the following Python code? import turtle t=turtle.Pen() for i in range(0,5): t.left(144) t.forward(100)





✅ Correct Answer: 4

What will be the output of the following Python functions? import turtle t=turtle.Pen() for i in range(0,3): t.forward(100) t.left(120) t.back(100) for i in range(0,3): t.forward(100) t.left(120)





✅ Correct Answer: 3

What will be the output of the following Python code? import turtle t=turtle.Pen() t.color(0,0,1) t.begin_fill() t.circle(15) t.end_fill()





✅ Correct Answer: 3

Which of the following functions can be used to make the arrow black?





✅ Correct Answer: 4

hat will be the output of the following Python code? import turtle t=turtle.Pen() t.color(1,1,1) t.begin_fill() for i in range(0,3): t.forward(100) t.right(120) t.end_fill()





✅ Correct Answer: 1

What will be the output of the following Python code? import turtle t=turtle.Pen() t.color(0,1,0) t.begin_fill() for i in range(0,4): t.forward(100) t.right(90)





✅ Correct Answer: 3

In which direction is the turtle pointed by default?





✅ Correct Answer: 3

The command used to set only the x coordinate of the turtle at 45 units is:





✅ Correct Answer: 2

Which of the following functions returns a value in degrees, counterclockwise from the horizontal right?





✅ Correct Answer: 1

What will be the output of the following Python code? import turtle t=turtle.Pen() t.right(90) t.forward(100) t.heading()





✅ Correct Answer: 3

What will be the output of the following Python code? import turtle t=turtle.Pen() t.clear() t.isvisible()





✅ Correct Answer: 2

What will be the output of the following Python code? import turtle t=turtle.Pen() t.forward(100) t.left(90) t.clear() t.position()





✅ Correct Answer: 4