40 lines
882 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

marbles = [10, 13, 39, 14, 41, 9, 3, 100]
def recursive_compute_sum(list):
if len(list) == 0:
return 0
else:
first = list[0]
rest = list[1:]
sum = first + recursive_compute_sum(rest)
return sum
sum = recursive_compute_sum(marbles)
print('Сумма равна', sum)
letter = 'radars'
def polindrom(str):
# с помощию цикла
# list = []
# ob_list = []
# for i in str:
# list.append(i)
# for i in str[::-1]:
# ob_list.append(i)
# if list == ob_list:
# return 'полиндром'
# else:
# return 'не полиндром'
# без цикла, просто через срез
if str == str[::-1]:
return 'полиндром'
else:
return 'не полиндром'
status = polindrom(letter)
print('Слово', letter, status)