Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

Python Assignment1 - 2324

Uploaded by

prathamdhobi360
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Python Assignment1 - 2324

Uploaded by

prathamdhobi360
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Ruchita is looking for her dream job, but has some choices and restrictions.

She loves Bangalore and


would talke a job there if paid over 15,00,000 per year. She hates Hyderabad and demands atleast
20,00,000 per year. Any other place she is content to work for 17,00,000 a year, unless she can work in
space in which case she would work for free. Write code for the same.

Given a list L1=[“Test”,”Find”,”Try”,”Search”,”Think”,”Innovate”]

Output = [‘e’,’k’,’h’,’y’,’d’,’t’]

Reverse the list and take only last character of each string in the list

Given a list List1=[10,20,[300,400,[5000,6000],500],30,40]

Output list=[10,20,[300,400,[5000,6000,7000],500],30,40]

Given a string, remove all vowels from the string.

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:

1. Call the cost of your dream home total_cost.

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).

Assume that your investments earn a return of r = 0.04 (4%).

5. Assume your annual salary is annual_salary.

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:

1. The starting annual salary (annual_salary)

2. The portion of salary to be saved (portion_saved)

3. The cost of your dream home (total_cost)

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:

1. The starting annual salary (annual_salary)

2. The percentage of salary to be saved (portion_saved)

3. The cost of your dream home (total_cost)

4. The semiannual salary raise (semi_annual_raise)

Check and return the palindromes in a string and list both.

Given a list

L1=[34,78,-12,44,78,91,60,-34,88]

1. Return the cube of all list elements greater than 50.


2. Remove all negative elements from list.
3. Remove the element at index 4 from the list
4. Pop the last element the from the list.

Create a list from the given string.

Create a string from the given list.

You might also like