A range can also count up or down based on the
sign of the number provided.
CHAPTER 4
1. C. A function in Python uses the def keyword
followed by a function name and parentheses
with an optional argument inside.
2. D. Python has specific rules for variable names. A
variable cannot be named using reserved
keywords, such True, and must start with a letter
or an underscore but not a number.
3. B. A docstring is text that describes the purpose
and use of a Python function, and it is located on
the very next line after the function definition.
The docstring can be viewed with the help()
function in Python.
4. A, B. The key components of object-oriented
programming in Python are functions that can be
performed on a data structure and attributes that
are stored in an object.
5. A, B, C. The benefits of OOP are reusable code,
easy-to-follow code, and low coupling/high
cohesion between application components.
6. A, B. A Python class can be defined using the
keyword class, a name for the class, and
optionally a parent class to inherit attributes and
functions from.
7. C. A method is a function that you can perform
on an object. Methods are often defined in
classes. They can also make use of externally
defined functions as well.
8. B. Inheritance allows you to define a base class
and then define another class using the previous
class as a parent. The subsequent class includes
all the capabilities of the parent class and can add
to or override any attribute or method that needs
to be different.