--- tags: Python --- # Домашнее задание по склонению единиц измерения времени ```python #!/usr/bin/env python3 # -*- coding: utf-8 -*- import datetime import locale locale.setlocale(locale.LC_ALL, 'ru_RU') current_date_time = datetime.datetime.now() user_name = str(input('Введите Ваше имя: ')) if 0 <= current_date_time.hour < 4: greeting_time = 'Доброй ночи' elif 4 <= current_date_time.hour < 11: greeting_time = 'Доброе утро' elif 11 <= current_date_time.hour < 17: greeting_time = 'Добрый день' else: greeting_time = 'Добрый вечер' if current_date_time.hour % 10 == 1 and current_date_time.hour // 10 != 1: current_date_time_hour_unit = 'час' elif 5 > current_date_time.hour % 10 > 1 != current_date_time.hour // 10: current_date_time_hour_unit = 'часа' else: current_date_time_hour_unit = 'часов' if current_date_time.minute % 10 == 1 and current_date_time.minute // 10 != 1: current_date_time_minute_unit = 'минута' elif 5 > current_date_time.minute % 10 > 1 != current_date_time.minute // 10: current_date_time_minute_unit = 'минуты' else: current_date_time_minute_unit = 'минут' if current_date_time.second % 10 == 1 and current_date_time.second // 10 != 1: current_date_time_second_unit = 'секунда' elif 5 > current_date_time.second % 10 > 1 != current_date_time.second // 10: current_date_time_second_unit = 'секунды' else: current_date_time_second_unit = 'секунд' print(f'{greeting_time}, {user_name}!') print( f'Текущие время и дата: {current_date_time.hour} {current_date_time_hour_unit} ' f'{current_date_time.minute} {current_date_time_minute_unit} ' f'{current_date_time.second} {current_date_time_second_unit}, ' f'{current_date_time.day} число ' f'{current_date_time.month} месяц ' f'{current_date_time.year} год.') ``` ###### `Python`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up