update
This commit is contained in:
parent
c2332f8f45
commit
51a9a4a149
@ -0,0 +1,30 @@
|
||||
# students = ['Ivan', 'Masha', 'Sasha']
|
||||
# students += ['Olga']
|
||||
# students += 'Olga'
|
||||
# print (students)
|
||||
|
||||
# a = [1, 2, 3]
|
||||
# b = a
|
||||
# print (b)
|
||||
# a[1] = 10
|
||||
# print (b)
|
||||
# b[0] = 20
|
||||
# print (b)
|
||||
# print (a)
|
||||
# a = [5, 6]
|
||||
# print (b)
|
||||
# print (a)
|
||||
|
||||
# # переделать в список каждую отдельную цифру
|
||||
# num = 1234
|
||||
# lst = [int(i) for i in str(num)]
|
||||
|
||||
# # наоборот из списка в набор слов через пробел
|
||||
# b = ("apple", "banana", "cherry")
|
||||
# print (" ".join(b))
|
||||
|
||||
|
||||
n =3
|
||||
a = [[0]*n]*n
|
||||
a[0][0]= 5
|
||||
print (a)
|
24
practica/stepik/beneficial_features/double.py
Normal file
24
practica/stepik/beneficial_features/double.py
Normal file
@ -0,0 +1,24 @@
|
||||
# нахождение дубликатов и вывод уникальных элементов
|
||||
a = input().split()
|
||||
a2 = []
|
||||
for item in a:
|
||||
c = a.count(item)
|
||||
if c > 1:
|
||||
a2.append(item)
|
||||
if c == 1:
|
||||
None
|
||||
def del_dubl(a2):
|
||||
seen = set()
|
||||
seen_add = seen.add
|
||||
return [x for x in a2 if not (x in seen or seen_add(x))]
|
||||
for i in del_dubl(a2):
|
||||
print(i, end=' ')
|
||||
|
||||
|
||||
# удаление дубликатов и вывод уникальных в виде списка
|
||||
a = input().split()
|
||||
def del_dubl(a):
|
||||
seen = set()
|
||||
seen_add = seen.add
|
||||
return [x for x in a if not (x in seen or seen_add(x))]
|
||||
print (del_dubl(a))
|
@ -5,4 +5,15 @@
|
||||
# print ("\t",str(num), sep='\t')
|
||||
|
||||
# num = 12
|
||||
# print("\t" + str(num), end="")
|
||||
# print("\t" + str(num), end="")
|
||||
|
||||
# for j in range(1):
|
||||
# print ("c", end="v")
|
||||
|
||||
# a = 1
|
||||
# m=2
|
||||
# n=3
|
||||
# print (a+ m,n,end ="\t")
|
||||
|
||||
# for i in range(c, d + 1):
|
||||
# print("\t" + str(i), end="")
|
@ -1,2 +1,5 @@
|
||||
a, b, c, d = int(input()), int(input()), int(input()), int(input())
|
||||
# построчный инпут записанный в 1 строку
|
||||
# a, b, c, d = int(input()), int(input()), int(input()), int(input())
|
||||
|
||||
|
||||
|
||||
|
@ -35,15 +35,4 @@
|
||||
# print()
|
||||
|
||||
|
||||
initial_list = input().split()
|
||||
sum_list = []
|
||||
left_index = -1
|
||||
right_index = -len(initial_list) + 1
|
||||
middle_index = 0
|
||||
while middle_index < len(initial_list):
|
||||
sum_list.append(initial_list[left_index] + initial_list[right_index])
|
||||
left_index += 1
|
||||
right_index += 1
|
||||
middle_index += 1
|
||||
print(sum_list)
|
||||
|
||||
|
@ -1,38 +1,38 @@
|
||||
# вариант решения 1
|
||||
# a = input().split()
|
||||
# len_a = len(a) - 1
|
||||
# for index, number in enumerate(a):
|
||||
# if len_a == 0:
|
||||
# print (number)
|
||||
# else:
|
||||
# if index == 0:
|
||||
# S = int(a[-1]) + int(a[1])
|
||||
# b = str(S)
|
||||
# elif index != 0 and index != int(len_a) :
|
||||
# n_index_0 = int(int(a.index(number)) + 1)
|
||||
# n_index_2 = int(int(a.index(number)) - 1)
|
||||
# n_0 = a[n_index_0]
|
||||
# N_2 = a[n_index_2]
|
||||
# S1 = int(n_0) + int(N_2)
|
||||
# b += " " + str(S1)
|
||||
# elif index == int(len_a):
|
||||
# S2 = int(a[0]) + int(a[-2])
|
||||
# b += " " + str(S2)
|
||||
# print (b)
|
||||
a = input().split()
|
||||
len_a = len(a) - 1
|
||||
for index, number in enumerate(a):
|
||||
if len_a == 0:
|
||||
print (number)
|
||||
else:
|
||||
if index == 0:
|
||||
S = int(a[-1]) + int(a[1])
|
||||
b = str(S)
|
||||
elif index != 0 and index != int(len_a) :
|
||||
n_index_0 = int(int(a.index(number)) + 1)
|
||||
n_index_2 = int(int(a.index(number)) - 1)
|
||||
n_0 = a[n_index_0]
|
||||
N_2 = a[n_index_2]
|
||||
S1 = int(n_0) + int(N_2)
|
||||
b += " " + str(S1)
|
||||
elif index == int(len_a):
|
||||
S2 = int(a[0]) + int(a[-2])
|
||||
b += " " + str(S2)
|
||||
print (b)
|
||||
|
||||
|
||||
# вариант решения 2 -короче
|
||||
# initial_list = input().split()
|
||||
# sum_list = []
|
||||
# left_index = -1
|
||||
# right_index = -len(initial_list) + 1
|
||||
# middle_index = 0
|
||||
# while middle_index < len(initial_list):
|
||||
# sum_list.append(initial_list[left_index] + initial_list[right_index])
|
||||
# left_index += 1
|
||||
# right_index += 1
|
||||
# middle_index += 1
|
||||
# print(sum_list)
|
||||
initial_list = input().split()
|
||||
sum_list = []
|
||||
left_index = -1
|
||||
right_index = -len(initial_list) + 1
|
||||
middle_index = 0
|
||||
while middle_index < len(initial_list):
|
||||
sum_list.append(initial_list[left_index] + initial_list[right_index])
|
||||
left_index += 1
|
||||
right_index += 1
|
||||
middle_index += 1
|
||||
print(sum_list)
|
||||
|
||||
# вариант решения 3
|
||||
a = [int(item) for item in input().split()]
|
||||
|
Loading…
Reference in New Issue
Block a user