<jupyter_start><jupyter_text>Getting Started Welcome to Google Colab. This is a species of iPython notebook that runs on a free Google server. We'll be using these for assignments and exercises.<jupyter_code>"hello"
print("hello")<jupyter_output>hello<jupyter_text>Variables and FunctionsThe most fundamental things in python are **variables** and **functions**. Both of these are things that you refer to by name, and both them are things that you can create--although we'll wait just a little before writing our own functions.Create a variable using an equals sign and something on the left.<jupyter_code>my_name = "Ben"<jupyter_output><empty_output><jupyter_text>Variables can be combined together. For both letters and numbers, we can do this with the "+" sign.<jupyter_code>1 + 1
"Hello " + my_name<jupyter_output><empty_output><jupyter_text>A **variable** is essentially a *noun*; something that exists. A function is a verb; an action that takes place on a variable. "+" is *sort of* of a function (it adds two things together.) But the typical syntax for **functions** is that they occur between two parentheses. You can chain things together inside of these parentheses like above.<jupyter_code>print("Hello " + my_name)<jupyter_output>Hello Ben<jupyter_text>OK--your first task is--change the *notebook* so it says your "Hello Mrs. Miniver" (or whatever your name is), while still using the variable "my_name" above.   Letters We'll start out with one of the simplest elements: the letter A.We've already seen that there are both words (called "strings") and numbers in python. Every letter is represented as a number under the hood; if you want to see what letter is produced by a given number, you can use a function called 'chr'.<jupyter_code>"A"
chr(65)<jupyter_output><empty_output><jupyter_text>Problem 1.Using trial and error, find the character code for the letter "0". (Yes, I said "letter zero.") Really what I mean is the *glyph* zero. I've given you a bunch of cells below. HotkeysWhile doing this, start learning some hotkeys in jupyter:Hit control (or command) M then press B to add a new cell; and hit shift-enteror control-enter to run a cell. (control advances the focus to the next cell; shift keeps it where it is.)<jupyter_code><jupyter_output><empty_output><jupyter_text><jupyter_code><jupyter_output><empty_output><jupyter_text>There's a faster way to do this, for the record; the function `ord` tells you the character code directly.<jupyter_code>ord("A")
chr(918)<jupyter_output><empty_output><jupyter_text>Find some other numbers that produce some interesting characters. I put in my birthday, and got an interesting one--this is **not** a Z. What else can you find? How big do the numbers go?<jupyter_code><jupyter_output><empty_output><jupyter_text>Some numbers get *very* high, and sometimes two different code points make one letter. See if you can explain what's going on without using language, **only variable names**.The point below seems to be two different characters. Fiddle around a little bit with both the left and right-hand numbers to figure out what's going on.<jupyter_code>chr(129499) + chr(127996)<jupyter_output><empty_output><jupyter_text>Things can get weird, and that's OK.<jupyter_code><jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07936507936507936, 'fraction_numerical': 0.00641025641025641, 'mean_word_length': 5.784679089026915, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '430256', 'license': 'MIT', 'n_tokens_mistral': 955, 'n_tokens_neox': 919, 'n_words': 428, 'path': 'Week_01_Working_in_Colab.ipynb', 'repo_name': 'HumanitiesDataAnalysis/intro-programming', 'size': '3276'}