我有任务要完成..这是一个基于python的问题...... [英] I have task to compleat ..this is a question based on a python...

查看:97
本文介绍了我有任务要完成..这是一个基于python的问题......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

部分 答: 众议院 狩猎 您已经从麻省理工学院毕业了 现在有一个很棒的工作!  您 移动 到 的 圣 旧金山 湾 区域和 确定 也就是说 你 想 到 启动 保存 到 购买  A 房子。  作为住房 价格 非常高               

湾 区, 你 实现 你 是 去 到 具有 到 保存 为 数 年 之前 你

可&NBSP ;负担 到 使  A 。房子 

以 部分  A, 我们 是 去 到 确定 如何 长&NBSP的 下 支付 在&NBSP ;它 将 取 你 到 保存 足够 钱 到 使 的 下 支付 给予 的 下面的 假设:





 



1__。致电    your dream  home  total_cost。

  2__。调用 的 所述 部分&NBSP的 成本 所需 对于  A 向下 支付  portion_down_payment 对于 简单起见, 假定 即  portion_down_payment  =  0.25 (25%) 。

  3__。呼叫 的 量 也就是说 你 具有 保存 因此 远  current_savings 你 启动 与  A 电流 储蓄 的  $ 0 

4__ 。假定 也就是说 你 投资 您的 电流 储蓄 在刀刃上, 与 的 年 返回 的  R (以 其他 也就是说,  AT 的 末 的 每个 本月, 你 接收 的 另外  current_savings * R / 12 基金 到 把 到 您的 储蓄  -  的  12 是 因为  R 是 的 年 费率)。 假设您的投资获得     =    0.04 (4%)。

  5__。假设您的年薪 是  annual_salary。 

6__。假定 你 是 去 到 奉献  A 某些 量 的 您的 工资 每个 当月 到 保存 为 的 下 支付 呼叫 也就是说  portion_saved 这个 变量 应该是  十进制 形式 (即  0.1 对于10%)。 

7__。 AT 的 末 的 每个 当月, 您的 储蓄 将 是 增加 由 的 回归 在 您的 投资, 加  A 百分比 您的 的&NBSP ;月薪 (年薪  / 12)。









 撰写  A 程序 到 计算 如何 许多 几个月 它 将 取 你 到 保存 最多 足够 钱 为  A 下&NBSP ;支付 你 将 想 您的 主 变量 到 是 花车, 所以 你 应该 投 用户NBSP;输入 到 浮动    1



我的尝试:



Part A: House Hunting You have graduated from MIT and now have a  great job!  You move to the  San Francisco Bay Area and decide that you want to start saving to buy a  house.  As housing prices are  very high in the  
Bay Area, 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

What I have tried:

total_cost=int(input('enter a value to buy a house:'))
down_payment=total_cost*25/100
total_cost=total_cost-down_payment
annual_sallery=int(input('enter your annual sallery:'))
y=int(input('enter how much % of your sallry you invested per mounth in this program:'))
mounth_proper_saving=annual_sallery*y/1200
x=mounth_proper_saving
mounth_sallery=annual_sallery/12
saving=mounth_sallery
mounth=1   #because of at the  end of 1st month you have only mounth_proper_saving

while(mounth_proper_saving<down_payment):
	
	mounth_proper_saving+=x
	mounth_proper_saving+=saving
	mounth+=1


current_saving=0
while(total_cost>current_saving):
	mounth+=1
	current_saving+=current_saving*0.04+saving

print(mounth)

推荐答案

0. 

4__。假定&NBSP;也就是说&NBSP;你&NBSP;投资&NBSP;您的&NBSP;电流&NBSP;储蓄&NBSP;在刀刃上,&NBSP;与&NBSP;的&NBSP;年&NBSP;返回&NBSP;的&NBSP; R&NBSP;(以 其他&NBSP;也就是说,&NBSP; AT&NBSP;的&NBSP;末&NBSP;的&NBSP;每个&NBSP;本月,&NBSP;你&NBSP;接收&NBSP;的&NBSP;另外&NBSP; current_savings * R / 12&NBSP;基金&NBSP;到&NBSP;把&NBSP;到&NBSP;您的&NBSP;储蓄&NBSP; - &NBSP;的&NBSP; 12&NBSP;是&NBSP;因为&NBSP; R&NBSP;是&NBSP;的&NBSP;年&NBSP;费率)。 假设您的投资获得     =    0.04 (4%)。

  5__。假设您的年薪 是  annual_salary。 

6__。假定&NBSP;你&NBSP;是&NBSP;去&NBSP;到&NBSP;奉献&NBSP; A&NBSP;某些&NBSP;量&NBSP;的&NBSP;您的&NBSP;工资&NBSP;每个&NBSP;当月&NBSP;到&NBSP;保存&NBSP;为&NBSP;的&NBSP;下&NBSP;支付&NBSP;呼叫&NBSP;也就是说&NBSP; portion_saved&NBSP;这个&NBSP;变量&NBSP;应该是  十进制 形式 (即  0.1 对于10%)。 

7__。 AT&NBSP;的&NBSP;末&NBSP;的&NBSP;每个&NBSP;当月,&NBSP;您的&NBSP;储蓄&NBSP;将&NBSP;是&NBSP;增加&NBSP;由&NBSP;的&NBSP;回归&NBSP;在&NBSP;您的&NBSP;投资,&NBSP;加&NBSP; A&NBSP;百分比&NBSP;您的&NBSP;的&NBSP ;月薪 (年薪  / 12)。









&NBSP;撰写&NBSP; A&NBSP;程序&NBSP;到&NBSP;计算&NBSP;如何&NBSP;许多&NBSP;几个月&NBSP;它&NBSP;将&NBSP;取&NBSP;你&NBSP;到&NBSP;保存&NBSP;最多&NBSP;足够&NBSP;钱&NBSP;为&NBSP; A&NBSP;下&NBSP ;支付&NBSP;你&NBSP;将&NBSP;想&NBSP;您的&NBSP;主&NBSP;变量&NBSP;到&NBSP;是&NBSP;花车,&NBSP;所以&NBSP;你&NBSP;应该&NBSP;投&NBSP;用户NBSP;输入&NBSP;到&NBSP;浮动&NBSP;   1



我的尝试:



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

What I have tried:

total_cost=int(input('enter a value to buy a house:'))
down_payment=total_cost*25/100
total_cost=total_cost-down_payment
annual_sallery=int(input('enter your annual sallery:'))
y=int(input('enter how much % of your sallry you invested per mounth in this program:'))
mounth_proper_saving=annual_sallery*y/1200
x=mounth_proper_saving
mounth_sallery=annual_sallery/12
saving=mounth_sallery
mounth=1   #because of at the  end of 1st month you have only mounth_proper_saving

while(mounth_proper_saving<down_payment):
	
	mounth_proper_saving+=x
	mounth_proper_saving+=saving
	mounth+=1


current_saving=0
while(total_cost>current_saving):
	mounth+=1
	current_saving+=current_saving*0.04+saving

print(mounth)


这篇关于我有任务要完成..这是一个基于python的问题......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