Python Assignment1 - 2324
Python Assignment1 - 2324
Output = [‘e’,’k’,’h’,’y’,’d’,’t’]
Reverse the list and take only last character of each string in the list
Output list=[10,20,[300,400,[5000,6000,7000],500],30,40]
Given a list of numbers, return the list containing only square of positive numbers from given list.
n = 10
i = 10
while i > 0:
print i
if i % 2 == 0:
i=i/2
else:
i=i+1
You have graduated from MSU and now have a great job! You move to the Bangalore and
decide that you want to start saving to buy a house. As housing prices are very high in the Bangalore,
you realize you are going to have to save for several years before you can afford to make the down
payment on a house. In Part A, we are going to determine how long it will take you to save enough
money to make the down payment given the following assumptions:
2. Call the portion of the cost needed for a down payment portion_down_payment. For
simplicity, assume that portion_down_payment = 0.25 (25%).
3. Call the amount that you have saved thus far current_savings. You start with a current savings of $0.
4. Assume that you invest your current savings wisely, with an annual return of r (in other words,
at the end of each month, you receive an additional current_savings*r/12 funds to put into
your savings – the 12 is because r is an annual rate).
6. Assume you are going to dedicate a certain amount of your salary each month to saving for
the down payment. Call that portion_saved. This variable should be in decimal form (i.e. 0.1 for 10%).
7. At the end of each month, your savings will be increased by the return on your investment,
plus a percentage of your monthly salary (annual salary / 12).
Write a program to calculate how many months it will take you to save up enough money for a down
payment. You will want your main variables to be floats, so you should cast user inputs to floats. 1
Your program should ask the user to enter the following variables:
In Part A, we unrealistically assumed that your salary didn’t change. But clearly you are going to be orth
more to your company over time! So we are going to build on your
solution to Part A by factoring in a raise every six months. Modify your program to include the following
1. Have the user input a semi-annual salary raise semi_annual_raise (as a decimal percentage)
2. After the 6th month, increase your salary by that percentage. Do the same after the 12 th
month, the 18 month, and so on.
Write a program to calculate how many months it will take you save up enough money for a down
payment. LIke before, assume that your investments earn a return of r = 0.04 (or 4%) and the
required down payment percentage is 0.25 (or 25%). Have the user enter the following variables:
Given a list
L1=[34,78,-12,44,78,91,60,-34,88]