This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello: str = 'Hello World!' | |
assert hello[6:] == 'World!' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello: str = 'Hello World!' | |
assert hello[:5] == 'Hello' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello: str = 'Hello World!' | |
assert hello[-6:-1] == 'World' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello: str = 'Hello World!' | |
assert hello[10:5:-1] == 'dlroW' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello: str = 'Hello World!' | |
assert hello[-2:5:-1] == 'dlroW' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello: str = 'Hello World!' | |
sl: slice = slice(-2, 5, -1) | |
assert hello[sl] == 'dlroW' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello: str = 'Hello World!' | |
sl: slice = slice(-2, 5, -1) | |
print(sl.start) | |
print(sl.stop) | |
print(sl.step) | |
print(hello[sl]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello: str = 'Hello World!' | |
sl: slice = slice(-2, 5, -1) | |
print(f'Start: {sl.start}') | |
print(f'Stop: {sl.stop}') | |
print(f'Start: {sl.start}') | |
print(f'Step: {sl.step}') | |
print(f'Slice: {sl}') | |
print(hello[sl]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello: str = 'Hello World!' | |
sl: slice = slice(-2, 5, -1) | |
print(f'Start: {sl.start}') | |
print(f'Stop: {sl.stop}') | |
print(f'Step: {sl.step}') | |
print(f'Slice: {sl}') | |
print(hello[sl]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fibonacci_iterative(target: int) -> int: | |
""" | |
This version uses iteration to start at the beginning of the sequence and work up to the target value. | |
It is in this way similar to fibonacci_bottomup | |
Luckily, the iterative version doesn't have the memory space issues, there are no deeply nested call chains here. | |
Unfortunately this method is slow, very slow. | |
>>> fibonacci_iterative(80) | |
23416728348467685 |