Assignment 2
Due Tues, Sep 11
Please create a single zip file named
<userid>-hw2.zip (i.e. kay-hw2.zip) that contains two files:
hw2-1.py (the solution of question 1)
hw2-2.py (the solution of question 2)
Email your solutions to kay <at> ischool. Include comments in each script stating your name, the name of any collaborators, and approximate time it took you to complete the exercise.
Question 3 is due on Tuesday, Sep 18th. Please check below for more details
1. Write a script that prompts the user for a number of gallons of gasoline. Reprint that value, along with its conversion to other measurements:
- Equivalent number of liters
- Number of barrels of oil required to produce it
- Price in US dollars
Figures to use:
- 1 gallon is equivalent to 3.7854 liters
- 1 barrel of oil produces 19.5 gallons of gas.
- The average price of gas is approximately $3.65
2. Write a script that prompts the user for their name. The script should then print the lyrics to the song below, giving the user’s name a new first letter in each line. If the first letter of the original name is a consonant, it should be deleted and replaced by the new letter. Otherwise, the new letter should be inserted before the first letter of the name.
Enter your name: Paul
Paul Paul Bo Baul
Banana Fanna Fo Faul
Me My Mo Maul
Paul
Enter your name: Ann
Ann Ann Bo BAnn
Banana Fanna Fo FAnn
Me My Mo MAnn
Ann
Assignment 2 Question 3
Due Tues, Sept 18
Please create a single zip file named
<userid>-hw2-3.zip (i.e. kay-hw2-3.zip) that contains only one file:
hw2-3.py (the solution of question 3)
Email your solutions to kay <at> ischool. Include comments in each script stating your name, the name of any collaborators, and approximate time it took you to complete the exercise.
3. Write a script that prompts the user for an integer tree size, then displays a number tree as shown below:
Enter a size: 5
1
121
12321
1234321
123454321
If you are having trouble, see the hint here.