Berkeley Ai Materials
The tasks for this magnificence expect you use Python 2.7.
Project 0 will cowl the subsequent:
A mini-UNIX educational (particularly crucial in case you paintings on educational machines),
A mini-Python academic,
Project grading:Every assignment's release consists of its autograder if you want to run yourself.
Files to Edit and Submit: You will fill in portions of addition.py, buyLotsOfFruit.py, and shopSmart.py in educational.zip in the course of the undertaking. You have to post these documents with your code and comments. Please do no longer trade the alternative documents in this distribution or publish any of our unique files aside from these documents.
Evaluation: Your code can be autograded for technical correctness. Please do not trade the names of any supplied features or training in the code, or you'll wreak havoc at the autograder. However, the correctness of your implementation -- no longer the autograder's judgements -- will be the final judge of your score. If necessary, we can review and grade assignments in my opinion to ensure that you receive due credit in your paintings.
Academic Dishonesty: We will be checking your code towards other submissions in the magnificence for logical redundancy. If you copy a person else's code and publish it with minor adjustments, we are able to realize. These cheat detectors are quite tough to idiot, so please do not try. We accept as true with you all to publish your personal paintings simplest; please don't allow us to down. If you do, we are able to pursue the strongest effects to be had to us.
Getting Help: You are not on my own! If you find your self caught on something, contact the course personnel for assist. Office hours, segment, and the dialogue forum are there to your guide; please use them. If you cannot make our office hours, allow us to recognize and we can time table greater. We want these tasks to be rewarding and educational, now not frustrating and demoralizing. But, we don't know whilst or a way to help except you ask.
Discussion: Please be cautious now not to submit spoilers.
Unix Basics
Here are simple commands to navigate UNIX and edit files.
File/Directory Manipulation
When you open a terminal window, you're placed at a command activate:
The spark off suggests your username, the host you are logged onto, and your modern location in the directory structure (your direction). The tilde character is shorthand for your own home directory. Note your prompt may look slightly different. To make a listing, use the mkdir command. Use cd to change to that listing:
[cs188-ta@nova ~]$ mkdir foo [cs188-ta@nova ~]$ cd foo [cs188-ta@nova ~/foo]$
Use ls to look a listing of the contents of a listing, and contact to create an empty record:
[cs188-ta@nova ~/foo]$ ls [cs188-ta@nova ~/foo]$ touch hello_world [cs188-ta@nova ~/foo]$ ls hello_world [cs188-ta@nova ~/foo]$ cd .. [cs188-ta@nova ~]$
Download python_basics.zip into your home listing (notice: the zip file's name may be barely one-of-a-kind whilst you download it). Use unzip to extract the contents of the zip report:
[cs188-ta@nova ~]$ ls *.zip python_basics.zip [cs188-ta@nova ~]$ unzip python_basics.zip [cs188-ta@nova ~]$ cd python_basics [cs188-ta@nova ~/python_basics]$ ls foreach.py helloWorld.py listcomp.py listcomp2.py quickSort.py save.py shopTest.py
Some other beneficial Unix instructions:
cp copies a document or documents
rm gets rid of (deletes) a record
mv moves a file (i.e., reduce/paste as opposed to reproduction/paste)
man displays documentation for a command
pwd prints your current direction
xterm opens a new terminal window
firefox opens a web browser
Press "Ctrl-c" to kill a jogging technique
Append & to a command to run it inside the background
fg brings a software strolling inside the historical past to the foreground
The Emacs textual content editor
Emacs is a customizable text editor which has a few first-rate features especially tailored for programmers. However, you could use every other text editor that you can decide upon (which includes vi, p.c., or joe on Unix; or Notepad on Windows; or TextWrangler on OS X; and plenty of more).
To run Emacs, type emacs at a command prompt:
[cs188-ta@nova ~/python_basics]$ emacs helloWorld.py & [1] 3262
Here we gave the argument helloWorld.py so as to both open that record for editing if it exists, or create it in any other case. Emacs notices that this is a Python supply document (due to the .py ending) and enters Python-mode, which is meant that will help you write code. When modifying this document you may word a number of that textual content turns into mechanically coloured: this is syntax highlighting to help you distinguish objects including keywords, variables, strings, and comments. Pressing Enter, Tab, or Backspace may reason the cursor to leap to weird locations: this is due to the fact Python could be very choosy about indentation, and Emacs is predicting the proper tabbing which you need to use.
Some fundamental Emacs enhancing commands (C- means "while holding the Ctrl-key"):
C-x C-s Save the current file
C-x C-f Open a file, or create a new document it if does not exist
C-k Cut a line, upload it to the clipboard
C-y Paste the contents of the clipboard
C-_ Undo
C-g Abort a 1/2-entered command
You can also replica and paste using just the mouse. Using the left button, select a place of text to replicate. Click the center button to paste.
There areapproaches you may use Emacs to develop Python code. The maximum truthful manner is to apply it simply as a text editor: create and edit Python files in Emacs; then run Python to check the code some other place, like in a terminal window. Alternatively, you may run Python interior Emacs: see the options beneath "Python" in the menubar, or kind C-c ! to begin a Python interpreter in a cut up display. (Use C-x o to interchange between the cut up screens, or simply click if C-x does not work).
If you need to spend some greater setup time becoming a energy user, you may try an IDE like Eclipse (Download the Eclipse Classic package deal at the bottom). Check out PyDev for Python assist in Eclipse.
Python Basics
Required Files
You can down load all of the documents associated with the Python mini-tutorial as a zip archive: python_basics.zip. If you probably did the unix educational inside the preceding tab, you have already downloaded and unzipped this report.
Table of Contents
Invoking the Interpreter
Operators
Strings
Dir and Help
Built-in Data Structures
Lists
Tuples
Sets
Dictionaries
Writing Scripts
Indentation
Tabs vs Spaces
Writing Functions
Object Basics
Defining Classes
Using Objects
Static vs Instance Variables
Tips and Tricks
Troubleshooting
More References
The programming assignments on this course will be written in Python, an interpreted, item-oriented language that shares a few functions with each Java and Scheme. This tutorial will walk thru the primary syntactic structures in Python, the use of quick examples.
We encourage you to kind all python shown in the tutorial onto your personal gadget. Make certain it responds the same way.
You may additionally discover the Troubleshooting phase beneficial if you run into problems. It includes a listing of the common issues previous CS188 students have encountered while following this educational.
Invoking the Interpreter
Python may be run in one in all two modes. It can either be used interactively, through an interpeter, or it can be referred to as from the command line to execute a script. We will first use the Python interpreter interactively.
You invoke the interpreter by getting into python at the Unix command prompt. Note: you could ought to kind python2.four, python2.five, python2.6 or python2.7, as opposed to python, depending to your gadget.
[cs188-ta@nova ~]$ python Python 2.6.five (r265:79063, Jan 14 2011, 14:20:15) [GCC four.four.1] on sunos5 Type "assist", "copyright", "credits" or "license" for greater information. >>>
Operators
The Python interpreter can be used to evaluate expressions, as an example simple mathematics expressions. If you input such expressions on the prompt (>>>) they will be evaluated and the result may be again on the following line.
>>> 1 + 1 2 >>> 2 * three 6
Post a Comment for "Berkeley Ai Materials"
Post a Comment