Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 74 additions & 1 deletion chap8.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,75 @@
# This is where the answers to Chapter 8 questions for the BSS Dev RampUp go
# Name:
# 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)









48 changes: 47 additions & 1 deletion chap9.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,48 @@
# This is where the answers to Chapter 9 questions for the BSS Dev RampUp go
# Name:
# 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."







Binary file modified fourth_app_example/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion fourth_app_example/login.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import flask, flask.views

users = {'juliana':'bacon'}
users = {'jgush':'octothorpe'}

class Login(flask.views.MethodView):
def get(self):
Expand Down
Binary file modified fourth_app_example/login.pyc
Binary file not shown.
Binary file modified fourth_app_example/main.pyc
Binary file not shown.
Binary file modified fourth_app_example/music.pyc
Binary file not shown.
Binary file modified fourth_app_example/remote.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion fourth_app_example/settings.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
secret_key = "bacon"
secret_key = "secret!!!!!"
Binary file modified fourth_app_example/settings.pyc
Binary file not shown.
Binary file modified fourth_app_example/static/.DS_Store
Binary file not shown.
Binary file added fourth_app_example/static/bootstrap/.DS_Store
Binary file not shown.
Binary file added fourth_app_example/static/music/.DS_Store
Binary file not shown.
Binary file added fourth_app_example/static/sloths.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified fourth_app_example/templates/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion fourth_app_example/templates/about.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "base.html" %}
{% block body %}
<h1>About!</h1>
<p>My name is [Your Name] and I love webdev.</p>
<p>My name is Jackie and I love webdev.</p>
{% endblock %}
7 changes: 3 additions & 4 deletions fourth_app_example/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>Week 3 Lab</title>
<link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
<title>Jay Gee</title>
<link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link rel="stylesheet" type="text/css" href="/static/style.css" />
<script type="text/javascript" src="/static/jquery-1.7.1.min.js"></script>
</head>
<body>
<div id="content">
{% block body %}{% endblock %}
</div>
Expand Down Expand Up @@ -34,7 +33,7 @@
{% endfor %}
{% endwith %}
</div>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
12 changes: 8 additions & 4 deletions fourth_app_example/templates/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{% extends "base.html" %}
{% block body %}
<h1>Welcome!</h1>
<p>This is [Your Name]'s web page. </p>
<p>Just try clicking on things to the left, you have to log in though.
Do you think you have access?</p>
<h1>Sloths</h1>
<p> Sloths would be the world's deadliest creatures... if the world
slowed the f@#! down. </p>
<p> For more facts about sloths, check out this video: <p>
<a href = "http://www.youtube.com/watch?v=XrUM8m2rnP0"> TRUE FACTS ABOUT SLOTHS </a>
<br>
<br>
<img src="/static/sloths.png">
{% endblock %}
Binary file modified fourth_app_example/utils.pyc
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.