Skip to content

Instantly share code, notes, and snippets.

@Offirmo
Last active February 28, 2024 02:31
Show Gist options
  • Save Offirmo/6757d27328d76567deb37ae745283974 to your computer and use it in GitHub Desktop.
Save Offirmo/6757d27328d76567deb37ae745283974 to your computer and use it in GitHub Desktop.
[Python basics] #python
## https://developers.google.com/edu/python
# ternary
a if x else b
## strings
## https://developers.google.com/edu/python/strings
s = 'hi'
print(s[1]) ## i
print(len(s)) ## 2
print(s + ' there') ## hi there
f"He said his name is {name}." ## https://docs.python.org/3/reference/lexical_analysis.html#f-strings
"The sum of 1 + 2 is {0}".format(1+2) ## https://docs.python.org/3/library/string.html#formatstrings
'{name} was born in {country}'.format_map(Default(name='Guido'))
# exec
import sys
def main():
print(sys.argv)
# This is the standard boilerplate that calls the main() function.
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment