Python lecture notes
Writing python code in text files
You may use your favorite text editor and write your python code in text files.
You must obey the same rules on indentation and syntax required by the
interpreter but you can now be more at ease doing it. When you are done, make
sure the file has the extension .py and that the script has
#!/directory-structure/python where directory-structure is a path to a
python interpreter on the system.
Exercises
Write all three of following in Python:
- square.py from the awk lab.
- reverse.py from the sed lab.
- class.py This one is going to be similar to one of Dr.
Straight's "Do something interesting" labs. You may do anything
you want for this exercise as long as it meets the following
criteria:
- Must use at least one class object that you design.
- Must invoke the class for use, aka class = MyClass(....)
- Must use the __init__() method to initialize the class and
initialize at least one "self" member of the class.
- Define and use at least two methods, one of which must
accept an argument that changes one the of the internal
members of the class.
Submission
DO NOT include any code to test your files. I expect
that the scripts will have EXACTLY the names listed above, take the
proper input values and return the correct outputs in the specified manner.
Don't forget that I expect error checking.