In [ ]:
"Hello World" # Put your cursor in this text-box and hit "Shift+Enter" on your keyboard.
In [ ]:
print("Hello World") # Okay, now do that again. See how with print(), Jupyter doesn't add quotes.
In [ ]:
print('Hello World') # You can also use single-quotes around strings.
In [ ]:
print("Mike's Hello World") # Use whichever quotes you need when you need them.
In [ ]:
print("b\nl\na\nh\ttab1\ttab2\ttab3") # There are some special characters in Python like \n for line return.
In [ ]:
print(r"b\nl\na\nh\ttab1\ttab2\ttab3") # You can neutralize special characters with the "raw" directive on a string.
In [ ]:
arbitrary_string = "Mike's Hello World" # "Variable" names are arbirtary but have certain limitations (must start with letter)
print(arbitrary_string)
In [ ]:
for letter in arbitrary_string: # Python can treat a string as a series of individual characters.
print(letter)
In [ ]:
for letter in arbitrary_string:
print(letter, end=" ") # Commands like print often have additonal controls as you see here.
In [ ]:
arbitrary_string[1:17] # Python has a concept of "slicing" which works really well on lists.
In [ ]:
arbitrary_string[:17] # You can leave out the number at the beginning to stand for 0.
In [ ]:
arbitrary_string[1:] # You can leave out the number at the end to stand for the end-length of the sequence.
In [ ]:
arbitrary_string[:-6] # You can use negative indexes to go back from the end.
In [ ]:
copy_of_string = arbitrary_string[:] # You can use this as an alternative to string.copy() (avoiding getting original object)
copy_of_string
In [ ]:
help(print) # You can type help() around any function name to see its built-in documentation.
In [ ]:
import this