diff --git a/chap8.py b/chap8.py index e9a1476..4d9d27c 100644 --- a/chap8.py +++ b/chap8.py @@ -1,2 +1,75 @@ # This is where the answers to Chapter 8 questions for the BSS Dev RampUp go -# Name: \ No newline at end of file +# Name: Jackie Gushue + +# Question 8.12 ROT13 (weak form of encryption) +# After writing code and checking answer, realized +# need to take into account upper vs. lower case letters + +def char_to_num(word, index): + num_list = [] + for char in word: + num_list.append(ord(char)+index) + return num_list + +def num_to_char(num_list): + word = "" + for num in num_list: + word = word + chr(num) + return word + +def rotate_word(word, index): + return num_to_char(char_to_num(word, index)) + +print rotate_word("cheer", 7) + +# Correct answer + +def rotate_letter(letter, n): + """Rotates a letter by n places. Does not change other chars. + + letter: single-letter string + n: int + + Returns: single-letter string + """ + if letter.isupper(): + start = ord('A') + print "Start: " + str(start) + elif letter.islower(): + start = ord('a') + print "Start: " + str(start) + else: + return letter + + c = ord(letter) - start + i = (c + n) % 26 + start + return chr(i) + + +def rotate_word(word, n): + """Rotates a word by n places. + + word: string + n: integer + + Returns: string + """ + res = '' + for letter in word: + res += rotate_letter(letter, n) + return res + + +if __name__ == '__main__': + print rotate_word('cheer', 7) + print rotate_word('melon', -10) + print rotate_word('sleep', 9) + + + + + + + + + diff --git a/chap9.py b/chap9.py index 2e9171d..487699d 100644 --- a/chap9.py +++ b/chap9.py @@ -1,2 +1,48 @@ # This is where the answers to Chapter 9 questions for the BSS Dev RampUp go -# Name: \ No newline at end of file +# Name: Jackie Gushue + +import string + +def has_no_e(word): + e_count = string.count(word, 'e') + if e_count == 0: + return True + else: + return False + +def avoids(word, forbidden): + for letter in word: + if letter in forbidden: + return False + return True + +def uses_only(word, contains): + for letter in word: + if letter not in contains: + return False + return True + +infile = open('words.txt', 'rU') + +count_words = 0 +count_e = 0 +count_forbid = 0 +forbidden = raw_input("Enter string of forbidden letters: ") + +for line in infile: + count_words += 1 + word = line.strip() + if has_no_e(word): + count_e += 1 + if avoids(word, forbidden): + count_forbid += 1 + +print "No \'e\' words percentage = " + str((float(count_e) / count_words)*100) + "." +print str(count_forbid) + " words do NOT contain any forbidden letters." + + + + + + + diff --git a/fourth_app_example/.DS_Store b/fourth_app_example/.DS_Store index a59bc20..0023536 100644 Binary files a/fourth_app_example/.DS_Store and b/fourth_app_example/.DS_Store differ diff --git a/fourth_app_example/login.py b/fourth_app_example/login.py index a8cb73d..ac8e5be 100644 --- a/fourth_app_example/login.py +++ b/fourth_app_example/login.py @@ -1,6 +1,6 @@ import flask, flask.views -users = {'juliana':'bacon'} +users = {'jgush':'octothorpe'} class Login(flask.views.MethodView): def get(self): diff --git a/fourth_app_example/login.pyc b/fourth_app_example/login.pyc index 45b4d90..fc1f899 100644 Binary files a/fourth_app_example/login.pyc and b/fourth_app_example/login.pyc differ diff --git a/fourth_app_example/main.pyc b/fourth_app_example/main.pyc index de2fa65..f03f917 100644 Binary files a/fourth_app_example/main.pyc and b/fourth_app_example/main.pyc differ diff --git a/fourth_app_example/music.pyc b/fourth_app_example/music.pyc index 05fb524..620cee0 100644 Binary files a/fourth_app_example/music.pyc and b/fourth_app_example/music.pyc differ diff --git a/fourth_app_example/remote.pyc b/fourth_app_example/remote.pyc index dc58e22..7009ac3 100644 Binary files a/fourth_app_example/remote.pyc and b/fourth_app_example/remote.pyc differ diff --git a/fourth_app_example/settings.py b/fourth_app_example/settings.py index 798020f..7060411 100644 --- a/fourth_app_example/settings.py +++ b/fourth_app_example/settings.py @@ -1 +1 @@ -secret_key = "bacon" \ No newline at end of file +secret_key = "secret!!!!!" \ No newline at end of file diff --git a/fourth_app_example/settings.pyc b/fourth_app_example/settings.pyc index ca4c2e7..3489e36 100644 Binary files a/fourth_app_example/settings.pyc and b/fourth_app_example/settings.pyc differ diff --git a/fourth_app_example/static/.DS_Store b/fourth_app_example/static/.DS_Store index b70c022..65b911f 100644 Binary files a/fourth_app_example/static/.DS_Store and b/fourth_app_example/static/.DS_Store differ diff --git a/fourth_app_example/static/bootstrap/.DS_Store b/fourth_app_example/static/bootstrap/.DS_Store new file mode 100644 index 0000000..a71f73c Binary files /dev/null and b/fourth_app_example/static/bootstrap/.DS_Store differ diff --git a/fourth_app_example/static/music/.DS_Store b/fourth_app_example/static/music/.DS_Store new file mode 100644 index 0000000..2b56426 Binary files /dev/null and b/fourth_app_example/static/music/.DS_Store differ diff --git a/fourth_app_example/static/sloths.png b/fourth_app_example/static/sloths.png new file mode 100644 index 0000000..959b299 Binary files /dev/null and b/fourth_app_example/static/sloths.png differ diff --git a/fourth_app_example/templates/.DS_Store b/fourth_app_example/templates/.DS_Store index 5dbfea8..5d625cf 100644 Binary files a/fourth_app_example/templates/.DS_Store and b/fourth_app_example/templates/.DS_Store differ diff --git a/fourth_app_example/templates/about.html b/fourth_app_example/templates/about.html index 3d8b841..5674802 100644 --- a/fourth_app_example/templates/about.html +++ b/fourth_app_example/templates/about.html @@ -1,5 +1,5 @@ {% extends "base.html" %} {% block body %}

