homework 2: python basics#

Please download this page by pressing the download button on upper right corner. You should save the page as an .ipynb file.

Afer downloading the document, open it on your own computer, either on Google Colab or Jupyter-Notebooks. If using Google Colab, you may need to first upload the document to your Google Drive before you can work on it.

When you are finished, download the document as an .ipynb file and submit it through Blackboard.

# In the box below, define a function called "subtract" that 
# subtracts one number from another. Make sure you include two 
# variables in the definition which will take the values of 
# the input numbers passed into the function. 
# Now call the same function, passing two random numbers as 
# parameters.
# Give an example of a "built-in" function that we have used in 
# class. Hint: we have used at least two.
# In a comment below, explain in your own words how a function 
# works and why it can be useful. 2-4 sentences.
# Write variable named `quote` that stores your favorite quote 
# of all time in the form of a list.
# Now write a loop that goes prints each word from the quote.
# Write a loop that prints the string "hello" using all capital 
# letters.
# In a comment below, explain in your own words how a loop works 
# and why it can be useful. 2-4 sentences. 
# Take the list that you created above (of your favorite quote)
# and write a list index that prints the first word of the quote.
# Take the same list, and write a list index that prints the a 
# slice of words from somewhere in the middle of the quote 
# (somewhere between the first and last words).
## BONUS ##
# Write a function that loops through a list or string which you 
# pass from the function call