Sie sind auf Seite 1von 1

CSE151-002 - Introduction to Programming Using Pathon Homework 1

January 31, 2014

1. Recall the exercise from class in which we calculated the average of two scores. Now write a Python program that asks the user to provide three comma-separated scores, and then prints out the average. 2. The following well-known formula to computes the height(m) of a projectile from its initial upward velocity (m/s) and the amount of time t(s) after the launch. (This assumes that you are on the planet Earths evil twin, which has the same gravity, but no air.) height = velocity t 1 g t2 . 2

Write a program that allows its user to enter an initial upward velocity and the amount of time after the launch, and then prints out the height of the projectile at that time (let g = 9.8(m/s2 )). (m, s are the units, representing meter and second) 3. We have seen the formula to convert a temperature degree in Celsius to Fahrenheit. Now we are given a list [0, 10, 30, 50, 80]. Each of the numbers in the list represents a temperature degree in Celsius. Write a program that uses a for loop to print out each of the corresponding degree in Fahrenheit. 4. We know that ab = a a a. a is called the base and b is called the exponent. Write a program
b

that asks the user to enter a base and an exponent, and then print out the value of ab . The calculation should be done using a for loop which repeatedly multiplies by the base until the correct value is reached. (Review how we computed 26 ). 5. Review the program we saw in class about the 10-years investment. Now modify the program so that the number of years for the investment is also a user input. 6. Now suppose that you want to be able to add an additional amount to your investment at the end of each year. Modify your program further to accept a fourth input, which represents the size of an annual contribution. Alter the programs calculations accordingly.

Das könnte Ihnen auch gefallen