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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 21 additions & 1 deletion chap8.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
# This is where the answers to Chapter 8 questions for the BSS Dev RampUp go
# Name:
# Name: Chris Van Schyndel

# Exercise 8.12

def rot_x(astring, rotator):
alpha_upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alpha_lower = 'abcdefghijklmnopqrstuvwxyz'
newstring = ''
for letter in astring:
if letter in alpha_upper:
newletter = alpha_upper[(alpha_upper.find(letter) + rotator) % 26]
newstring += newletter
if letter in alpha_lower:
newletter = alpha_lower[(alpha_lower.find(letter) + rotator) % 26]
newstring += newletter
return newstring

print rot_x('cheer', 7)
print rot_x('melon', -10)


86 changes: 85 additions & 1 deletion chap9.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,86 @@
# This is where the answers to Chapter 9 questions for the BSS Dev RampUp go
# Name:
# Name: Chris Van Schyndel

# Exercise 9.1

def greaterthantwenty():
fin = open('words.txt')
for line in fin:
word = line.strip()
if len(word) > 20:
print word

# Exercise 9.2

def has_no_e(string):
for letters in string:
if letters == 'e' or letters == 'E':
return False
return True


def words_with_e():
fin = open('words.txt')
words_with_e = 0
words_without_e = 0
wordcheck = False
for line in fin:
word = line.strip()
for letters in word:
if letters == 'e':
wordcheck = True
if wordcheck == True:
words_with_e += 1
wordcheck = False
else:
print word
words_without_e += 1
return str(((words_without_e * 100) / words_with_e * 100)/100) + '%'

# Exercise 9.3

def avoids():
print 'Please enter in the Forbidden letters!'
astring = raw_input('Forbidden Letters: >')
wordcheck = False
wordcount = 0
fin = open('words.txt')
for line in fin:
word = line.strip()
for letters in word:
for forbiddens in astring:
if letters == forbiddens:
wordcheck = True
if wordcheck == True:
wordcheck = False
else:
wordcount +=1
print word
print wordcount

# Can you find a combination of 5 forbidden letters that excludes the smallest number of words?
# My guess? 'zyqkj'


# Exercise 9.4

def uses_only(aword, astring):
# Returns True if the word contains only letters in the list.
# It must also contain all the letters from the list.
count = 0
aword = aword.replace(' ', '')
letterchecker = False
for bagels in astring:
if bagels not in aword:
return False
for bagels in aword:
for cheesecakes in astring:
if cheesecakes == bagels:
letterchecker = True
if letterchecker == False:
return False
else:
letterchecker = False
return True

print uses_only('cell of heal', 'acefhlo')
Binary file added my_app/.DS_Store
Binary file not shown.
Loading