8.2. Idiom All

  • Return True if all elements of the iterable are true

  • If the iterable is empty, return True

  • Built-in

8.2.1. Problem

>>> data = [True, False, True]
>>>
>>> result = True
>>> for x in data:
...     if x is False:
...         result = False
>>>
>>> result
False

8.2.2. Solution

>>> data = [True, False, True]
>>> result = all(data)
>>>
>>> result
False

8.2.3. Implementation

>>> def all(iterable):
...     for element in iterable:
...         if not element:
...             return False
...     return True

8.2.4. Case Study

  • Date: 2024-08-29

  • Python: 3.12.5

  • IPython: 8.26.0

  • System: macOS 14.6.1

  • Computer: MacBook M3 Max

  • CPU: 16 cores (12 performance and 4 efficiency) / 3nm

  • RAM: 128 GB RAM LPDDR5

DATA = [
    ('sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'species'),
    (5.8, 2.7, 5.1, 1.9, 'virginica'),
    (5.1, 3.5, 1.4, 0.2, 'setosa'),
    (5.7, 2.8, 4.1, 1.3, 'versicolor'),
    (6.3, 2.9, 5.6, 1.8, 'virginica'),
    (6.4, 3.2, 4.5, 1.5, 'versicolor'),
    (4.7, 3.2, 1.3, 0.2, 'setosa'),
    (7.0, 3.2, 4.7, 1.4, 'versicolor'),
    (7.6, 3.0, 6.6, 2.1, 'virginica'),
    (4.6, 3.1, 1.5, 0.2, 'setosa'),
]

header, *rows = DATA

# %% all value >= 1.0

answers = []
for *values, species in rows:
    for value in values:
        answers.append(value >= 1.0)

result = all(answers)

# %%

print(result)

# %%timeit -n 1000 -r 1000
# 1.25 μs ± 68.2 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
# 1.25 μs ± 77.3 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
# 1.32 μs ± 78.2 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
DATA = [
    ('sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'species'),
    (5.8, 2.7, 5.1, 1.9, 'virginica'),
    (5.1, 3.5, 1.4, 0.2, 'setosa'),
    (5.7, 2.8, 4.1, 1.3, 'versicolor'),
    (6.3, 2.9, 5.6, 1.8, 'virginica'),
    (6.4, 3.2, 4.5, 1.5, 'versicolor'),
    (4.7, 3.2, 1.3, 0.2, 'setosa'),
    (7.0, 3.2, 4.7, 1.4, 'versicolor'),
    (7.6, 3.0, 6.6, 2.1, 'virginica'),
    (4.6, 3.1, 1.5, 0.2, 'setosa'),
]

header, *rows = DATA

# %% all value >= 1.0

result = True
for *values, species in rows:
    for value in values:
        if value < 1.0:
            result = False

# %%

print(result)

# %%timeit -n 1000 -r 1000
# 961 ns ± 72.9 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
# 970 ns ± 80.8 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
# 978 ns ± 79.3 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
DATA = [
    ('sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'species'),
    (5.8, 2.7, 5.1, 1.9, 'virginica'),
    (5.1, 3.5, 1.4, 0.2, 'setosa'),
    (5.7, 2.8, 4.1, 1.3, 'versicolor'),
    (6.3, 2.9, 5.6, 1.8, 'virginica'),
    (6.4, 3.2, 4.5, 1.5, 'versicolor'),
    (4.7, 3.2, 1.3, 0.2, 'setosa'),
    (7.0, 3.2, 4.7, 1.4, 'versicolor'),
    (7.6, 3.0, 6.6, 2.1, 'virginica'),
    (4.6, 3.1, 1.5, 0.2, 'setosa'),
]

header, *rows = DATA

# %% all value >= 1.0

result = True
for *values, species in rows:
    for value in values:
        if value < 1.0:
            result = False
            break

# %%

print(result)

# %%timeit -n 1000 -r 1000
# 940 ns ± 58 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
# 944 ns ± 67.4 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
# 971 ns ± 70.7 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
DATA = [
    ('sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'species'),
    (5.8, 2.7, 5.1, 1.9, 'virginica'),
    (5.1, 3.5, 1.4, 0.2, 'setosa'),
    (5.7, 2.8, 4.1, 1.3, 'versicolor'),
    (6.3, 2.9, 5.6, 1.8, 'virginica'),
    (6.4, 3.2, 4.5, 1.5, 'versicolor'),
    (4.7, 3.2, 1.3, 0.2, 'setosa'),
    (7.0, 3.2, 4.7, 1.4, 'versicolor'),
    (7.6, 3.0, 6.6, 2.1, 'virginica'),
    (4.6, 3.1, 1.5, 0.2, 'setosa'),
]

header, *rows = DATA

# %% all value >= 1.0

result = True
for *values, species in rows:
    for value in values:
        if value < 1.0:
            result = False
            break
    if result is False:
        break

# %%

print(result)

# %%timeit -n 1000 -r 1000
# 247 ns ± 31.2 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
# 245 ns ± 26.8 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
# 247 ns ± 29.7 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
DATA = [
    ('sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'species'),
    (5.8, 2.7, 5.1, 1.9, 'virginica'),
    (5.1, 3.5, 1.4, 0.2, 'setosa'),
    (5.7, 2.8, 4.1, 1.3, 'versicolor'),
    (6.3, 2.9, 5.6, 1.8, 'virginica'),
    (6.4, 3.2, 4.5, 1.5, 'versicolor'),
    (4.7, 3.2, 1.3, 0.2, 'setosa'),
    (7.0, 3.2, 4.7, 1.4, 'versicolor'),
    (7.6, 3.0, 6.6, 2.1, 'virginica'),
    (4.6, 3.1, 1.5, 0.2, 'setosa'),
]

header, *rows = DATA

# %% all value >= 1.0

answers = []
for *values, species in rows:
    answer = all(value>=1.0 for value in values)
    answers.append(answer)

result = all(answers)

# %%

print(result)

# %%timeit -n 1000 -r 1000
# 2.63 μs ± 120 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
# 2.63 μs ± 135 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
# 2.64 μs ± 116 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
DATA = [
    ('sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'species'),
    (5.8, 2.7, 5.1, 1.9, 'virginica'),
    (5.1, 3.5, 1.4, 0.2, 'setosa'),
    (5.7, 2.8, 4.1, 1.3, 'versicolor'),
    (6.3, 2.9, 5.6, 1.8, 'virginica'),
    (6.4, 3.2, 4.5, 1.5, 'versicolor'),
    (4.7, 3.2, 1.3, 0.2, 'setosa'),
    (7.0, 3.2, 4.7, 1.4, 'versicolor'),
    (7.6, 3.0, 6.6, 2.1, 'virginica'),
    (4.6, 3.1, 1.5, 0.2, 'setosa'),
]

header, *rows = DATA

# %% all value >= 1.0

answers = []
for *values, species in rows:
    answer = all(value>=1.0 for value in values)
    answers.append(answer)
    if answer is False:
        break

result = all(answers)

# %%

print(result)

# %%timeit -n 1000 -r 1000
# 688 ns ± 58.6 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
# 663 ns ± 54.2 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
# 687 ns ± 59.1 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
DATA = [
    ('sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'species'),
    (5.8, 2.7, 5.1, 1.9, 'virginica'),
    (5.1, 3.5, 1.4, 0.2, 'setosa'),
    (5.7, 2.8, 4.1, 1.3, 'versicolor'),
    (6.3, 2.9, 5.6, 1.8, 'virginica'),
    (6.4, 3.2, 4.5, 1.5, 'versicolor'),
    (4.7, 3.2, 1.3, 0.2, 'setosa'),
    (7.0, 3.2, 4.7, 1.4, 'versicolor'),
    (7.6, 3.0, 6.6, 2.1, 'virginica'),
    (4.6, 3.1, 1.5, 0.2, 'setosa'),
]

header, *rows = DATA

# %% all value >= 1.0

result = all(value >= 1.0
             for *values, species in rows
             for value in values)

# %%

print(result)

# %%timeit -n 1000 -r 1000
# 527 ns ± 53.4 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
# 501 ns ± 47.1 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
# 511 ns ± 50.9 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
DATA = [
    ('sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'species'),
    (5.8, 2.7, 5.1, 1.9, 'virginica'),
    (5.1, 3.5, 1.4, 0.2, 'setosa'),
    (5.7, 2.8, 4.1, 1.3, 'versicolor'),
    (6.3, 2.9, 5.6, 1.8, 'virginica'),
    (6.4, 3.2, 4.5, 1.5, 'versicolor'),
    (4.7, 3.2, 1.3, 0.2, 'setosa'),
    (7.0, 3.2, 4.7, 1.4, 'versicolor'),
    (7.6, 3.0, 6.6, 2.1, 'virginica'),
    (4.6, 3.1, 1.5, 0.2, 'setosa'),
]

header, *rows = DATA

# %% all value >= 1.0

result = all(value >= 1.0 for *values, species in rows for value in values)

# %%

print(result)

# %%timeit -n 1000 -r 1000
# 503 ns ± 44.8 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
# 524 ns ± 61.1 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
# 509 ns ± 46.7 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
DATA = [
    ('sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'species'),
    (5.8, 2.7, 5.1, 1.9, 'virginica'),
    (5.1, 3.5, 1.4, 0.2, 'setosa'),
    (5.7, 2.8, 4.1, 1.3, 'versicolor'),
    (6.3, 2.9, 5.6, 1.8, 'virginica'),
    (6.4, 3.2, 4.5, 1.5, 'versicolor'),
    (4.7, 3.2, 1.3, 0.2, 'setosa'),
    (7.0, 3.2, 4.7, 1.4, 'versicolor'),
    (7.6, 3.0, 6.6, 2.1, 'virginica'),
    (4.6, 3.1, 1.5, 0.2, 'setosa'),
]

header, *rows = DATA

# %% all value >= 1.0

result = all(z>=1.0 for *x,y in rows for z in x)

# %%

print(result)

# %%timeit -n 1000 -r 1000
# 517 ns ± 47.8 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
# 553 ns ± 46.1 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
# 557 ns ± 49.5 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
DATA = [
    ('sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'species'),
    (5.8, 2.7, 5.1, 1.9, 'virginica'),
    (5.1, 3.5, 1.4, 0.2, 'setosa'),
    (5.7, 2.8, 4.1, 1.3, 'versicolor'),
    (6.3, 2.9, 5.6, 1.8, 'virginica'),
    (6.4, 3.2, 4.5, 1.5, 'versicolor'),
    (4.7, 3.2, 1.3, 0.2, 'setosa'),
    (7.0, 3.2, 4.7, 1.4, 'versicolor'),
    (7.6, 3.0, 6.6, 2.1, 'virginica'),
    (4.6, 3.1, 1.5, 0.2, 'setosa'),
]

header, *rows = DATA

# %% all value >= 1.0

result = all(x>=1.0 for *X,y in rows for x in X)

# %%

print(result)

# %%timeit -n 1000 -r 1000
# 545 ns ± 44.7 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
# 526 ns ± 56.6 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
# 519 ns ± 44.6 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)







# *X,y = (7.6, 3.0, 6.6, 2.1, 'virginica')

# X
# (7.6, 3.0, 6.6, 2.1)

# y
# 'virginica'

# x1 = 7.6
# x2 = 3.0
# x3 = 6.6
# x4 = 2.1

8.2.5. Use Case - 1

>>> all(x for x in range(0,5))
False

8.2.6. Use Case - 2

>>> users = [
...     {'is_admin': True,  'name': 'Mark Watney'},
...     {'is_admin': True,  'name': 'Melisa Lewis'},
...     {'is_admin': False, 'name': 'Rick Martinez'},
...     {'is_admin': True,  'name': 'Alex Vogel'},
...     {'is_admin': False, 'name': 'Beth Johanssen'},
...     {'is_admin': False, 'name': 'Chris Beck'},
... ]
>>>
>>>
>>> if all(user['is_admin'] for user in users):
...     print('Everyone is admin')
... else:
...     print('Not everyone is admin')
Not everyone is admin

8.2.7. Use Case - 3

>>> DATA = [
...     ('sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'species'),
...     (5.8, 2.7, 5.1, 1.9, 'virginica'),
...     (5.1, 3.5, 1.4, 0.2, 'setosa'),
...     (5.7, 2.8, 4.1, 1.3, 'versicolor'),
...     (6.3, 2.9, 5.6, 1.8, 'virginica'),
...     (6.4, 3.2, 4.5, 1.5, 'versicolor'),
...     (4.7, 3.2, 1.3, 0.2, 'setosa'),
...     (7.0, 3.2, 4.7, 1.4, 'versicolor'),
... ]
>>>
>>>
>>> all(value > 1.0
...     for *values, species in DATA[1:]
...     for value in values
...     if isinstance(value, float))
False

8.2.8. Performance

  • Date: 2024-12-04

  • Python: 3.13.0

  • IPython: 8.30.0

  • System: macOS 15.1.1

  • Computer: MacBook M3 Max

  • CPU: 16 cores (12 performance and 4 efficiency) / 3nm

  • RAM: 128 GB RAM LPDDR5

Setup:

>>> DATA = [
...     ('sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'species'),
...     (5.8, 2.7, 5.1, 1.9, 'virginica'),
...     (5.1, 3.5, 1.4, 0.2, 'setosa'),
...     (5.7, 2.8, 4.1, 1.3, 'versicolor'),
...     (6.3, 2.9, 5.6, 1.8, 'virginica'),
...     (6.4, 3.2, 4.5, 1.5, 'versicolor'),
...     (4.7, 3.2, 1.3, 0.2, 'setosa'),
...     (7.0, 3.2, 4.7, 1.4, 'versicolor'),
... ]
>>> # doctest: +SKIP
... %%timeit -n 1000 -r 1000
... result = []
... for row in DATA[1:]:
...     for value in row:
...         if isinstance(value, float):
...             result.append(value >= 1.0)
... result = all(result)
...
964 ns ± 85.9 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
925 ns ± 91.7 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
919 ns ± 52.7 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
941 ns ± 86.1 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
936 ns ± 77.8 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
>>> # doctest: +SKIP
... %%timeit -n 1000 -r 1000
... result = True
... for row in DATA[1:]:
...     for value in row:
...         if isinstance(value, float):
...             if not value >= 1.0:
...                 result = False
...                 break
...     if not result:
...         break
...
310 ns ± 47.3 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
306 ns ± 44.6 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
302 ns ± 33.5 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
307 ns ± 51.7 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
308 ns ± 57.2 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
>>> # doctest: +SKIP
... %%timeit -n 1000 -r 1000
... result = all(value >= 1.0
...              for row in DATA[1:]
...              for value in row
...              if isinstance(value, float))
...
386 ns ± 40.4 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
388 ns ± 58.6 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
387 ns ± 52.3 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
388 ns ± 52.6 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
385 ns ± 57.4 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
>>> # doctest: +SKIP
... %%timeit -n 1000 -r 1000
... result = all(value >= 1.0 for row in DATA[1:] for value in row if isinstance(value, float))
...
387 ns ± 63.4 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
389 ns ± 61 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
387 ns ± 55.2 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
384 ns ± 61 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
387 ns ± 64.3 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
>>> # doctest: +SKIP
... %%timeit -n 1000 -r 1000
... result = all(y >= 1.0 for x in DATA[1:] for y in x if isinstance(y, float))
...
387 ns ± 63.2 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
387 ns ± 65.5 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
388 ns ± 63.9 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
386 ns ± 58.7 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
385 ns ± 62.5 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
>>> # doctest: +SKIP
... %%timeit -n 1000 -r 1000
... result = all(x >= 1.0 for X in DATA[1:] for x in X if isinstance(x, float))
...
389 ns ± 60.7 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
388 ns ± 64.7 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
387 ns ± 60.7 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
386 ns ± 63.8 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)
387 ns ± 65.4 ns per loop (mean ± std. dev. of 1000 runs, 1,000 loops each)

8.2.9. Assignments

# %% License
# - Copyright 2025, Matt Harasymczuk <matt@python3.info>
# - This code can be used only for learning by humans
# - This code cannot be used for teaching others
# - This code cannot be used for teaching LLMs and AI algorithms
# - This code cannot be used in commercial or proprietary products
# - This code cannot be distributed in any form
# - This code cannot be changed in any form outside of training course
# - This code cannot have its license changed
# - If you use this code in your product, you must open-source it under GPLv2
# - Exception can be granted only by the author

# %% Run
# - PyCharm: right-click in the editor and `Run Doctest in ...`
# - PyCharm: keyboard shortcut `Control + Shift + F10`
# - Terminal: `python -m doctest -v myfile.py`

# %% About
# - Name: Idiom All IsAdmin
# - Difficulty: easy
# - Lines: 1
# - Minutes: 3

# %% English
# 1. Define `result: bool` with the result of checking
#    if all users has admin role
# 2. Run doctests - all must succeed

# %% Polish
# 1. Zdefiniuj `result: bool` z wynikiem sprawdzenia
#    czy wsyscy użytkownicy mają rolę admin
# 2. Uruchom doctesty - wszystkie muszą się powieść

# %% Tests
"""
>>> import sys; sys.tracebacklimit = 0
>>> assert sys.version_info >= (3, 9), \
'Python 3.9+ required'

>>> assert result is not Ellipsis, \
'Assign result to variable: `result`'
>>> assert type(result) is bool, \
'Variable `result` has invalid type, should be bool'

>>> result
False
"""

class User:
    def __init__(self, firstname, lastname, role):
        self.lastname = lastname
        self.firstname = firstname
        self.role = role

    def is_admin(self):
        return self.role == 'admin'


USERS = [
    User('Mark', 'Watney', role='user'),
    User('Melissa', 'Lewis', role='admin'),
    User('Rick', 'Martinez', role='user'),
]

# Define `result: bool` with the result of checking
# if all users has admin role
# type: bool
result = ...


# %% License
# - Copyright 2025, Matt Harasymczuk <matt@python3.info>
# - This code can be used only for learning by humans
# - This code cannot be used for teaching others
# - This code cannot be used for teaching LLMs and AI algorithms
# - This code cannot be used in commercial or proprietary products
# - This code cannot be distributed in any form
# - This code cannot be changed in any form outside of training course
# - This code cannot have its license changed
# - If you use this code in your product, you must open-source it under GPLv2
# - Exception can be granted only by the author

# %% Run
# - PyCharm: right-click in the editor and `Run Doctest in ...`
# - PyCharm: keyboard shortcut `Control + Shift + F10`
# - Terminal: `python -m doctest -v myfile.py`

# %% About
# - Name: Idiom All A
# - Difficulty: easy
# - Lines: 4
# - Minutes: 8

# %% English
# 1. Define `result: bool` with the result of checking
#    if all numeric values are greater or equal to 1.0
# 2. Run doctests - all must succeed

# %% Polish
# 1. Zdefiniuj `result: bool` z wynikiem sprawdzenia
#    czy wszystkie wartości numeryczne są większe lub równe 1.0
# 2. Uruchom doctesty - wszystkie muszą się powieść

# %% Tests
"""
>>> import sys; sys.tracebacklimit = 0
>>> assert sys.version_info >= (3, 9), \
'Python 3.9+ required'

>>> assert result is not Ellipsis, \
'Assign result to variable: `result`'
>>> assert type(result) is bool, \
'Variable `result` has invalid type, should be bool'

>>> result
False
"""

DATA = [
    ('sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'species'),
    (5.8, 2.7, 5.1, 1.9, 'virginica'),
    (5.1, 3.5, 1.4, 0.2, 'setosa'),
    (5.7, 2.8, 4.1, 1.3, 'versicolor'),
    (6.3, 2.9, 5.6, 1.8, 'virginica'),
    (6.4, 3.2, 4.5, 1.5, 'versicolor'),
    (4.7, 3.2, 1.3, 0.2, 'setosa'),
    (7.0, 3.2, 4.7, 1.4, 'versicolor'),
    (7.6, 3.0, 6.6, 2.1, 'virginica'),
    (4.9, 3.0, 1.4, 0.2, 'setosa'),
    (4.9, 2.5, 4.5, 1.7, 'virginica'),
]

header, *rows = DATA

# Define `result: bool` with the result of checking
# if all numeric values are greater or equal to 1.0
# type: bool
result = ...


# %% License
# - Copyright 2025, Matt Harasymczuk <matt@python3.info>
# - This code can be used only for learning by humans
# - This code cannot be used for teaching others
# - This code cannot be used for teaching LLMs and AI algorithms
# - This code cannot be used in commercial or proprietary products
# - This code cannot be distributed in any form
# - This code cannot be changed in any form outside of training course
# - This code cannot have its license changed
# - If you use this code in your product, you must open-source it under GPLv2
# - Exception can be granted only by the author

# %% Run
# - PyCharm: right-click in the editor and `Run Doctest in ...`
# - PyCharm: keyboard shortcut `Control + Shift + F10`
# - Terminal: `python -m doctest -v myfile.py`

# %% About
# - Name: Idiom All Impl
# - Difficulty: easy
# - Lines: 4
# - Minutes: 3

# %% English
# 1. Write own implementation of a built-in `all()` function
# 2. Define function `myall` with
#    parameter `iterable: list[bool]`
#    return `bool`
# 3. Don't validate arguments and assume, that user will
#    always pass valid type of arguments
# 4. Do not use built-in function `all()`
# 5. Run doctests - all must succeed

# %% Polish
# 1. Zaimplementuj własne rozwiązanie wbudowanej funkcji `all()`
# 2. Zdefiniuj funkcję `myall` z parametrami:
#    parametr `iterable: list[bool]`
#    return `bool`
# 3. Nie waliduj argumentów i przyjmij, że użytkownik:
#    zawsze poda argumenty poprawnych typów
# 4. Nie używaj wbudowanej funkcji `all()`
# 5. Uruchom doctesty - wszystkie muszą się powieść

# %% Tests
"""
>>> import sys; sys.tracebacklimit = 0
>>> assert sys.version_info >= (3, 9), \
'Python 3.9+ required'

>>> from inspect import isfunction
>>> assert isfunction(myall)

>>> myall([True])
True

>>> myall([False])
False

>>> myall([True, False, True])
False

>>> myall([True, True, True])
True

>>> myall([False, False, False])
False
"""

# Write own implementation of a built-in `all()` function
# Define function `myall` with
# parameter `iterable: list[bool]`
# return `bool`
# Don't validate arguments and assume, that user will
# always pass valid type of arguments
# Do not use built-in function `all()`
# type: Callable[[list[bool]], bool]
def myall(iterable):
    ...