当前位置:网站首页>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)

边栏推荐
- PAT考试总结(考试心得)
- Mysql环境变量的配置(详细图解)
- PyQt5快速开发与实战10.2 复利计算 && 10.3 刷新博客点击量
- 集群的安全模式
- Encapsulation of conversion between Json and objects (Gson)
- 亲测可用!!!WPF中遍历整个窗口的所有TextBox组件,对每个输入框做非空判断。
- 在 Excel 里使用 ODBC 读取 SAP BTP 平台上 CDS view 的数据
- 深度学习基本概念
- How does the SAP ABAP OData service support the $filter (filter) operation trial version
- 基于verilog的CRC校验(汇总)
猜你喜欢
随机推荐
FIFO深度计算学习记录(汇总)
关于IDEA开发工具的介绍
Hybrid brain-computer interface system based on steady-state visual evoked potentials and attentional EEG
CWE4.8 -- 2022年危害最大的25种软件安全问题
三相PWM整流器预测直接功率控制
Banyan Tree Loan GPU Hardware Architecture
AMBA APB学习记录(AMBA 2.0)
TOGAF10标准读书会第2场活动精彩继续,高光时刻回顾!
NPM 使用介绍
通过斐波那契数再谈函数递归2.0
Use ODBC in Excel to read data from CDS view on SAP BTP platform
给你一个大厂面试的机会,你能面试上吗?进来看看!
集群的安全模式
Service discovery of kubernetes
关于==和equals的区别和联系,面试这么回答就可以
ipv4和ipv6对比(IPV4)
[core]-ARMV7-A, ARMV8-A, ARMV9-A Architecture Introduction "Recommended Collection"
Character Functions and String Functions
anaconda虚拟环境安装pytorch gpu版本
JVM 运行时数据区与JMM 内存模型详解









