python计算连续复利_复利的Python程序

python计算连续复利

Given principle amount, rate and time and we have to find the compound interest in Python.

给定原理量,速率和时间,我们必须找到Python的复利 。

计算复利 (Calculate compound interest)

To calculate compound interest, we use the following formula,

要计算复利,我们使用以下公式,

    P(1 + R / 100)T

Where,

哪里,

  • P – Principle amount

    P –本金

  • R – Rate of the interest, and

    R –利率,以及

  • T – Time in the years

    T –岁月

Example:

例:

    Input:
p = 250000
r = 36
t = 1
# formula
ci =  p * (pow((1 + r / 100), t)) 
print(ci)
Output:
339999.99999999994

Python程序找到复利 (Python program to find compound interest)

# Python program to find compound interest 
p = float(input("Enter the principle amount : "))
r = float(input("Enter the rate of interest : "))
t = float(input("Enter the time in the years: "))
# calculating compound interest
ci =  p * (pow((1 + r / 100), t)) 
# printing the values
print("Principle amount  : ", p)
print("Interest rate     : ", r)
print("Time in years     : ", t)
print("compound Interest : ", ci)

Output

输出量

First run:
Enter the principle amount : 10000
Enter the rate of interest : 3.5
Enter the time in the years: 1
Principle amount  :  10000.0
Interest rate     :  3.5
Time in years     :  1.0
compound Interest :  10350.0
Second run:
Enter the principle amount : 250000
Enter the rate of interest : 36
Enter the time in the years: 1
Principle amount  :  250000.0
Interest rate     :  36.0
Time in years     :  1.0
compound Interest :  339999.99999999994

翻译自: https://www.includehelp.com/python/program-for-compound-interest.aspx

python计算连续复利

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.tpcf.cn/news/544045.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

聊聊Java中代码优化的30个小技巧

今天我们一起聊聊Java中代码优化的30个小技巧,希望会对你有所帮助。1.用String.format拼接字符串不知道你有没有拼接过字符串,特别是那种有多个参数,字符串比较长的情况。比如现在有个需求:要用get请求调用第三方接口,…

scala 字符串函数_Scala中的字符串chomp(或chop)函数

scala 字符串函数剁或剁弦 (Chop or Chomp string) It is used to chop off the end of line characters. For this Scala has an inbuilt method stripLineEnd. 它用于截断行尾字符。 为此,Scala具有内置方法stripLineEnd 。 Syntax: 句法: string.st…

Linux扩展根分区大小

1、查看当前逻辑卷的分布df -h2、卸载home分区umount /home注意:无法卸载时候,使用以下命令结束进程:fuser -m /home3、调整home分区大小为20Gresize2fs -p /dev/mapper/VolGroup-lv_home 20G4、检查home分区e2fsck -f /dev/mapper/VolGroup-…

面试突击69:TCP 可靠吗?为什么?

作者 | 磊哥来源 | Java面试真题解析(ID:aimianshi666)转载请联系授权(微信ID:GG_Stone)相比于 UDP 来说,TCP 的主要特性是三个:有连接、可靠、面向数据流。所谓的“有连接”指的是 …

vc++中画线时xor_C ++'xor_eq'关键字和示例

vc中画线时xor"xor_eq" is an inbuilt keyword that has been around since at least C98. It is an alternative to ^ (EXCLUSIVE-OR Assignment) operator and it mostly uses for bit manipulations. “ xor_eq”是一个内置关键字,至少从C 98起就存在…

【学习笔记】java核心技术学习笔记整理

《java核心技术》 花了半天到一天又认真读了一下java核心技术中的类部分,感觉最近编程时候好多迷迷糊糊,“这样对不对呢,试一试。怎么不对呢”这类的迷糊问题原来都早有定义。 main函数必须在主类中 一个class就是一个机器,要使…

Java 是值传递还是引用传递?

作者 | 王磊来源 | Java中文社群(ID:javacn666)转载请联系授权(微信ID:GG_Stone)开篇先来曝答案,在 Java 语言中,本质只有值传递,而无引用传递,解释和证明详见…

