<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Day 6 - pre-class assignment
Goals for today's pre-class assignment
Use the NumPy module to manipulate arrays of data
Write a program using if statements and Boolean logic
Create loops that use the for and while statements
Assignment instructions
Watch the videos below, read through the materials linked to below the videos as well as Section 4.1 through 4.3 of the Python Tutorial, and complete the assigned programming problems.  Please get started early, and come to office hours if you have any questions!
Recall that to make notebook cells that have Python code in them do something, hold down the 'shift' key and then press the 'enter' key (you'll have to do this to get the YouTube videos to run).  To edit a cell (to add answers, for example) you double-click on the cell, add your text, and then enter it by holding down 'shift' and pressing 'enter'
This assignment is due by 11
Step1:  Some useful numpy references
The NumPy Quick Start Guide
An introduction to numpy
Question 1
Step2:  Question 2
Step3:  Potentially useful links
WikiBooks Python Programming - conditional statements
Learn Python the Hard Way - Boolean Logic
How To Think Like a Computer Scientist
Step4:  Potentially useful links
WikiBooks Python Programming - loops
Hands-on Python - loops and sequences
Numpy - nditer reference
Question 4
Step6:  Assignment wrapup
Please fill out the form that appears when you run the code below.  You must completely fill this out in order to receive credit for the assignment!
<ASSISTANT_TASK:>
Python Code:
# Imports the functionality that we need to display YouTube videos in 
# a Jupyter Notebook.  
# You need to run this cell before you run ANY of the YouTube videos.
from IPython.display import YouTubeVideo  
# Don't forget to watch the video in full-screen mode!
YouTubeVideo("BTXyE3KLIOs",width=640,height=360)  # numpy
Explanation: Day 6 - pre-class assignment
Goals for today's pre-class assignment
Use the NumPy module to manipulate arrays of data
Write a program using if statements and Boolean logic
Create loops that use the for and while statements
Assignment instructions
Watch the videos below, read through the materials linked to below the videos as well as Section 4.1 through 4.3 of the Python Tutorial, and complete the assigned programming problems.  Please get started early, and come to office hours if you have any questions!
Recall that to make notebook cells that have Python code in them do something, hold down the 'shift' key and then press the 'enter' key (you'll have to do this to get the YouTube videos to run).  To edit a cell (to add answers, for example) you double-click on the cell, add your text, and then enter it by holding down 'shift' and pressing 'enter'
This assignment is due by 11:59 p.m. the day before class, and should be uploaded into the "Pre-class assignments" dropbox folder for Day 6.  Submission instructions can be found at the end of the notebook.
End of explanation
import numpy as np
# put your code here!
Explanation: Some useful numpy references
The NumPy Quick Start Guide
An introduction to numpy
Question 1: In the cell below, import the numpy module and then create two arrays with the same number of elements in each one (pick the number of elements and the value of each yourself, making sure they're numbers and not strings!).  Then, add those arrays together and store it in a third array, and print it out.  Sort the values of the third array, and print that out again.
End of explanation
%matplotlib inline
import matplotlib.pyplot as plt
# put your code here!
# Don't forget to watch the video in full-screen mode!
YouTubeVideo("cozbOliNwSs",width=640,height=360)  # Boolean logic and if statements
Explanation: Question 2: Now let's use numpy and pyplot together (you learned about pyplot in a prior class).  We're going to use numpy's linspace method (which you can learn about by typing this:
np.linspace?
in the cell below.  Use linspace to create an array called x with 10 values ranging from x=0 to $4\pi$, and then a second array called y that is the sine of x.  Then, plot x vs. y with a red line!
Hint 1: use np.sin(), which you can find more about by typing np.sin? in the cell below
Hint 2: look at the pre-class notebook from previous classes - what did you do to make plots there?  Alternately, check out the Pyplot tutorial.
End of explanation
# write your program here, using multiple cells if necessary (adding extra cells using
# the 'Cell' menu at the top of this notebook).  Don't forget that you can execute 
# your program by holding down 'shift' and pressing 'enter' in each cell!
# Don't forget to watch the video in full-screen mode!
YouTubeVideo("VnTN5sFIPD0",width=640,height=360)  # loops in python
Explanation: Potentially useful links
WikiBooks Python Programming - conditional statements
Learn Python the Hard Way - Boolean Logic
How To Think Like a Computer Scientist: Conditionals
Python logical operators
Python comparison operators
Question 3: Write a program that compares three variables v1, v2, and v3 (not necessarily the variable names) and does the following using if statements:
If v1 is equal to v2, print "woohoo!"
If v1 has the smallest value of the three (i.e., v1 is less than both v2 and v3), print out "v1 is tiny!"
As with (2), but add a nested if statement to print out a statement saying whether v2 or v3 is the largest value.
Try several values of v1, v2 and v3 and ensure that you see the correct behavior.
End of explanation
# Program 1 here
# Program 2 here
# Program 3 here
Explanation: Potentially useful links
WikiBooks Python Programming - loops
Hands-on Python - loops and sequences
Numpy - nditer reference
Question 4: Write two small programs that do the following:
Using range() and a for loop, print out the numbers from 4 to 16 by steps of two (i.e., 2, 4, ... 16), adding up all of the numbers you have printed out.
Write a while loop that does exactly the same thing.
Create two numpy arrays with 10 elements, one using np.arange() and one using np.ones(), and use np.nditer() to iterate over the two arrays and print out their values.
End of explanation
from IPython.display import HTML
HTML(
<iframe 
	src="https://goo.gl/forms/F1MvFMDpIWPScchr2?embedded=true" 
	width="80%" 
	height="1200px" 
	frameborder="0" 
	marginheight="0" 
	marginwidth="0">
	Loading...
</iframe>
)
Explanation: Assignment wrapup
Please fill out the form that appears when you run the code below.  You must completely fill this out in order to receive credit for the assignment!
End of explanation
<END_TASK>