-
Notifications
You must be signed in to change notification settings - Fork 0
Lesson 2 #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?
Lesson 2 #2
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,4 @@ | ||
| my_list = [22, 'editor', 887, 75.8, None] | ||
| for i in my_list: | ||
| print(f"{i}-{type(i)}") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| my_list = list(input("Введите целые числа через пробел: ").split()) | ||
| for i in range(1, len(my_list), 2): | ||
| my_list.insert(i-1, my_list.pop(i)) | ||
| print(my_list) | ||
|
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. выполнено |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # dict | ||
|
|
||
| month = int(input('Введите номер месяца: ')) | ||
|
|
||
| month_list = {1: 'Зима', 2: 'Зима', 12: 'Зима', | ||
| 3: 'Весна', 4: 'Весна', 5: 'Весна', | ||
| 6: 'Лето', 7: 'Лето', 8: 'Лето', | ||
| 9: 'Осень', 10: 'Осень', 11: 'Осень'} | ||
|
|
||
| for key, value in month_list.items(): | ||
| if key == month: | ||
| print(f'Результат через словарь: {value}') | ||
|
|
||
|
|
||
| # list | ||
|
|
||
| month_list = [None, 'Январь Зима', 'Февраль Зима', 'Март Весна', 'Апрель Весна', 'Май Весна', 'Июнь Лето', | ||
|
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. выполнено, но вопрос для чего здесь элемент None, |
||
| 'Июль Лето', 'Август Лето', 'Сентябрь Осень', 'Октябрь Осень', 'Ноябрь Осень', 'Декабрь Зима'] | ||
|
|
||
| for i in month_list: | ||
| if month_list.index(i) == month: | ||
| print(f'Результат через список: {i}') | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| user_str = list(input('Введети строку из нескольких слов, разделённых пробелами: ').split()) | ||
|
|
||
| for i in range(len(user_str)): | ||
| print(i + 1, ')', user_str[i][:10]) | ||
|
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. выполнено |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| my_list = [7, 5, 3, 3, 2] | ||
|
|
||
| user_number = float(input('Введите число от 0 до 100: ')) | ||
| i = 0 | ||
| for n in my_list: | ||
| if user_number <= n: | ||
| i += 1 | ||
| else: | ||
| break | ||
|
|
||
| my_list.insert(i, user_number) | ||
| print(my_list) | ||
|
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. нет задачи 6 |
||
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.
выполнено