You can also supply a default value argument in case you
have an empty value to send to a function. By defining a
function with an assigned key value, you can prevent an
error. If the value in the function definition is not
supplied, Python uses the default, and if it is supplied,
Python uses what is supplied when the function is called
and then ignores the default value. Consider this
example:
Click here to view code image
>>> def greeting(name, message="Good morning!"):
print("Hello", name + ', ' + message)
>>> greeting('Caleb')
Hello Caleb, Good morning!
>>> greeting('Sydney', "How are you?")
Hello Sydney, How are you?
OBJECT-ORIENTED PROGRAMMING
AND PYTHON
Python was developed as a modern object-oriented
programming (OOP) language. Object-oriented
programming is a computer programming paradigm that
makes it possible to describe real-world things and their
relationships to each other. If you wanted to describe a
router in the physical world, for example, you would list
all its properties, such as ports, software versions,
names, and IP addresses. In addition, you might list
different capabilities or functions of the router that you
would want to interact with. OOP was intended to model
these types of relationships programmatically, allowing
you to create an object that you can use anywhere in your
code by just assigning it to a variable in order to
instantiate it.