Krystin Burn
3BC
Computer Programming
Ms. Grant
Python Coding Basics
1. When you see >>> inside IDLE, it means that:
Answer: Python is waiting for you to give it some instructions.
2. What’s the file extension used for text files containing Python code?
Answer: .py
3. You run a Python program, and the following text is displayed in the interactive window:
What does this mean?
Answers: The line that generated the error was: print(Hello, world).
The specific error was: name 'Hello' is not defined.
The error happened on line 1 of the program.
A NameError occurred.
4. Write the Python code that prints out the text Hello, world:
Answer: print("Hello, world")
5. A error is any error that can only be caught once a program is being executed.
Answer: runtime
6. The following Python statement has an error in it:
Answer: Syntax Error
7. In Python, variables are:
Answer: Names that you can assign to different objects and use to reference those objects
throughout your code.
8. Which operator symbol is used by Python to assign values to variables?
Answer: =
9. Which of the following code examples will cause a runtime error when executed?
Answer:
10. Which of the following are valid Python variable names?
Answer: really_big_number
left_
sirLancelot
a2z
name
11. According to PEP 8, Python variable names should be written in which style?
Answer: lower_case_with_underscores (Example: variable_name)
12. Write the Python code that assigns the value “super snake” to the variable hero and then
prints it:
Answer: hero = "super snake"
print(hero)
13. Comments are lines of text that subtly change the way a Python program runs.
Answer: That’s wrong
14. What’s the result of the following Python program?
Answer: NameError: name 'text' is not defined