-
Notifications
You must be signed in to change notification settings - Fork 0
Create home_work_lesson1.py #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # 1. Поработайте с переменными, создайте несколько, выведите на экран. Запросите у пользователя некоторые числа и строки и сохраните в переменные, затем выведите на экран. | ||
|
|
||
| username = input("Укажите имя:") | ||
| age = int(input("Укажите возраст:")) | ||
| print("{} отмечает сегодня день рожления, ему {}".format(username, age)) | ||
|
|
||
| # 2. Пользователь вводит время в секундах. Переведите время в часы, минуты, секунды и выведите в формате чч:мм:сс. Используйте форматирование строк. | ||
|
|
||
| def conversion(sec): | ||
| sec_value = sec % (24 * 3600) | ||
| hour_value = sec_value // 3600 | ||
| sec_value %= 3600 | ||
| min = sec_value // 60 | ||
| sec_value %= 60 | ||
| print("{}:{}:{}".format(hour_value, min, sec_value)) | ||
| sec = int(input("Укажите количество секунд:")) | ||
| conversion(sec) | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. выполнено |
||
| # 3. Узнайте у пользователя число n. Найдите сумму чисел n + nn + nnn. Например, пользователь ввёл число 3. Считаем 3 + 33 + 333 = 369. | ||
|
|
||
| n = int(input("Введите число n:")) | ||
| temp = str(n) | ||
| nn = temp + temp | ||
| nnn = temp + temp + temp | ||
| comp = n + int(nn) + int(nnn) | ||
| print("Результат равен:", comp) | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. выполнено |
||
| #4. Пользователь вводит целое положительное число. Найдите самую большую цифру в числе. Для решения используйте цикл while и арифметические операции. | ||
|
|
||
| a = int(input("Введите число, для поиска наибольшего числа:")) | ||
| m = a % 10 | ||
| a = a // 10 | ||
| while a > 0: | ||
| if a % 10 > m: | ||
| m = a % 10 | ||
| a = a // 10 | ||
| print("Наибольшое число:{}".format(m)) | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. выполнено There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. нет задач 5-7 |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лучше через ф-строку