# Problem Set 0: Introduction & Installation

The questions below are due on Friday September 10, 2021; 09:00:00 PM.

You are not logged in.

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.

## 1) Background Survey

 Freshman Sophomore Junior Senior Graduate Student (Non MBA) MBA Student

What is your (first) major? If freshman, choose "Freshman".

What is your second major? If not double majoring or undecided, do not answer this question.

Approximate Lines of Code written before enrolling in 6.0001

Prior Programming Experience?
 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

Why did you enroll in 6.0001?
 To Learn how to Program To Fulfill a Course Requirement To Get a Good Grade other

Select all of the resources that you are aware of or have used to help learn how to program.
 Google Online coding courses Stack Overflow Friends that know how to program

## 3) Class Info Assessment

(did you read the course info page?)

 problem sets mandatory exercises optional exercises on MITx exams lecture attendance and participation recitation attendance and participation

When are problem sets due?
 every Monday every Wednesday depends on the pset, check the calendar

When are mandatory finger exercises due?
 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

Microquizzes are in the last 20-45 minutes of 4 specific lectures outlined in the calendar. What happens if you cannot make it to a microquiz?
 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

You are working with a friend (not your assigned pset buddy) on the problem set. Your friend tells you to use a specific kind of loop to solve a part. Is this a collaboration violation?
 Yes for you and the friend Yes only for the friend Yes only for you no

You are stuck debugging the problem set. Your friend (not your assigned pset buddy) already finished but they can't stay to help you anymore, so they email you the code. You look over the part you are stuck but write up your own code. Is this a collaboration violation?
 Yes for you and the friend Yes only for the friend Yes only for you no

## 4) Introduction to Python & Spyder

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.

### 4.1) Collaboration

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.

### 4.2) Installing Python & Spyder

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.

### 4.3) Your First Program: Raising a number to a power and taking a logarithm

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.

#### 4.3.1) Assignment

Write a program that does the following in order:

1. Asks the user to enter a number "x"
2. Asks the user to enter a number "y"
3. Prints out number "x", raised to the power "y".
4. Prints out the log (base 2) of "x".

Use Spyder to create your program, and save your code in a file named 'ps0.py'. An example of an interaction with your program is shown below. The numbers printed after ": " are an example of a user's input. The rest are should be printed by your program.

Enter number x: 2
Enter number y: 3
X**y = 8
log(x) = 1

Hints:

• To see how to use the print command, you may find it convenient to look at the input and output of the Python Wikibook. This will show you how to use print statements to print out values of variables.
• To see how to read input from a user's console into the Python environment, you may find it convenient to look at the same section (see for example the input() function)
• Reference the basic math section of the Python Wikibook to read more about using basic mathematical operators in Python
• To take the logarithm of a variable, import either of the numpy or pylab packages. You can then call either numpy.log2 or pylab.log2 to calculate the logarithm. See the Getting Started document on importing packages and the many Numpy examples online for more info. Googling the log2 function may take you here, which has some helpful info.
• 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. (As you read through, remember that in Python 3.x you should be using input() not raw_input()). Take a look at the “Combining Numbers and Strings” sub-section, because you will be working with numbers and strings in this problem and will have to convert between the two using the str() and int() functions.

## 5) Hand-in Procedure

### 5.1) Save

Save your code in ps0.py. *Do not ignore this step or save your file(s) with different names.*

### 5.2) Time and Collaboration Info

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 …

### 5.3) Submit

After you completed the steps in the file "Getting Started" from the downloaded files and Problem 3 above, upload your file here. You may upload new versions of each file until the 9PM deadline, but anything uploaded after that time will be counted towards your late days, if you have any remaining. If you have no remaining late days, you will receive no credit for a late submission.

When you upload a new file, your old one will be overwritten.

No file selected