The goal of this assignment is to allow you to explore the basics of the
Python programming language. To record your solutions and answers,
create a new Jupyter Notebook titled Notebook 01 - Basic Syntax and
Types.ipynb
and use this notebook to complete the following activities and
answer the corresponding questions.
Make sure you label your activities appropriately. That is for Activity 1, have a header cell that is titled Activity 1. Likewise, use the Markdown cells to answer the questions (include the questions above the answer).
This Notebook assignment is due Midnight Wednesday, September 9, 2015 and is to be done individually.
For this activity, you are given the following three math formulas:
For each formula, you are to write a program that prompts the user for the appropriate input, perform the computation, and then print out the formatted result.
A transcript of the program for Formula 2 should go as follows:
What is the radius? 10
What is the height? 42
Volume of Cylinder with radius 10 and height 42 is 13194.69
Output results to two places after the decimal point.
After you have completed the programs above, answer the following questions:
What happens if a user enters in non-numerical input or nothing at all? Why does this happen?
Did you use ints or floats? Does it make a difference? Why?
For this activity, you are to implement a program that simulates a Magic 8-Ball by prompting the user for a question and then randomly printing one of the following outcomes:
A transcript of the program should go as follows:
What is your question? Will Notre Dame win the national championship this year?
Without a doubt
Hint: random.choice
After you have completed the program above, answer the following questions:
Did you use a data structure in your program? If so, which one and why? Could you have used another one instead (which one)?
Execute your program a few times. Is your Magic 8-Ball positive, neutral, or negative? If you wanted to make an overly pessimistic or negative Magic 8-Ball, what could you do to accomplish that without removing any positive or neutral answers?
For this activity, each of the following programs contains at least one bug. You are to identify the bugs and correct the programs.
Program 1
# Print list of points
x0, y0 = 0, 0
x1, y1 = 1, 1
points = [(x0, y0), (x1, y1)]
print 'Points:' + points
Program 2
# Convert Celsius to Fahrenheit
celsius = 32
fahrenheit = celsius * 9/5 + 32
print 'Celsius ({}) = Fahrenheit ({})'.format(celsius, fahrenheit)
Program 3
# Convert miles to feet
miles = 10
feet = 5,280
print '{} miles is {} feet'.format(miles, miles * feet)
After you have fixed the programs above, answer the following questions:
Explain the process you used to identify and fix each program.
Which bug was the hardest for you to identify and fix? Explain.
To submit your notebook, follow the same directions for Notebook00, except store this notebook in the notebook01 folder.