Due Thursday, October 27, at the start of class.
Find a working Python system and become a bit more comfortable using it.
Essentially, this part of the homework is to make sure that you have a working Python environment to use for the first half of the class. Complete these steps:
#!/usr/bin/env python """Homework for CS 368-4 (2011 Fall) Assigned on Day 01, 2011-10-25 Executed and printed by <Your Name> """ import getpass import os import platform import socket import sys import time print __doc__ print 'Time =', time.strftime('%Y-%m-%d (%a) %H:%M:%S %Z') print 'Host =', getpass.getuser(), '@', socket.gethostname() uname = platform.uname() print "System =", uname, uname, uname print "Version =", platform.python_version() print "Program =", sys.executable print 'Script =', os.path.abspath(__file__)
Start interactive Python. Use numbers, strings, and operations to make expressions. Experiment. Maybe read about operations that were not covered in class and try them out. Can you calculate interesting things? Can you mix numbers and strings to make formatted output? Can you put together expressions that are relevant to your research or class work?
Pick the five most interesting expressions (and their resulting values).
1 + 1 are not interesting.
Copy your interesting expressions into your homework. If you need to
explain things, just add notes.
Examples (do not use yourself!):
Convert 42.0 degrees Fahrenheit to Celsius >>> (42.0 - 32.0) * 5.0 / 9.0 5.555555555555555 Area of circle with radius = 2.5 units >>> 3.14159 * (2.5 ** 2) 19.6349375 Formatted version of above >>> 'Area = %.1f' % (3.14159 * (2.5 ** 2)) 'Area = 19.6'
A printout of your output on a single sheet of paper. For Part I, just include the output; for Part II, include the five expressions, the Python output from them, and any blank lines and comments to make things clear. In Part I, be sure to replace “<Your Name>” with your own name before running the script. Identifying your work is important, or you may not receive appropriate credit.
Normally, you will do each homework by yourself. But in this case, you may ask for help from anyone who knows how to get Python running on your machine. Be sure to use a machine that you can use for the rest of the class, because you really want to make sure Python is working right…