diff options
-rwxr-xr-x | datatypes.py | 6 | ||||
-rw-r--r-- | lambda.py | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/datatypes.py b/datatypes.py index 8072582..5df78f3 100755 --- a/datatypes.py +++ b/datatypes.py @@ -31,3 +31,9 @@ print(x) mysum = sum([i for i in range(1, 10) if i%2==0]) squares = [x**2 for x in range(10)] squares = list(map(lambda x: x**2, range(10))) + + +# in addition to [] index operator on lists, there's slice operator: [start:stop:step] +aList = [1, 4, 9, 16, 25] +slicedList = aList[::-1] +print(f"reverse of: {aList} is: {slicedList}") diff --git a/lambda.py b/lambda.py new file mode 100644 index 0000000..7994376 --- /dev/null +++ b/lambda.py @@ -0,0 +1,3 @@ +fib = lambda n: n if n<=1 else fib(n-1)+fib(n-2) + +for i in range(10):print(fib(i))
\ No newline at end of file |