Commit 0a6f03df by Patryk Czarnik

emps_obiektowo - zadania nt średniej

parent e3615cb3
from employees import read_csv
emps = read_csv('emps.csv')
ile = 0
for emp in emps:
if emp.salary >= 10_000:
print(f'Pracownik {emp.first_name} {emp.last_name} ({emp.job_title}) zarabia ${emp.salary}')
ile += 1
print('Liczba bogatych:', ile)
from employees import read_csv
emps = read_csv('emps.csv')
ile = 0
suma = 0
for emp in emps:
suma += emp.salary
ile += 1
srednia = suma / ile
print('Średnia wszystkich:', srednia)
from employees import read_csv
jaki_job = input('Podaj nazwę stanowiska, np. Programmer: ')
emps = read_csv('emps.csv')
ile = 0
suma = 0
for emp in emps:
if emp.job_title == jaki_job:
suma += emp.salary
ile += 1
if ile > 0:
srednia = suma / ile
print(f'Średnia pensja {ile} pracowników na stanowisku {jaki_job} wynosi: {srednia:.2f}')
else:
print(f'Nikt nie pracuje na stanowisku {jaki_job}')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment