-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHW15_debug.py
More file actions
76 lines (64 loc) · 1.4 KB
/
HW15_debug.py
File metadata and controls
76 lines (64 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Task №1
# def f(a):
# return 18 * a * b
# print(f(1))
# Ошибка - name 'b' is not defined
# Исправленная функция
# def f(a,b):
# return 18 * a * b
# print(f(1,1))
# Task №2
# for i in range(1,11):
# summa += i
# print("The sum is: ", summa)
#Ошибка номер 3) Переменная summa не объявлена
# summa = 0
# for i in range(1,11):
# summa += i
# print("The sum is: ", summa)
#Task №3
# def is_even(n):
# if n % 2 == 0:
# print(n, " is even")
# else:
# print(n, " is odd")
# is_even('4')
#Ошибка - TypeError
# Исправленный код:
# def is_even(n):
# if n % 2 == 0:
# print(n, " is even")
# else:
# print(n, " is odd")
# is_even(4)
#Task №4
# def factorial(n):
# value = 1
# if n < 0:
# return None
# if n == 0:
# return 1
# while (n > 0):
# value *= n
# n -= 1
# return print(value)
# factorial(5)
#Task №5
# def is_palindrome(s):
# s = s.lower()
# l = len(s)//2
# for i in range(l):
# if s[i] != s[-i-1]:
# return print(False)
# return print(True)
# is_palindrome("accbcca")
#Task №6
# def multiply(lst):
# if len(lst) == 0:
# return None
# else:
# result = 1
# for i in lst:
# result *= i
# return result
# multiply([1,2,3,4,5])