Last active
February 27, 2024 23:51
-
-
Save Offirmo/a43ec13bedc4c3186b97b062da6ae2b1 to your computer and use it in GitHub Desktop.
[Python snippets for hacker rank] python
This file contains 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
## starters | |
x = [ 1, 2, 3, 4, 5 , 6, 7 ] | |
print(f'{x} => {xyz(x)}')' | |
x = [ 1, 2, 3, 4, 5 , 6, 7 ] | |
print(f'{x} => {xyz(x, len(x))}') | |
x, y = 'foo', 2 | |
print(f'{x},{y} => {xxxxx(x, y)}') | |
## debug | |
print(repr(arr)) | |
print(f'{x} => {xyz(x)}') | |
## string manipulation | |
arr = list(map(int, '1 2 3 4 5'.strip().split())) | |
## lists | |
arr.sort() | |
create an empty list of size n: result = [0] * 100 | |
unpacking * | |
## arr | |
x = [ | |
[ 1, 2, 3], | |
[ 4, 5, 6], | |
[ 9, 8, 9], | |
] | |
## set | |
unpacking ** | |
## binary manipulation | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment