{"assignment":{"_schema_version":2,"course_id":37,"date_created":"2022-06-28T19:00:00+00:00","date_modified":"2023-08-26T14:04:12.876507+00:00","extra_instructor_files":"","extra_starting_files":"","forked_id":null,"forked_version":null,"hidden":false,"id":946,"instructions":"## Purpose\n\n```python example-strings\nname = \"Ada Bart\"\nword = \"rubber\"\nbook = \"Dante's Inferno\"\nwebsite = \"https://wikipedia.org\"\n```\n\nStrings are how we put text data into a computer.\nAny text data can be a string: names, words, books, web sites.\n\n## Characters\n\n- **Letters:** The alphabet, `a` through `z` and `A` through `Z` (lowercase and uppercase)\n- **Numbers:** The digits `0` to `9`\n- **Symbols:** All other characters like `!` and `:` and even the space character\n\nStrings are made up of letters, numbers, and symbols.\nWe call these things \"characters.\"\n\n## The name \"String\"\n\n![A picture of a necklace of beads with characters written on the beads, spelling out \"Hello World\"](intro_strings_beads.png)\n\nThink of a string like a necklace, where each bead has a character on it.\nWe \"string together\" letters.\nThe single or double quotes are knots at the end that tie the letters off.\n\n## Notation\n\n```python string-notation\nmessage1 = \"What's wrong with me?\"\nmessage2 = 'He said, \"What did you do?\"'\n\nprint(message1)\nprint(message2)\n```\n\nStrings are represented with quotes.\nYou can use either double quotation marks or single quotation marks.\nHowever, if you start a string with double quotes, then you must end it with double quotes.\nIf you start with single quotes, then you must end with single quotes.\nThe reason there are two kinds of quotes is to make it easier to create strings like the ones shown.\nIn the first string, we can have single quotes (or apostrophes) because we wrapped the string in double quotes.\nIn the second string, we can have double quotes because we wrapped the string in single quotes.\n\n## Escape Characters\n\n```python escape-characters\nprint(\"He said, \\\"What's wrong with me?\\\" to the girl.\")\n\nprint(\"This will\\nbe on two lines.\")\n\nprint(\"\\tThis will\\thave some\\tgaps.\")\n```\n\nSo how do you have a string with both single and double quotes in it? You can use escape characters.\nBy putting a backslash `\\` before a character, you create a special \"escape character.\" In the following code, we have a slash before the double quotes so that they are _escaped_ safely.\nThere are actually many kinds of escape characters.\nA slash before a lowercase `n` makes a new line in the string when it is printed (`\\n`), like when you press enter.\nA slash before a lowercase `t` makes the string indented when the string is printed (`\\t`), like when you press tab.\n\n## Numbers and Strings\n\n```python numbers-and-strings\n# Predict what will be printed when this code runs!\nprint(1 + 2)\nprint(\"1\" + \"2\")\n```\n\nIt's a little confusing, but you can put a number in quotes.\nHowever, this means that you have a string and not an integer.\nThe difference becomes very obvious when you try to add things together.\n`\"1\" + \"2\"` is `\"12\"`, instead of `3`.\nPython is very strict about the differences between numbers and strings when it comes to operations.\n\n## Variables and Strings\n\n```python string-vs-variable\nmy_string_variable = \"A string value\"\n\nprint(my_string_variable)\n```\n\nSome people confuse variables and strings, but they are very different.\nStrings have quotes around them, and variables do not.\nStrings _are_ values, while variables _hold_ values.\nYou can update a variable with a new value, but you cannot assign to a string.\nThat is a syntax error.\nTry swapping the order of the value and the variable in this code and you will see for yourself that it cannot work!\n\n## Triple Quoted Strings\n\n```python triple-quoted-string\nmy_variable = \"\"\"This is a long multi-line \ntext block. Notice how it can spill onto \nmultiple lines. It has been assigned to a new \nvariable called my_variable. You can use 'single'\nand \"double\" quotes inside.\"\"\"\n\nprint(my_variable)\n```\n\nOnce in a while, you need a large amount of text in your program.\nThe best way to do so is to use \"triple quoted strings.\" The syntax is simple: You start and end the chunk of text with three quote marks.\nIt doesn't matter if they are single or double quotes so long as they start and end with the same type.\n\n## The Empty String\n\n```python\nthe_empty_string = \"\"\nprint(\"-->\"+the_empty_string+\"<--\")\n\nthe_space_character = \" \"\nprint(\"-->\"+the_space_character+\"<--\")\n```\n\nThe empty string (`\"\"`) is one of the most important strings, since it is the simplest and shortest string possible.\nThe empty string is what you get when you delete all the characters between the two quotation marks.\nIt is similar to the concept of zero, but for strings.\nCritically, the empty string is NOT the same thing as the string containing a whitespace character (`\" \"`).\nThe space character takes up space, as its name suggests.\nPressing the space key on your keyboard adds a bit of blank space, but it still has space.\nThe empty string is zero characters, while the space character is a single character, just like the underscore (`\"_\"`) or the letter `\"j\"`.\nIn the example code shown here, we show what happens when you print out the empty string vs if you print out the space character.\nOne has no space, while the other does.\nDo not treat the space character as if it were the empty string.\n\n## Summary\n\n- Strings are composed of characters, which can be letters, digits, or symbols, surrounded by either a pair of single quotes or a pair of double quotes.\n- Strings can also begin or end with three quote marks of the same type to make triple-quoted strings that span multiple lines of text.\n- Escape characters are special characters made with a back slash (`\\\\`) and a second character, which can be used to represent things like tabs and new lines.\n- Text with digits are still strings and not integers; the two types of values can be differentiated by the presence of quotation marks.\n- The empty string is not the same thing as the string containing a single space character. One has zero characters, the other has one invisible character.","ip_ranges":"","name":"1B6) Strings Reading","on_change":"","on_eval":"","on_run":"","owner_id":1,"owner_id__email":"acbart@udel.edu","points":0,"public":true,"reviewed":false,"sample_submissions":[],"settings":"{\n  \"header\": \"Strings\",\n  \"slides\": \"bakery_intro_strings.pdf\",\n  \"youtube\": {\n    \"Bart\": \"G2SNTDwewtc\",\n    \"Amy\": \"iph00g8cJtE\"\n  },\n  \"video\": {\n    \"Bart\": \"https://blockpy.cis.udel.edu/videos/bakery_intro_strings-Bart.mp4\",\n    \"Amy\": \"https://blockpy.cis.udel.edu/videos/bakery_intro_strings-Amy.mp4\"\n  },\n  \"summary\": \"This class gives a more formal introduction to Strings. Although we covered Strings briefly back when we learned about types, now we're studying them in more depth.\",\n  \"small_layout\": true\n}","starting_code":"","subordinate":true,"tags":[],"type":"reading","url":"bakery_intro_strings_read","version":7},"ip":"216.73.216.157","submission":{"_schema_version":3,"assignment_id":946,"assignment_version":7,"attempts":0,"code":"","correct":false,"course_id":37,"date_created":"2026-05-20T12:42:00.567821+00:00","date_due":"","date_graded":"","date_locked":"","date_modified":"2026-05-20T12:42:00.567821+00:00","date_started":"","date_submitted":"","endpoint":"","extra_files":"","feedback":"","grading_status":"NotReady","id":2036759,"score":0.0,"submission_status":"Started","time_limit":"","url":"submission_url-432efe60-f22b-4db2-92ca-dfb22c4008b9","user_id":2044660,"user_id__email":"","version":0},"success":true}