About!

-

My name is [Your Name] and I love webdev.

+

My name is Jackie and I love webdev.

{% endblock %} \ No newline at end of file diff --git a/fourth_app_example/templates/base.html b/fourth_app_example/templates/base.html index 2122832..9eb1945 100644 --- a/fourth_app_example/templates/base.html +++ b/fourth_app_example/templates/base.html @@ -1,12 +1,11 @@ - Week 3 Lab - + Jay Gee + -
{% block body %}{% endblock %}
@@ -34,7 +33,7 @@ {% endfor %} {% endwith %} - + \ No newline at end of file diff --git a/fourth_app_example/templates/index.html b/fourth_app_example/templates/index.html index f1d95f8..6a35325 100644 --- a/fourth_app_example/templates/index.html +++ b/fourth_app_example/templates/index.html @@ -1,7 +1,11 @@ {% extends "base.html" %} {% block body %} -

Welcome!

-

This is [Your Name]'s web page.

-

Just try clicking on things to the left, you have to log in though. - Do you think you have access?

+

Sloths

+

Sloths would be the world's deadliest creatures... if the world + slowed the f@#! down.

+

For more facts about sloths, check out this video:

+ TRUE FACTS ABOUT SLOTHS +
+
+ {% endblock %} \ No newline at end of file diff --git a/fourth_app_example/utils.pyc b/fourth_app_example/utils.pyc index 69affc4..3430193 100644 Binary files a/fourth_app_example/utils.pyc and b/fourth_app_example/utils.pyc differ diff --git a/screenshots/Screen Shot 2013-02-13 at 10.15.15 PM.png b/screenshots/Screen Shot 2013-02-13 at 10.15.15 PM.png new file mode 100644 index 0000000..63510cb Binary files /dev/null and b/screenshots/Screen Shot 2013-02-13 at 10.15.15 PM.png differ