ex19 函数和变量 习题三 自编函数

本文介绍了一个使用Python编写的薪资计算器,该计算器能够根据基本工资、绩效工资和绩效分数计算员工的总薪资。此外,还展示了如何从另一个Python文件调用此计算器函数,并通过用户输入动态计算薪资。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、

ex19_1.py

# this is ex19's excrist
def Burst_price(user_name, basic_pay, performance_pay, performance_score):
    print(f"Hi,{user_name}")
    print(f"Your basic pay is {basic_pay} $.")
    print(f"And performance pay is {performance_pay} $.")
    print(f"This month your performance score is {performance_score}.")
    print(f"So the month your pay is", basic_pay + performance_pay * performance_score/10, "$")


Burst_price("xiaoming", 3000, 5000, 8)
print("-" * 30)

print("Hi, Can I ask you some question?")
print("Please hit RETURN to countinue, OR CTRL-C to stop")
input("?")

score = 7.7
name = input("What's your name?")
basic = int(input("how much your basic?"))
performance = int(input("How nuch your performance?"))
print(f"OK, this month your performance_score is {score}. \n SO" )

Burst_price(name, basic, performance, score)

遇到的问题:

print(f""),f代表字符串,在合计工资总数是按照上面的类型写在了{}中。系统报错

TypeError: unsupported operand type(s) for *: 'set' and 'set'

之后,写在“”外画蛇添足的 int({ })形式。

 

二 本地函数的调用。

test_19_1.py

from ex19_1 import Burst_price

Burst_price("Lily", 5000, 2000, 5.5)

运行结果:

Hi,xiaoming
Your basic pay is 3000 $.
And performance pay is 5000 $.
This month your performance score is 8.
So the month your pay is 7000.0 $
Hi,Lily
Your basic pay is 5000 $.
And performance pay is 2000 $.
This month your performance score is 5.5.
So the month your pay is 6100.0 $

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值