-1

最低の給与 (私は既に把握しています) と、その最低の給与に関連する名前を表示したいと考えています。印刷すると次のようになります。

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]
    if earned < mini:
        mini = earned
    if earned > maxi:
        maxi = earned

average = sum(salary)/len(salary)

print('The Average Salary is: $',average)
print('The Lowest Salary is: $',mini,'Produced by: ',name)
print('The Highest Salary is: $',maxi,'Produced by: ',name)
4

3 に答える 3

2

または、最小値と最大値のインデックスを見つけることができます

maxi = salary.index(max(salary))
mini = salary.index(min(salary))

maxsal = salary[maxi]
maxname = name[maxi]

minsal = salary[mini]
minname = name[mini]
于 2013-04-10T18:03:42.013 に答える
0
print('The Lowest Salary is: ' + str(mini) + ' Produced by: ' + name)

次のようなこともできます。

print('The Lowest salary is %d Produced by: %s' % (mini, name))
于 2013-04-10T17:54:40.233 に答える