Changes

Jump to: navigation, search

OPS435 Python Lab 7

89 bytes added, 09:28, 21 January 2020
no edit summary
<font color='red'>
'''** DO NOT USE - TO BE UPDATED FOR CENTOS 8.0 **'''
</font>
= LAB OBJECTIVES =
:Object-oriented programming is one level of complexity higher than simply structured programming as you've experienced in languages such as Bash or C. In this second lab on objects we're going to look at slightly more complex issues that come up when using them.
== PYTHON REFERENCE ==
:In previous labs, you have been advised to make notes and use online references. This also relates to learning about objected object oriented programming to help becoming "overwhelmed" with the volume of information in this lab.
:Below is a table with links to useful online Python reference sites (by category). You may find these references useful when performing assignments and labs.
|- style="background-color:white;border:none;"
| Car
| Andrew's silver Civic with VIN 1234567890, John's blue Subaru with VIN 0987654321, Evan's BWMMSeries Black BMWMSeries with VIN 4567981230
|}
# Note that you cannot make any of the following print() functions work because neither of
# the variables '''a''' exist in this scope (outside the function where they were defined):
a = 'Andrew 500'
print(a)
function1()
</source>
Note that the same thing is printed over and over because the '''authorName''' variable is defined outside a function which makes it global which makes it accessible from whywhereanywhere.
Python has one weird quirk when it comes to global scope: if you assign something to a variable inside a function - it will assume you want to create a new variable in that function's local scope. That will hide the global variable inside the function unless you declare it explicitly as global:
:'''Have Ready to Show Your Instructor:'''
::<span style="color:green;font-size:1.5em;">&#x2713;</span> Output of: <code>./CheckLab7.py -f -v</code>running your scripts for this lab and
::<span style="color:green;font-size:1.5em;">&#x2713;</span> Output of: <code>cat lab7a.py lab7b.py lab7c.py</code>
= LAB REVIEW =#
[[Category:OPS435-Python]]
1,760
edits

Navigation menu