1
0
forked from tdwojak/Python2017
Python2017/labs04/task01.py

19 lines
627 B
Python
Raw Permalink Normal View History

2017-12-03 13:05:05 +01:00
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
2017-12-16 02:44:01 +01:00
def is_numeric(xs):
return all(isinstance(x, (int, float)) for x in xs)
2017-12-03 13:05:05 +01:00
2017-12-16 02:44:01 +01:00
assert is_numeric([1,2,3,4,5,6,6])
assert is_numeric([1.0,2.0,3.0,4.0,5.0,6.0])
assert is_numeric([1])
assert is_numeric([1.0])
assert is_numeric([1.0, 1])
assert is_numeric([1, 1.0])
assert is_numeric([]) #zgodnie z ustaleniami z zajęć
assert not is_numeric([1,2,3,'a',4,5,6,6])
assert not is_numeric([1.0,2.0,3.0,'a',4.0,5.0,6.0])
assert not is_numeric([1, 'a'])
assert not is_numeric([1.0, 'a'])
assert not is_numeric(['a', 1.0, 1])
assert not is_numeric([1, 1.0, 'a'])
assert not is_numeric(['a'])