python实现存款日利息计算器(窗口界面形式)

输入存款金额,7日年化收益率,输出每日利息

完整源码如下:

复制代码
import tkinter as tk
from tkinter import messagebox

def calculate_interest():
    deposit = float(entry_deposit.get())
    interest_rate = float(entry_interest_rate.get())

    daily_interest_rate = interest_rate / 365  # 计算每日利率
    daily_interest = round(deposit * daily_interest_rate, 2)  # 计算每日收益并保留两位小数

    result_label.config(text=f"每天的收益为:{daily_interest}")

# 创建窗口
window = tk.Tk()
window.title("存款利息计算器")
window.geometry("400x200")  # 设置窗口大小

# 创建标签和输入框
label_deposit = tk.Label(window, text="存款金额:")
label_deposit.pack()
entry_deposit = tk.Entry(window)
entry_deposit.pack()

label_interest_rate = tk.Label(window, text="7日年化收益率:")
label_interest_rate.pack()
entry_interest_rate = tk.Entry(window)
entry_interest_rate.pack()

# 创建按钮
button_calculate = tk.Button(window, text="计算", command=calculate_interest)
button_calculate.pack()

# 创建结果标签
result_label = tk.Label(window, text="每天的收益为:")
result_label.pack()

# 运行窗口
window.mainloop()

运行结果如下:

10万和1000万的情况

相关推荐
guslegend4 分钟前
脚手架原理与本地调试:从 bin 软链接到 npm link
前端·npm·node.js·脚手架·前端工程化
2601_966949658 分钟前
多市场量化策略的数据接口应该如何设计:从数据层架构到策略接入
开发语言·python·数据分析·pandas·量化交易·股票数据·quantdash
小宋102111 分钟前
A2UI从零实战:Agent安全生成交互界面与事件回传
javascript·人工智能·安全·交互
坤坤子吖11 分钟前
C++智能指针:RAII、shared_ptr与内存泄漏
开发语言·c++·笔记·学习
全栈弄潮儿18 分钟前
Python实战第1期:Python环境搭建与第一个程序
python
奋斗的阿狸_198621 分钟前
ESP32-S3 + ES7210 四通道麦克风录音上传方案
c语言·开发语言·fpga开发
心易行者23 分钟前
Agent应用+API端点商业化进阶实战:从单体智能体到可付费调用的API全流程
运维·服务器·人工智能·python·apache
大包子36 分钟前
structuredClone vs lodash.cloneDeep:核心差异与选型指南
javascript·vue.js
weixin1997010801636 分钟前
《1688图片空间API踩坑:img.upload 与 album.* 的防盗链与CDN缓存问题》(附Python源码)
开发语言·python·缓存
海码事务所37 分钟前
Google Play 新个人开发者账号上架指南:12 人连续 14 天封闭测试怎么做?
前端