用于数据分析的Python – Pandas

大熊猫 (Pandas) Pandas is an open-source library built on top of NumPy Pandas是建立在NumPy之上的开源库 It allows for fast analysis and data cleaning and preparation 它允许快速分析以及数据清理和准备 It excels in performance and productivity 它在性能和生产力…

1022词法分析实验总结

经过这次词法分析的实验之后,收获良多。弥补了一些知识空洞,以前不懂的知识也弄懂了。 显然这都得力于组员之间的合作与帮助,一人负责编写,其他在旁边给想法同时学习。程序中运用了许多for,if,while等的循环…

SpringCloud基于RocketMQ实现分布式事务

前言分布式事务是在微服务开发中经常会遇到的一个问题,之前的文章中我们已经实现了利用Seata来实现强一致性事务,其实还有一种广为人知的方案就是利用消息队列来实现分布式事务,保证数据的最终一致性,也就是我们常说的柔性事务。消…

c# uri.host_C#| 具有示例的Uri.Host属性

c# uri.hostUri.Host属性 (Uri.Host Property) Uri.Host Property is the instance property of Uri class which used to get host components from URI. This property returns a string value. This property may generate System.InvalidOperationException exception. Uri…

VS使用和错误收集

USE: VS引用相对路径(需要说明的是,“..\”表示退出这一目录) VS 2005项目中添加lib库以及代码中的相对路径 ERROR: fatal error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires M…

漫画:怎么证明sleep不释放锁,而wait释放锁?

wait 加锁示例public class WaitDemo {private static Object locker new Object();public static void main(String[] args) throws InterruptedException {WaitDemo waitDemo new WaitDemo();// 启动新线程,防止主线程被休眠new Thread(() -> {try {waitDemo…

机器学习 导论_机器学习导论

机器学习 导论什么是机器学习? (What is Machine Learning?) Machine learning can be vaguely defined as a computers ability to learn without being explicitly programmed, this, however, is an older definition of machine learning. A more modern defin…

就国内某个程序员问答网站的简单的分析

为什么80%的码农都做不了架构师?>>> 一、数据抓取 分析页面数据,设计数据表结构数据只要包含投票、回答数、问题状态、最后谁回答过、浏览数、问题标题、标签,数据样例如下:由于一开只打算爬问题标题,问题…

树的结构 数据结构_段树| 数据结构

树的结构 数据结构What is a segment tree? 什么是段树? A segment tree is a full binary tree where each node represents an interval. A node may store one or more data members of an interval which can be queried later. 段树是完整的二叉树&#xff0…

iOS开发中 常用枚举和常用的一些运算符(易错总结)

1、色值的随机值:#define kColorValue arc4random_uniform(256)/255.0 // arc4random_uniform(256)/255.0; 求出0.0~1.0之间的数字view.backgroundColor [UIColor colorWithRed:kColorValue green: kColorValue blue: kColorValue alpha: 0.5]; 2、定时器的使用&…

明明加了唯一索引,为什么还是产生重复数据?

前段时间我踩过一个坑:在mysql8的一张innodb引擎的表中,加了唯一索引,但最后发现数据竟然还是重复了。到底怎么回事呢?本文通过一次踩坑经历,聊聊唯一索引,一些有意思的知识点。1.还原问题现场前段时间&…

python字符串 切片_用于切片字符串的Python程序

python字符串 切片Given a string and number of characters (N), we have to slice and print the starting N characters from the given string using python program. 给定一个字符串和字符数( N ),我们必须使用python程序从给定的字符串中切片并打印开始的N个字…

nmap入门之主机发现

2019独角兽企业重金招聘Python工程师标准>>> #主机发现(HOST DISCOVERY) ##仅列出IP,不扫描 nmap -sL 192.168.70.0/24 > nmap_result.txt 2>&1##仅ping扫描,不扫描端口 nmap -sn 192.168.70.0/24##不ping扫…