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

相关推荐
云水-禅心5 分钟前
解决MacOS 安装Python之后默认版本指向不正确问题
开发语言·python·macos
冰暮流星6 分钟前
javascript之this关键字
开发语言·前端·javascript
rit84324996 分钟前
基于Qt的串口上位机控制蓝牙小车程序
开发语言·qt
百度Geek说7 分钟前
CodingAgent 的原始森林困境:一张地图能解决什么?
开发语言·javascript·ecmascript·coding agent
余大大.9 分钟前
SystemVerilog-参数宏与拼接符的使用
前端
羸弱的穷酸书生12 分钟前
跟AI学一手之前端导出
前端·文件导出
怕浪猫12 分钟前
Electron 开发实战(十三):性能优化策略|极速启动、低内存、流畅渲染、极致瘦身
前端·javascript·electron
想要成为糕糕手13 分钟前
JavaScript 异步编程完全指南
javascript·面试·promise
sunny.day15 分钟前
js原型与原型链
开发语言·javascript·原型模式·js原型链