当前位置:网站首页>PyQt5 rapid development and actual combat 10.2 compound interest calculation && 10.3 refresh blog clicks
PyQt5 rapid development and actual combat 10.2 compound interest calculation && 10.3 refresh blog clicks
2022-07-31 12:31:00 【Ding Jiaxiong】
PyQt5快速开发与实战
文章目录
10. 第10章 PyQt5 实战一:Classic program development
10.2 复利计算 && 10.3 Refresh blog hits
10.2.1 Compound interest calculation business
复利计算,It means after each interest accrual period,The interest accrued in the current period must be added to the principal,以计算下期的利息.这样,in each interest period,The interest of the previous period will become the interest-earning principal,即以利生利,也就是俗称的“利滚利”.This involves the present value of compound interest、Compound interest future value and compound interest calculation formula.
复利现值,It means in the case of calculating compound interest,To reach a certain amount of money in the future,The principal that must be invested now.所谓复利,Also known as lee-on-galley,It refers to the return of a deposit or investment,A way to make a new round of investment with capital and profit.
复利终值,It refers to the interest earned on the principal within the agreed period,Add the interest to the principal and then calculate the interest,The sum of the principal that is rolled over to the end of the agreed period.
复利计算公式:
其中P为本金,i为利率,nfor the holding period.
举例:
例如:某人用20000RMB yuan to invest in a project,annual rate of return5%,So what is the interest income after two years?
Calculated according to the compound interest formula,The interest income earned is:
20000X(1+5%)^2-2000×(1+5%)×(1+5%)
= 2000 ×1.05 ×1.05= 22050 (元)
10.2.2 Interface and logic implementation
# -*- coding: utf-8 -*-
''' 【简介】 银行复利计算 '''
from __future__ import division
import sys
from PyQt5.QtWidgets import (QApplication, QComboBox, QDialog,
QDoubleSpinBox, QGridLayout, QLabel)
class Form(QDialog):
def __init__(self, parent=None):
super(Form, self).__init__(parent)
principalLabel = QLabel("Principal:")
self.principalSpinBox = QDoubleSpinBox()
self.principalSpinBox.setRange(1, 1000000000)
self.principalSpinBox.setValue(1000)
self.principalSpinBox.setPrefix("RMB ")
rateLabel = QLabel("Rate:")
self.rateSpinBox = QDoubleSpinBox()
self.rateSpinBox.setRange(1, 100)
self.rateSpinBox.setValue(5)
self.rateSpinBox.setSuffix(" %")
yearsLabel = QLabel("Years:")
self.yearsComboBox = QComboBox()
self.yearsComboBox.addItem("1 year")
self.yearsComboBox.addItems(["{0} years".format(x)
for x in range(2, 31)])
amountLabel = QLabel("Amount")
self.amountLabel = QLabel()
grid = QGridLayout()
grid.addWidget(principalLabel, 0, 0)
grid.addWidget(self.principalSpinBox, 0, 1)
grid.addWidget(rateLabel, 1, 0)
grid.addWidget(self.rateSpinBox, 1, 1)
grid.addWidget(yearsLabel, 2, 0)
grid.addWidget(self.yearsComboBox, 2, 1)
grid.addWidget(amountLabel, 3, 0)
grid.addWidget(self.amountLabel, 3, 1)
self.setLayout(grid)
self.principalSpinBox.valueChanged.connect(self.updateUi)
self.rateSpinBox.valueChanged.connect(self.updateUi)
self.yearsComboBox.currentIndexChanged.connect(self.updateUi)
self.setWindowTitle("Interest")
self.updateUi()
def updateUi(self):
principal = self.principalSpinBox.value()
rate = self.rateSpinBox.value()
years = self.yearsComboBox.currentIndex() + 1
amount = principal * ((1 + (rate / 100.0)) ** years)
self.amountLabel.setText("RMB {0:.2f}".format(amount))
if __name__=="__main__":
from pyqt5_plugins.examples.exampleqmlitem import QtCore
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
app = QApplication(sys.argv)
form = Form()
form.show()
sys.exit(app.exec_())
10.3 Refresh blog hits
import sys
import time
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
class WebView(QWebEngineView):
def __init__(self ):
super(WebView, self).__init__()
url = 'https://blog.csdn.net/weixin_44226181?type=blog'
self.load( QUrl( url ) )
self.show()
QTimer.singleShot(1000*3 , self.close)
if __name__ == '__main__':
app = QApplication(sys.argv)
web = WebView()
print('### exec succeed !')
sys.exit(app.exec_())
call the main window
if __name__ == '__main__' :
for i in range(5):
os.system("python openweb.py")
print("Refreshing page. 次数 =>" , i)
time.sleep(5)
边栏推荐
- CameraToolUnity中两种摄像机的两种观察控制方式
- 最长算术(暑假每日一题 11)
- 手撕Verilog PWM呼吸灯
- Exploring Plain Vision Transformer Backbones for Object Detection 论文阅读笔记
- The 2nd activity of the TOGAF10 Standard Reading Club continues wonderfully, and the highlights will be reviewed!
- PyQt5快速开发与实战10.2 复利计算 && 10.3 刷新博客点击量
- 想吃菌子,当然是自己上山找了
- 如何正确地把服务器端返回的文件二进制流写入到本地保存成文件
- 普林斯顿微积分读本03第二章--编程实现函数图像绘制、三角学回顾
- WebGL给Unity传递参数问题1: Cannot read properties of undefined (reading ‘SendMessage‘)
猜你喜欢
Anaconda安装labelImg图像标注软件
AMBA APB学习记录(AMBA 2.0)
ESP8266-Arduino编程实例-HDC1008温度湿度传感器驱动
SAP 电商云 Spartacus UI 和 Accelerator UI 里的 ASM 模块
这款悄然崛起的国产API接口管理工具,你一定要晓得
DCM 中间件家族迎来新成员
JVS函数公式使用场景介绍
TOGAF10标准读书会第2场活动精彩继续,高光时刻回顾!
WebGL给Unity传递参数问题1: Cannot read properties of undefined (reading ‘SendMessage‘)
JVM 运行时数据区与JMM 内存模型详解
随机推荐
给你一个大厂面试的机会,你能面试上吗?进来看看!
kubernetes之服务发现
深度学习基本概念
jmeter性能测试步骤入门(性能测试工具jmeter)
消息队列面试题(2022最新整理)
WebGL给Unity传递参数问题1: Cannot read properties of undefined (reading ‘SendMessage‘)
Hybrid brain-computer interface system based on steady-state visual evoked potentials and attentional EEG
Use Excel to read data exposed by SAP ABAP CDS View through ODBC
B/S架构模式的一个整体执行流程
分布式监视 Zabbix 和 Prometheus 到底怎么选?千万别用错了!
SAP Commerce Cloud Product Review 的添加逻辑
Chrome开发自定义右键菜单实现快速跳转到指定页面
基于verilog的CRC校验(汇总)
CWE4.8 -- 2022年危害最大的25种软件安全问题
ASM module in SAP Ecommerce Cloud Spartacus UI and Accelerator UI
一文吃透哈希表
关于Mysql数据库的介绍
JVS开发套件产品定位
连续变量离散化教程
函数的参数