Problem Set 0: Introduction & Installation
Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.
Freshman Sophomore Junior Senior Graduate Student (Non MBA) MBA Student
None HTML AP Computer Science Online coding course (code academy, etc.) Programming Experience in language other than Python Programming Experience in Python Took 6.0001 before Took a Python course at MIT during IAP before (e.g. 6.145) Watched or Participated in Programming course in OCW or edX College course using programming language other than Python College course using Python
To Learn how to Program To Fulfill a Course Requirement To Get a Good Grade other
Google Online coding courses Stack Overflow Friends that know how to program
Do you want to sign up for Pset buddies? Each week you will get assigned a new person to collaborate with on the pset. You and your buddy will be matched based on timezone/experience/class year, and may collaborate on the pset as much as you wish, without penalty for similar code. You can change your options for each pset, up until 9pm the night before the pset is released. For more information, and to sign up for a buddy, please go to Buddy Sign Ups.
problem sets mandatory exercises optional exercises on MITx exams lecture attendance and participation recitation attendance and participation
every Monday every Wednesday depends on the pset, check the calendar
generally available with the pset, and due with the pset generally available with a lecture, and due by the beginning of next lecture no deadline per exercise, but must do them all by the end of the course
Email S^3 and post to the forum to schedule a conflict microquiz Conflict microquizzes are not given but the lowest quiz grade is dropped
Yes for you and the friend Yes only for the friend Yes only for you no
Yes for you and the friend Yes only for the friend Yes only for you no
This problem set will introduce you to the programming environment Spyder from the Anaconda Distribution of Python, and to programming in Python, as well as to our general problem set structure. In this problem set, you will confirm your installation of Python, write a simple Python program, and hand it in. Be sure to read this problem set thoroughly, especially the Collaboration and Hand-in Procedure sections.
You may work with other students. However, each student should write up and hand in his or her assignment separately. Be sure to indicate with whom you have worked in the comments of your submission.
Follow the steps in the Getting Started handout for installing the Anaconda distribution of Python and Spyder onto the machine you plan to be using this term. The numpy and matplotlib packages, which will be used primarily in 6.0002, should come with the installation. Familiarize yourself with Python and Spyder using the exercises given in the handout. Once you are ready, proceed to the programming part of this assignment.
This class uses Python version 3.0 or higher.
When you first start using your system, make sure that the version number displayed is 3.0 or higher. Python 3 is not backwards compatible with versions starting with 2.x.
The goal of this programming exercise is to make sure your python and numpy installations
are correct, to get you more comfortable with using Spyder, and to begin using simple
elements of Python. Standard elements of a program include the ability to print out results
(using the print
operation), the ability to read input from a user at the console (for
example using the input
function), and the ability to store values in a variable, so that the
program can access that value as needed.
Write a program that does the following in order:
- At the top of your file and type:
import numpy
- Now write a line that sets a variable named
x
to 5. - Now write a line that sets a variable named
y
to 8. - Add variables x and y, and save the result to a variable named
z
. - Now save the result of this command:
numpy.log2(z)
to a variable nameda
.
Use Spyder to create your program, and save your code in a file named 'ps0.py'.
Hints:
- Remember that if you want to hold onto a value, you need to store it in a variable (i.e., give it a name to which you can refer when you want that value). You may find it convenient to look at the variables and strings section of the Python Wikibook.
At the start of each file, in a comment, write down the number of hours (roughly) you spent on the problems in that part, and the names of your collaborators. For example:
# Problem Set 0
# Name: Jane Lee
# Collaborators: John Doe
# Time Spent: 3:30
… your code goes here …
When you upload a new file, your old one will be overwritten.