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

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




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




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




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




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




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




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




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




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




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




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




12. 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")




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




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




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




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




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




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




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




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




21. What does os.name contain?




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




23. What does os.getlogin() return?




24. What does os.close(f) do?




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




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




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




28. What does os.link() do?




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




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




31. 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)




32. 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)




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




34. 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(_____)




35. 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)




36. 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)




37. Which of the following functions does not accept any arguments?




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




39. 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)




40. 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)




41. 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()




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




43. 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()




44. 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)




45. In which direction is the turtle pointed by default?




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




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




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




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




50. 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()