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万的情况

相关推荐
Blanche15008 分钟前
利用 RAG 为答疑机器人扩展知识范围
前端
天若有情67313 分钟前
【纯前端小工具】公历生日转农历,批量查询每年农历生日对应的公历日期(GitHub Pages在线直接用)
前端·javascript·github pages·农历转换·lunisolar·网页小工具
SoonITer14 分钟前
怎样构建一个 Agent-friendly 的网站
前端·agent
梦在远山后16 分钟前
从手写 Loop 到可恢复 Runtime:用 LangGraph、PostgreSQL Checkpoint 与 AG-UI 跑通中断恢复
python·langchain·agent
阿里嘎多学长21 分钟前
2026-09-20 GitHub 热点项目精选
开发语言·程序员·github·代码托管
颜进强30 分钟前
01 · NestJS 是什么:用途、解决什么问题、与热门框架对比
前端·后端·ai编程
wendZzoo33 分钟前
前端工程师的 3D 第一课:一个模型如何进入网页
前端
Yolanda_202235 分钟前
8.tensorboard的使用
python
颜进强44 分钟前
04 · NestJS 依赖注入:你在 `@Module` 写的 providers,和构造参数里那个类型,是怎么"对上"的?
前端·后端·ai编程
用户0332126663671 小时前
使用 Python 添加、隐藏或删除 PowerPoint 幻灯片
python