1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- from functools import reduce
- def func_1():
- a, b, *c = [1, True, 4, 6, 'hello ', 7, 9]
- print(a, b, c)
- a, *b, c = [1, True, 4, 6, 'hello ', 7, 9]
- print(a, b, c)
- *a, b, c = [1, True, 4, 6, 'hello ', 7, 9]
- print(a, b, c)
- a, *b, c = 'hello moto'
- print(a, b, c)
- a, *b, c = [1, 4]
- print(a, b, c)
- def func_2():
- a, b, *c = range(5)
- print(c)
- *a, b, c = 'No money', 'no honey'
- print(a, b, c)
-
- *values, = [1, 2, 3, 4, 5]
- print(values)
- def print_values(*values):
- print(values, sep=',')
- def count_args(*args):
- return len(args)
- def multiply(*args):
- if not args:
- return 1
- return reduce(lambda a, b: a*b, args)
- def check_sum(*args):
- return print("not enough") if sum(args) < 50 else print("verification passed")
- def is_only_one_positive(*args):
- return len(list(filter(lambda x: x > 0, args))) == 1
- def print_goods(*args):
- counter = 1
- for x in args:
- if isinstance(x, str) and x != "":
- print(f'{counter}. {x}')
- counter += 1
- if counter == 1:
- print('Нет товаров')
- def main():
-
-
-
-
-
-
-
-
-
-
-
- print_goods(1, True, 'Грушечка', '', 'Pineapple')
- if __name__ == '__main__':
- main()
|