-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharg_recur.py
More file actions
26 lines (16 loc) · 827 Bytes
/
arg_recur.py
File metadata and controls
26 lines (16 loc) · 827 Bytes
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
# 1. name_args — Accepts any number of named arguments and prints them in the pattern key : value one at a time.
def name_args(**kwargs):
for k in kwargs.keys():
print(f"{k}:{kwargs[k]}")
name_args(name="Random", weather="sunny",location="park",time=3)
# 2. all_true — Returns True if all the elements in an iterable are true. Hint: there is an existing built-in function that could be very helpful here.
def all_true(iter):
return all(iter)
print(all_true([True,True,True]))
print(all_true((True, False)))
# 3. one_true — Returns True if one of the elements in an iterable is true. Hint: there is an existing built-in function that could be very helpful here.
def one_true(iter):
return any(iter)
print(one_true([True,True,True]))
print(one_true([False, False, False]))
print(one_true((True, False)))