Homework 1 - Getting Started with Python
Instructions:
Please also be sure to read the homework policies on the
General Course Information page.
Basically the content relevant for this assignment means that you may
help each other setting up Python and writing the script, but
the Python script you turn in should be written by yourself.
I hope this assignment should be simple for you, but please let me know
if you have any questions (by email or in person).
Step 1
Get Python 2 if you
don't have it already. (If, for instance, you have Mac OS X or some form
of Unix/Linux, it may already be installed on your system.)
The most recent version is 2.6.1, but if you have
an older version that should also work fine (but no guarantees).
DO NOT use Python 3 as some of the commands are different.
Step 2
Start up Python and have a look at the tutorial.
Step 3
Using the for statement, write code that prints the numbers 1 through 10
on the same line (note: you can prevent the print statement from automatically
adding a carriage return either by adding a comma on the end or using the
end= feature as in the tutorial).
Step 4
Write code for a function (using the "def" command)
of a variable n which prints (on the same line)
all odd numbers from 1 to n (this is simpler than the Fibonacci example in the
tutorial). Try calling this function for a few values of n, including negative
numbers.
Step 5
Put your code from Steps 3 and 4
in a text file (in fact it may be easier to write your code
in a text file and copy and paste it into the Python 2 interepreter)
and email it to me (either in the message text or as an attachment is fine)
at kmartin@math.ou.edu with the subject "MATH 4383/5383 - Homework 1." (NOTE: I do not frequently check my Sooner Email.) Please submit this by the end of the day Monday Jan 26.
Step 6
Congratulate yourself on a job well done!
Homework Page
Course Home