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