Python Fundamentals Quiz

Test your knowledge of Python basics including syntax, functions, loops, data structures, file operations, and the turtle graphics module.

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

which of the following is used for exception handling?

  1. try.....catch()
  2. try.....except()
  3. if.....except()
  4. if....else.....
Question 2 Multiple Choice (Single Answer)

what is the command for MOD?

  1. //
  2. %
  3. Math.mod()
  4. MOD
Question 3 Multiple Choice (Single Answer)

which command is used to open a text file called myFile.txt for reading?

  1. open("myFile.txt", "w")
  2. file.open("myFile.txt", "r")
  3. file = open("myFile.txt", "r")
  4. open = filename("myFile.txt", "r")
Question 4 Multiple Choice (Single Answer)

what is the command for adding a library to python?

  1. insert
  2. import
  3. use
  4. open
Question 5 Multiple Choice (Single Answer)

what kind of language is Python NOT?

  1. interpreted
  2. 3rd generation
  3. 4th generation
  4. compiled
Question 6 Multiple Choice (Single Answer)

what data structure could you use to store a grid (like a chess board)?

  1. a list
  2. a dictionary
  3. a vector
  4. a two dimensional array
Question 7 Multiple Choice (Single Answer)

which of the following would be used to store a list of names?

  1. a variable
  2. an array
  3. a dictionary
  4. a constant
Question 8 Multiple Choice (Single Answer)

which of the following does not define iteration?

  1. using a while loop
  2. repetition
  3. using a for loop
  4. start again
Question 9 Multiple Choice (Single Answer)

Which of the following is needed to make the turtle's pen thickness 4?

  1. turtle.penWidth(4)
  2. turtle.width(4)
  3. turtle.size(4)
  4. turtle.pen(4)
Question 10 Multiple Choice (Single Answer)

which of the following would print out exactly "My name is: Mr. Forsyth" ?

  1. print("My name is Mr. Forsyth")
  2. print("My name is: Mr. Forsyth")
  3. print('"My name is Mr. Forsyth"')
  4. print('"My name is: Mr. Forsyth"')
Question 11 Multiple Choice (Single Answer)

which command does NOT have a syntax error?

  1. print("hello)
  2. for i range(10):
  3. for line in file
  4. def myFunction():
Question 12 Multiple Choice (Single Answer)

which command is used to create a function?

  1. for
  2. range
  3. while
  4. def
Question 13 Multiple Choice (Single Answer)

What is used to indicate an array/list?

  1. curly brackets
  2. round brackets
  3. square brackets
  4. a colon :
Question 14 Multiple Choice (Single Answer)

What is always used to indicate a function

  1. round brackets
  2. square brackets
  3. curly brackets
  4. capital letters
Question 15 Multiple Choice (Single Answer)

What is a for loop an example of?

  1. Selection
  2. Iteration
  3. Sequence
  4. Variables