A201 Introduction to Programming 1

A201 Homework 2

Due Date: Tuesday, September 5, 2023.

Make sure to complete Lab 2 before doing the homework.

Create a Python script file called hw2.py. Add your name at the top as a comment, along with the class name and date. Both exercises should be in this file, with a comment before each of them to mark it.

Ex. 1. Computing the interest

Write a program that computes the interest of a sum of money based on a give rate. First, ask the user for an amount of money, input it as a float, and store it in a variable. Then ask the user for an interest rate (such as 0.3 meaning 30%), and also input it as a float, and store it in a second variable. Finally, compute the interest as the amount times the rate, and output it.

Ex. 2. Miles to Kilometers conversion

Write a program that inputs a distance in miles from the user, converts it to kilometers, then outputs the result. If M is the distance in miles, the distance in kilometers is equal to M * 1.60934.

Homework Submission

Upload the files lab2.py and hw2.py in Canvas, Assignments, Homework 2.