Lab 6: Programming in Python I In this assignment you will write your first Python program. There are two parts to the program: (1) print your name, your UCD ID number, and today's date; (2) compute and print the last 4 BINARY digits (bits) of your ID (in reverse order). Note: As before, you can do this assignment either in the computer lab or on your own computer, if you have one. To do the assignment on your own computer, you will need to install Python. We strongly recommend you install Python, and we strongly recommend that you do it this week. If you have a laptop, you could bring it to lab hours and we would be happy to help you install Python if you need. Note: For more detailed instructions on using Python, see pp. 8-11 and pp. 28-35 of the book. This lab is easier if you do the reading beforehand. Note: The hard part of this assignment is to compute the bits of your ID (in reverse order). If you don't remember how to convert decimal to binary, please review the lecture note on binary number. Starting up Python: Go Start -> All Programs -> Class Software -> Python 2.4 -> IDLE (Python GUI) What you see is the Python Interpreter that responses to input one by one. Try typing: print "hello world" >>> print "hello world" hello world >>> Writing your Python program: Go to File on the Python GUI Select New Window What you see is a new window (the script window) pop up. In the script window, use the print statement to type out your name, your ID, and today's date. Use print statement to print out "The last 4 bits of my ID (in reverse order) are" Assign the last four digits of your UCD ID (considered as a decimal number) to the new variable "ID". For example, if the last four digits of your UCD ID is 0024, then assign 24 to "ID". Assign the value ID%2 to the new variable "remainder". Assign the value ID/2 to the new variable "result". Print the value of "remainder" (= last bit of your UCD ID) Assign the value result%2 to the variable "remainder". Assign the value result/2 to the variable "result". Print the value of "remainder (= 2nd-to-last bit of your UCD ID) Repeat the last three steps to print the 3rd-to-last bit of your UCD ID. Then repeat them again to print the 4th-to-last bit. Note: Save your Python program to your Desktop, and name it "prog1". It should automatically get the suffix ".py", indicating that it is a Python program. In Windows, it will show up in the folder with the Python logo. Running your Python program: go to Run->Run Module. The program should then run immediately, producing the output IN THE IDLE WINDOW, not in the script window. For instance, this is an example of program output that appears in the IDLE window: >>>===================RESTART========================= >>> My name is John Joe My UCD ID is 123456789 Today is 10/29/2007 The last 4 binary digits of my ID (in reverse order) is 1 0 1 0 Turning in your Program: Use my.ucdavis.edu to turn in the program. The program name should be named prog1.py. You do not need to turn in a hard copy.