Last active
August 29, 2015 14:22
-
-
Save aaronlelevier/409f624c73de167fe3bf to your computer and use it in GitHub Desktop.
Notes for Saturday May 30th
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
| ''' String Methods ''' | |
| s = 'Jack the Crazy Giant' | |
| # methods | |
| s.upper() | |
| s.lower() | |
| # will return false because Python is case sensitive | |
| s.startswith('j') | |
| # indexing | |
| s[0] | |
| s[2:] | |
| s[3:7] | |
| s[-1] | |
| s[-2:] | |
| # can concatenate, but must be the same type | |
| s + ' yo you' | |
| # raises an error because different types | |
| s + 1 | |
| # cast as a string (str) | |
| s + str(1) | |
| # strings have integer values, and vice versa | |
| int_a = ord('a') | |
| chr_100 = chr(100) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment