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

相关推荐
YYYing.2 分钟前
【设计模式系列 (五) 】原型模式
开发语言·后端·设计模式·原型模式·c/c++
吴声子夜歌2 分钟前
HTML——结构化微数据语言简介
前端·数据库·html
TeamDev4 分钟前
JxBrowser 9.5.2 版本发布啦!
java·前端·windows·chromium·混合应用·jxbrowser·浏览器控件
重生之小比特5 分钟前
【C++进阶】哈希表实现
开发语言·c++·哈希
鬼手点金5 分钟前
Claude Code示范案例-进阶学习路径
java·服务器·前端·学习·计算机视觉·前向传播
吴声子夜歌10 分钟前
HTML——Web Components开发
前端·html
m0_3807438716 分钟前
VisualStudio中OpenCV的创建与配置使用小结
开发语言·c++
FYKJ_201016 分钟前
springboot鲜花销售系统91056-计算机课程设计、毕业设计
vue.js·spring boot·后端·python·mysql·django·课程设计
子非鱼eva28 分钟前
ONNX模型导出实战:PyTorch 导出 ResNet18 模型
人工智能·pytorch·python·知识图谱·onnx·昇腾知识图谱