DATA 420 — Modeling and Simulation — Spring 2024
Possible experience: +14XP
Due: Mon, Jan 22nd, midnight
In this initial coding assignment, you'll get a little practice (or refresher) programming in Python.
If you already have Python 3.10 or higher installed, you can use it. If you're using an IDE (Spyder, IDLE, PyCharm, etc) there should be some menu you can find that will tell you your Python version. If you're on the command line, you can type "python --version" to find out. (Btw, "command line" likely means "Power Shell" if you're a Windows user, "Terminal" if you're a MacOS user, and "command line" or "terminal" if you're a Linux user like me.)
If your Python is out of date or non-existent, you can download it for your operating system and install it. I also heartily encourage the use of the enhanced IPython interactive shell.
CPSC students: if you've never used Python before, or you did long ago and have forgotten everything, don't despair: it's a snap. Anyone who has made it through CPSC 110, 220, and 240, all with a C or better, is more than capable of picking up Python as an additional language. (You'll do this picking-up-languages thing often in your career, btw.)
DATA students: although it won't be until spring break, you'll eventually need to learn how the OO ("object-oriented") aspects of Python work. That's sections 9.3 and 9.5 (and all subsections 9.3.*, 9.5.*) of the tutorial, below. Go ahead and read through those sections now just as a preview of what you're up against.
Whether or not this is your first Python experience, go through the following sections of the official Python tutorial (make sure that the drop-down box at the top says at least "3.10"):
The file pythonworkout.py contains a test scaffolding for this project. The best way to get this file is to clone the class github repo somewhere on your computer, and then you'll be able to easily get updates for the class all semester. The not-so-good way is to copy/paste the text from that page into a file in your editor/IDE, and save the file with the appropriate name. Choose the second way only if you want to delay as long as possible getting familiar with the tools and techniques actually used in the real world.
You'll be adding your own code to this file in order to practice your Python and to earn XP, as described in the Requirements section below. You can run it at any point and it will tell you how many XP you've earned so far.
After obtaining the file named pythonworkout.py via any of the above strategies, make a copy of it named yourumwid_pythonworkout.py. You can use a copy command, OS right-click operation, "Save as..." operation in your IDE, or any other way you can think of to make this copy. (Please do not name your copied file anything else. Please do not omit the suffix, or change the capitalization, or add/remove underscores, or do any other clever or creative things. Please call it exactly yourumwid_pythonworkout.py, with your actual (lowercase) UMW Net ID substituted for "yourumwid". For instance, "jsmith19_pythonworkout.py" is a correct name.)
You'll write all your code in the newly-created yourumwid_pythonworkout.py file. The original pythonworkout.py file can and should stay put.
Now, run your yourumwid_pythonworkout.py file. (In an IDE, it might be a little green arrow button, or the F5 key. On the command line, it will be the command "python yourumwid_pythonworkout.py".)
If you're running in an IDE, execute whatever the "run" command is on that IDE, making sure to specify yourumwnetid as a command-line argument. (On Spyder, I happen to know you access this through "Configuration per file..." from the "Run" menu, then check "Command-line option" and type the argument in the little text box.)
Either way, make sure you get an output that looks something like this:
Some variables incomplete or incorrect. (plus2() incomplete.) (center() incomplete.) (nuke_last() incomplete.) (middlest() incomplete.) (tack_on_end() incomplete.) (wondrous_count() incomplete.) (unique_vals() incomplete.) You've earned 0/14 XP!
You are now ready to begin coding.
In your yourumwid_pythonworkout.py file, locate the section that says "(Add your code here.)" This is where you will add your code. Create the following variables and functions, in any order you choose:
Key | Value |
---|---|
Karl | Helo |
Kara | Starbuck |
Lee | Apollo |
Key | Value |
---|---|
Sharon | Boomer |
Marge | Racetrack |
Louanne | Kat |
Whenever you run the code, your score will appear at the bottom of the output.
For this assignment, send an email to data420submissions@gmail.com with subject line "DATA 420 Python workout turnin", with your yourumwid_pythonworkout.py file attached. (Double-check to make sure it's really attached!)
Come to office hours, or send me email with subject line "DATA 420 Python workout help!!"