Python is the language I'm focusing on next. # About Python is an interpreted language. It's general purpose, mega popular, and used in all sorts of ways. Most data folks use Python. # Standard Library https://docs.python.org/3/library/index.html --- Here are some bits and bobs about it as I'm learning. - [[F-Strings]]. # Strings ## Basics ```python a = "basic" b = "concatenation" c = a + " " + b # various string methods A = a.upper() # does not mutate print(A) # returns "BASIC" print(a) # returns "basic" joined = " ".join([a,b]) # so weird to me still ``` # Lists, Tuples, & Sets ```python my_list = ["hello", 3] my_tuple = ("I","Cannot","Change") my_set = {"Duplicate values removed", "Duplicate values removed", "Duplicate values removed"} #only retains the first one ``` ## Join Join is weird & backwards from JavaScript's `join()` method. You supply the string you want to use as the separator then call `join` from it, passing in the list to join together. ```python my_list = ["Jimmy", "cracked", "corn"] separator = " " separator.join(my_list) # correct python syntax ``` Very backwards from [[JavaScript]]'s ```javascript myList = ["Jimmy", "cracked", "corn"]; separator = " "; myList.join(separator); // correct JavaScript syntax ``` ## List Comprehension A neat little way to basically run a forEach()-style loop: ```python # Using List Comprehension to make a lowercase copy of a list of strings original_list = ["LIST","COMPREHENSIONS","ARE","COOOOOL"] lowercased_list = [name.lower() for name in original_list] print(', '.join(lowercased_list)) # reflects lowercase print(', '.join(original_list)) # unmodified ``` **** ## Source - doing stuff with it ## Related - [[Jupyter Notebook]] - [[JavaScript]]