{"id":59,"date":"2021-09-15T17:05:13","date_gmt":"2021-09-15T22:05:13","guid":{"rendered":"https:\/\/sites.owu.edu\/geog-199\/?p=59"},"modified":"2021-09-15T17:05:13","modified_gmt":"2021-09-15T22:05:13","slug":"frawley-chapter-4-notes","status":"publish","type":"post","link":"https:\/\/sites.owu.edu\/geog-293\/2021\/09\/15\/frawley-chapter-4-notes\/","title":{"rendered":"Frawley: Chapter 4 Notes"},"content":{"rendered":"<p><span style=\"font-weight: 400\">Chapter 4 Notes: This was an amazing review for me, essentially a complete introduction to python and its syntax and how to use it. This was genuinely the best python tutorial that I have read just because of how concise and to the point it was. I\u2019ve read about two different intermediate-level python books and they didn\u2019t compare to the examples and just the great layout the author put forth. Anyone could read through this chapter a few times and receive a pretty intermediate-level understanding of python. Genuinely you can mentally program in your head once learning the syntax. For me, this has helped me visualize projects easier and how I would accomplish them. I spent at least two hours reading this chapter several times to absorb the massive amount of information thrown at you.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">It helped me ponder on a semester project. I&#8217;m possibly thinking about attempting to automate a mapping sequence and run data extraction by teaching the program how to locate and measure each feature. On what, I am not exactly sure yet.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">What are the main data types in python? Which data types are sequences? Which data types are mutable, which are immutable?\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Strings, tuples, lists, dictionaries, boolean expressions, integers, float. Strings, tuples, and numbers are immutable. Lists and dictionaries are mutable, meaning they can be modified.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">Describe the difference between true division and floor division.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Floor division divides with no remainder, while true division divides into a whole number with a leftover remainder.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">Explain what the dynamic assignment of a variable means.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Dynamic assignment of variables occurs after you assign a value to it. Specifically, y = 6 is an integer, y =\u00a0 10.33 is a float, and y = \u201cMark\u201d is a string. The variable you assigned the value to becomes that exact data type you applied to it.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">Give examples of variable names and why they are good.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Counter, field5, my_file. Underscores are great for creating a unique variable name. All lowercase or including a number helps differentiate the variables from the rest of the code to avoid confusion.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">What\u2019s the difference between an expression and a statement in python, give examples.<\/span><\/p>\n<p><span style=\"font-weight: 400\">An expression is a value with no variable assignment. For example, 3 * 10 and the console will calculate it and return 30. A statement is a function that assigns a value to a variable. For example, x = 40 * 3. The x itself is not a value, it is just assigned one, and to display the result you need to incorporate the print() function to display the value. Print(x) and it would return 120.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">Explain the use of quotation marks in python<\/span><\/p>\n<p><span style=\"font-weight: 400\">Quotation marks assign a collection of characters as a string, which is designated to a variable.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">What are Unicode strings?\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Strings are essentially plain text, and Unicode allows that plain text to be converted into other languages, and with Unicode you can use different letters from other languages by using their designated ASCII code.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">Name five built in functions in python and provide an example of each one\u2019s use.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\"><strong>Print(x) :<\/strong> Prints a result from a function. Print (name) &#8211; Mark<\/span><\/p>\n<p><span style=\"font-weight: 400\"><strong>pow(x,y) :<\/strong> First number is multiplied by a \u2018power\u2019\u00a0 of the later value pow(2,3) &#8211; 8\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\"><strong>string (x)<\/strong> : Can convert an integer into a string to be able to display the integer in a normal line\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">of string characters. str(10) = \u201c10\u201d<\/span><\/p>\n<p><span style=\"font-weight: 400\"><strong>abs(x) :<\/strong> Returns absolute value of a number. abs(-8) &#8211; 8<\/span><\/p>\n<p><span style=\"font-weight: 400\">f<strong>loat(x) :<\/strong> converts a string or number into a float. float(\u201c8.0\u201d) &#8211; 10.0\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">What is dot notation?\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Shows that method belongs to the object. What comes after the dot belongs to what came before it.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">Describe the use of forward and reverse indexing sequences. Provide an example of slicing strings and lists.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Forward indexing is used to extract or display certain characters in a string, list, dictionary, or tuple, by a specific number correlated to the character. For example, indexing starts at 0, so indexing a string can retrieve a certain number or letter. Mystring = \u201cMark is the best\u201d\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Mystring[0] would return \u201cM\u201d. Slicing strings and lists can be used to take a chunk of letters or values from the string or list. This is done by using the index numbers and a colon to separate the first and last values you want to return from the string or list.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">Name three methods of string objects in python, provide an example of each one\u2019s use.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">.join(x) &#8211; Joins values in a list into one string.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Leela_list = [ \u2018she\u2019 , \u2018needs\u2019 , \u2018dog\u2019 , \u2018food\u2019]\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Leelastring = \u201c\u201d<\/span><\/p>\n<p><span style=\"font-weight: 400\">leela_list.join(leelastring) = \u2018she needs dog food\u2019\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">.split(x) &#8211; Can turn a string into a list by splitting each word into substrings<\/span><\/p>\n<p><span style=\"font-weight: 400\">bestdog = \u201cLeela is the best dog.\u201d<\/span><\/p>\n<p><span style=\"font-weight: 400\">Bestdog.split(\u201c \u201d)\u00a0 = [\u2018Leela\u2019 , \u2018is\u2019 , \u2018the\u2019 , \u2018best\u2019, \u2018dog\u2019]\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">.replace(x) &#8211; replace all occurrences of a specific substring with another substring<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">myhouse = \u201c609 logan\u201d<\/span><\/p>\n<p><span style=\"font-weight: 400\">myhouse.replace(\u201c609\u201d, \u201cToronto\u201d)<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">What are some key similarities between lists and tuples?\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">They can both hold multiple values, except tuples are immutable.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">Describe the use of boolean values to evaluate a condition.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Boolean values are true\/false values that can differentiate if a value is there or not, essentially a yes or no.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">X = 3\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">X == 8<\/span><\/p>\n<p><span style=\"font-weight: 400\">Returns false\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Describe the key steps to create a dictionary and add new items to the dictionary.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">The first step to creating a dictionary is to assign a variable name to it and set it equal to empty braces. For example,<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u00a0teams = {}<\/span><\/p>\n<p><span style=\"font-weight: 400\">To add to a dictionary, you include brackets to the variable with a pair of quotation marks inside and set it equal to the complete string.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">teams[\u201cCHI\u201d] = \u201cChicago Blackhawks\u201d\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">And to add to the dictionary you continue to use the same syntax.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">Why should backslashes be avoided when writing paths in python?\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Because a single backslash is used to denote a new line of text in strings.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">Describe how branching is implemented in python.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Branching is implemented with if statements, telling the compiler that it should take one path or another depending on the returned value.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">What is a compound statement in python?\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">A compound statement is a block of code expected to run together as a block, which is denoted by indentation.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">What are the two main looping structures in python? Describe each.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">While loops check for the value of a variable and require an exit statement.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">For loops repeat a block of code for each element in that sequence\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">What approaches can be used to split long lines of code into multiple lines and improve readability?\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Enter a backslash in a defined string within quotation marks.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Implied line continuation (), [], {}.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Hanging indentation\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">Why should you add comments to your scripts?\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">To help separate parts of the code into blocks<\/span><\/p>\n<p><span style=\"font-weight: 400\">Designate certain code with comments to know that this block is performing a particular function within the script. <\/span><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Chapter 4 Notes: This was an amazing review for me, essentially a complete introduction to python and its syntax and how to use it. This was genuinely the best python tutorial that I have read just because of how concise <span class=\"readmore\"><a href=\"https:\/\/sites.owu.edu\/geog-293\/2021\/09\/15\/frawley-chapter-4-notes\/\">Continue Reading<\/a><\/span><\/p>\n","protected":false},"author":1213,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-59","post","type-post","status-publish","format-standard","hentry","category-chapter-notes"],"_links":{"self":[{"href":"https:\/\/sites.owu.edu\/geog-293\/wp-json\/wp\/v2\/posts\/59","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sites.owu.edu\/geog-293\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sites.owu.edu\/geog-293\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sites.owu.edu\/geog-293\/wp-json\/wp\/v2\/users\/1213"}],"replies":[{"embeddable":true,"href":"https:\/\/sites.owu.edu\/geog-293\/wp-json\/wp\/v2\/comments?post=59"}],"version-history":[{"count":1,"href":"https:\/\/sites.owu.edu\/geog-293\/wp-json\/wp\/v2\/posts\/59\/revisions"}],"predecessor-version":[{"id":60,"href":"https:\/\/sites.owu.edu\/geog-293\/wp-json\/wp\/v2\/posts\/59\/revisions\/60"}],"wp:attachment":[{"href":"https:\/\/sites.owu.edu\/geog-293\/wp-json\/wp\/v2\/media?parent=59"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sites.owu.edu\/geog-293\/wp-json\/wp\/v2\/categories?post=59"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sites.owu.edu\/geog-293\/wp-json\/wp\/v2\/tags?post=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}