该程序将确定最高薪水,并将其与具有该薪水数字的员工姓名一起打印出来。
我需要为员工制作一份清单,并为工资制作另一个清单。我可以找到最低/最高工资并将其打印出来,但我不知道如何打印出相应的员工。让这变得困难的是,我们只在第 6 章,而且我们只能使用到目前为止所学的内容。所以我们不能使用 Python 必须提供的很多内置函数(我们甚至还没有介绍 append() 方法,所以我不得不使用另一种方式添加到列表中......) max 和 min 也是不允许。
amount = int(input("How many employees?: "))
if amount <= 0:
print("You cannot have 0 or less.")
name = []
salary = []
length = len(salary)
mini = 200000
maxi = 0
combined = (name, salary)
for i in range(1, amount + 1):
employee = input("What is the employee's name?: ")
name += [employee]
earned = int(input("How much is the salary? It cannot be less than 0 or over $200,000: "))
while earned <= 0 or earned >= 200000:
earned = int(input("How much is the salary? It cannot be less than 0 or over $200,000: "))
mini = earned
maxi = earned
salary += [earned]
total += earned
if earned < mini:
mini = earned
if earned > maxi:
maxi = earned