Musings in STEM Education
  • Home
  • Research Spring 2017
    • Research Paperwork and Resources
    • Reading
  • Foundations Spring 2017
    • Nested Loop Challenge
    • Random Challenges
    • String and List Challenges
    • Mock Create PT Challenges
  • Research Fall 16
  • Foundations 2016
  • Algebra II Spr 16
  • Research Spr 16
  • Found of Engineering and Tech
  • Differentiation Strategies
    • Artifacts
    • Class Standards
    • Reflections
  • Research Fall 2015
  • VTB ICM
  • FOET Student Blogs
    • Marcos P.
    • Vinny P.
    • Rebecca S.
    • Jerome S.
    • Andrew S.
    • Zach Y.
    • Daniel Z.
    • Shayan B.
    • Mariah B.
    • Eddie C.
    • Eli H.
    • Ben Ha.
    • Ben Ho.
    • Nick H.
    • Raymond J.
    • Andrew K.
    • Andrew M.
    • Sejal P.
    • Abhi P.
    • Adam P.
    • Erica R.
    • Avni S.
    • Ethan S.
    • Stephen S.
    • Alex T.
    • Hanna W.
  • STEM Workshop Research Notebook Blogs
    • Research Notebook User 1
    • Research Notebook User 2
    • Research Notebook User 3
    • Research Notebook User 4
    • Research Notebook User 5
    • Research Notebook User 6
    • Research Notebook User 7
    • Research Notebook User 8
    • Research Notebook User 9
    • Research Notebook User 10
    • Research Notebook User 11
    • Research Notebook User 12
    • Research Notebooks User 13
    • Research Notebook User 14
    • Research Notebook User 15
    • Research Notebook User 16
    • Research Notebook User 17
    • Research Notebook User 18
    • Research Notebook User 19
    • Research Notebook User 20
  • WHS Girls' Lax
  • FOET Spr15
  • Research Spr15
  • IDD Spr15
  • Research
  • Intro to Drafting and Design
  • Architectural Drawing and Design I
  • Student Blogs
    • Kevin
    • Forrest
    • Sarfarez
    • Thomas
    • Rachel
    • Parth
    • Dani
    • Derek
    • Virinchi
    • Anusha
    • Alex
    • Melam
    • Jeet
    • Pranav
    • Tarun
    • Jeffery
    • Assata
    • Justin
    • Kristin
    • Mary
    • Udo
    • Praveen
    • Carter
    • Clay
    • Adie
    • Christian
    • Luke
    • Colin
  • About
  • Untitled

Use this website as a resource.

​Do exercises 1-5, plus the one I assign you specifically, then choose any of the remaining exercises. 

1. What is the result of each of the following:
>>> "Python"[1] >>> "Strings are sequences of characters."[5] >>> len("wonderful") >>> "Mystery"[:4] >>> "p" in "Pineapple" >>> "apple" in "Pineapple" >>> "pear" not in "Pineapple" >>> "apple" > "pineapple" >>> "pineapple" < "Peach"
  1. Modify:
    1 2 3 4 5prefixes = "JKLMNOPQ" suffix = "ack" for letter in prefixes: print(letter + suffix) so that Ouack and Quack are spelled correctly.
  2. Encapsulate
    1 2 3 4 5 6fruit = "banana" count = 0 for char in fruit: if char == "a": count += 1 print(count) in a function named count_letters, and generalize it so that it accepts the string and the letter as arguments. Make the function return the number of characters, rather than print the answer. The caller should do the printing.
  3. Now rewrite the count_letters function so that instead of traversing the string, it repeatedly calls the find method, with the optional third parameter to locate new occurrences of the letter being counted.
  4. Assign to a variable in your program a triple-quoted string that contains your favourite paragraph of text — perhaps a poem, a speech, instructions to bake a cake, some inspirational verses, etc.
    Write a function which removes all punctuation from the string, breaks the string into a list of words, and counts the number of words in your text that contain the letter “e”. Your program should print an analysis of the text like this:
    Your text contains 243 words, of which 109 (44.8%) contain an "e".
  5. Print a neat looking multiplication table like this:
  6. Write a function that reverses its string argument, and satisfies these tests:
    1 2 3 4test(reverse("happy") == "yppah") test(reverse("Python") == "nohtyP") test(reverse("") == "") test(reverse("a") == "a")
  7. Write a function that mirrors its argument:
    1 2 3 4test(mirror("good") == "gooddoog") test(mirror("Python") == "PythonnohtyP") test(mirror("") == "") test(mirror("a") == "aa")
  8. Write a function that removes all occurrences of a given letter from a string:
    1 2 3 4 5 6test(remove_letter("a", "apple") == "pple") test(remove_letter("a", "banana") == "bnn") test(remove_letter("z", "banana") == "banana") test(remove_letter("i", "Mississippi") == "Msssspp") test(remove_letter("b", "") = "") test(remove_letter("b", "c") = "c")
  9. Write a function that recognizes palindromes. (Hint: use your reverse function to make this easy!):
    1 2 3 4 5 6 7test(is_palindrome("abba")) test(not is_palindrome("abab")) test(is_palindrome("tenet")) test(not is_palindrome("banana")) test(is_palindrome("straw warts")) test(is_palindrome("a")) # test(is_palindrome("")) # Is an empty string a palindrome?
  10. Write a function that counts how many times a substring occurs in a string:
    1 2 3 4 5 6test(count("is", "Mississippi") == 2) test(count("an", "banana") == 2) test(count("ana", "banana") == 2) test(count("nana", "banana") == 1) test(count("nanan", "banana") == 0) test(count("aaa", "aaaaaa") == 4)
  11. Write a function that removes the first occurrence of a string from another string:
    1 2 3 4test(remove("an", "banana") == "bana") test(remove("cyc", "bicycle") == "bile") test(remove("iss", "Mississippi") == "Missippi") test(remove("eggs", "bicycle") == "bicycle")
  12. Write a function that removes all occurrences of a string from another string:
    1 2 3 4test(remove_all("an", "banana") == "ba") test(remove_all("cyc", "bicycle") == "bile") test(remove_all("iss", "Mississippi") == "Mippi") test(remove_all("eggs", "bicycle") == "bicycle")
Proudly powered by Weebly