Created
February 17, 2023 13:06
-
-
Save bannovGB/c623bad44576a7417135ebcf9a79823b to your computer and use it in GitHub Desktop.
Python_lesson06.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Задача 30: Заполните массив элементами арифметической прогрессии. Её первый элемент, разность и количество | |
элементов нужно ввести с клавиатуры. Формула для получения n-го члена прогрессии: a | |
n = a1 + (n-1) * d. | |
Каждое число вводится с новой строки. | |
Ввод: 7 2 5 | |
Вывод: 7 9 11 13 15''' | |
a1 = 7 | |
d = 2 | |
n = 5 | |
for i in range(n): | |
print(a1 + i * d, end=' ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Определить индексы элементов массива (списка), значения которых принадлежат заданному диапазону | |
(т.е. не меньше заданного минимума и не больше заданного максимума) | |
Ввод: [-5, 9, 0, 3, -1, -2, 1, 4, -2, 10, 2, 0, -9, 8, 10, -9, 0, -5, -5, 7] | |
Вывод: [1, 9, 13, 14, 19]''' | |
list_1 = [-5, 9, 0, 3, -1, -2, 1, 4, -2, 10, 2, 0, -9, 8, 10, -9, 0, -5, -5, 7] | |
list_2 = [] | |
max = 10 | |
min = 6 | |
# for i in range(len(lst_1)): | |
# if list_1[i] >= min and list_1[i] <= max: | |
# list_2.append(i) | |
# print(list_2) | |
# или | |
for i in range(len(list_1)): | |
if min <= list_1[i] <= max: | |
print(i, end=' ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment