用python写一个最新法退休定年龄计算器
时间: 2024-09-14 15:04:50 浏览: 44
当然可以,下面是一个简单的Python程序,它用于计算按照中国最新的退休政策(男职工60岁退休,女干部55岁退休,女工人50岁退休)来确定退休年龄:
```python
def calculate_retirement_age(gender, birth_year):
if gender == 'male':
retirement_age = 60
elif gender.lower() in ['female', 'woman'] and 'officer' in birth_year:
# 假设女性干部在20世纪出生,以此作为例子
retirement_age = 55 + (birth_year - 1900) // 10 * 5
else:
# 女性工人或非干部假设在20世纪60年代及以后出生
retirement_age = 50 + (birth_year - 1960) // 10 * 5
return retirement_age
# 使用示例
birth_years = [1970, 1955, 1980] # 输入一些人的出生年份
for birth_year in birth_years:
age = calculate_retirement_age('male', birth_year)
print(f"男性,{birth_year}年出生,预计退休年龄为 {age}岁.")
female_officer_age = calculate_retirement_age('Female Officer', birth_year)
print(f"女性干部,{birth_year}年出生,预计退休年龄为 {female_officer_age}岁.")
female_worker_age = calculate_retirement_age('female worker', birth_year)
print(f"女性工人,{birth_year}年出生,预计退休年龄为 {female_worker_age}岁.")
阅读全文