Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 1)
- def f(a,b):
- return 18 * a * b
- print(f(1,4))
- #Ответ: 2
- #2)
- summa = 0
- for i in range(1,11):
- summa += i
- print('The sum is', summa)
- #Ответ: 3
- #3)
- def is_even(n):
- if n % 2 == 0:
- return (n,'is even')
- else:
- return (n, "is odd")
- print(is_even(int('4')))
- #Ответ: 3
- #4)
- def factorial(n):
- if n < 0:
- return None
- if n == 0:
- return 1
- else:
- return n * factorial(n - 1)
- print(factorial(int(input())))
- #5)
- def is_palindrom(s):
- s = s.lower()
- for i in range(len(s)):
- if s[i] != s[len(s) - i - 1]:
- return False
- return True
- print(is_palindrom('шалаш'))
- #6)
- def multiplylist(lst):
- if len(lst) == 0:
- return None
- else:
- result = 1
- for i in range(len(lst)):
- result = result * lst[i]
- return result
- print(multiplylist([1,2,3,4,5]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement