Python Fundamentals Quiz
Test your knowledge of Python basics including syntax, functions, loops, data structures, file operations, and the turtle graphics module.
Questions
which of the following is used for exception handling?
- try.....catch()
- try.....except()
- if.....except()
- if....else.....
what is the command for MOD?
- //
- %
- Math.mod()
- MOD
which command is used to open a text file called myFile.txt for reading?
- open("myFile.txt", "w")
- file.open("myFile.txt", "r")
- file = open("myFile.txt", "r")
- open = filename("myFile.txt", "r")
what is the command for adding a library to python?
- insert
- import
- use
- open
what kind of language is Python NOT?
- interpreted
- 3rd generation
- 4th generation
- compiled
what data structure could you use to store a grid (like a chess board)?
- a list
- a dictionary
- a vector
- a two dimensional array
which of the following would be used to store a list of names?
- a variable
- an array
- a dictionary
- a constant
which of the following does not define iteration?
- using a while loop
- repetition
- using a for loop
- start again
Which of the following is needed to make the turtle's pen thickness 4?
- turtle.penWidth(4)
- turtle.width(4)
- turtle.size(4)
- turtle.pen(4)
which of the following would print out exactly "My name is: Mr. Forsyth" ?
- print("My name is Mr. Forsyth")
- print("My name is: Mr. Forsyth")
- print('"My name is Mr. Forsyth"')
- print('"My name is: Mr. Forsyth"')
which command does NOT have a syntax error?
- print("hello)
- for i range(10):
- for line in file
- def myFunction():
which command is used to create a function?
- for
- range
- while
- def
What is used to indicate an array/list?
- curly brackets
- round brackets
- square brackets
- a colon :
What is always used to indicate a function
- round brackets
- square brackets
- curly brackets
- capital letters
What is a for loop an example of?
- Selection
- Iteration
- Sequence
- Variables