-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path09b-Functions-III.py
98 lines (46 loc) · 1.29 KB
/
09b-Functions-III.py
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
77
78
79
80
81
82
83
84
85
# *args & **kwargs ;
def function1(*args):
return sum(args)
print(function1(3, 6, 9))
def function2(**kwargs):
total = 0
for items in kwargs.values():
total += items
return total
print(function2(num1=33, num2=66))
def function3(*args, **kwargs):
total = 0
for items in kwargs.values():
total += items
return sum(args) + total
print(function3(3, 6, 9, num1=33, num2=66))
# Rule; params, *args, default parameters, **kwargs
def function4(name, *number, iq=369, **age):
return name, number, iq, age
print(function4("captain", 3, 6, 9, started_year=15, current_age=17))
#Exercise; Functions;
# - My code;
def highest_even(*number):
highest = max(number)
if (highest % 2 == 0):
return highest
print(highest_even(3, 6, 9, 30, 60, 90))
# Other Method;
def highest_even2(numbers):
even = []
for item in numbers:
if (item % 2 == 0):
even.append(item)
return max(even)
print(highest_even(3, 6, 9, 30, 60, 90, 306090))
"""
# Walrus Operator ( := )
-> It's focus is that, how to learn about new features of python.
-> just search, what's new in Python 3.X
-> Learn the feature now...
"""
a = "hellooo000"
while ((i := len(a)) > 5):
print(i)
a = a[:-1]
print(a)