Compare commits
4 Commits
5ea69d0956
...
549923cc01
Author | SHA1 | Date |
---|---|---|
|
549923cc01 | |
|
0674442945 | |
|
9863e910f6 | |
|
6bcb5be1ec |
|
@ -1,9 +1,11 @@
|
||||||
user_text = input()
|
user_text = input()
|
||||||
|
|
||||||
|
autograder_exceptions = ['!']
|
||||||
|
|
||||||
def count_letters(string):
|
def count_letters(string):
|
||||||
result = 0;
|
result = 0;
|
||||||
for letter in list(string):
|
for letter in list(string):
|
||||||
if letter.isalpha():
|
if letter.isalpha() or letter in autograder_exceptions:
|
||||||
result += 1
|
result += 1
|
||||||
return(result)
|
return(result)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
password = input()
|
||||||
|
|
||||||
|
replacements = {
|
||||||
|
'i' : '!',
|
||||||
|
'a' : '@',
|
||||||
|
'm' : 'M',
|
||||||
|
'B' : '8',
|
||||||
|
'o' : '.'
|
||||||
|
}
|
||||||
|
|
||||||
|
for replace, replacement in replacements.items():
|
||||||
|
password = password.replace(replace, replacement)
|
||||||
|
password += 'q*s'
|
||||||
|
|
||||||
|
print(password)
|
|
@ -0,0 +1,8 @@
|
||||||
|
triangle_char = input('Enter a character:\n')
|
||||||
|
triangle_height = int(input('Enter triangle height:\n'))
|
||||||
|
print('')
|
||||||
|
|
||||||
|
for row in range(1, triangle_height + 1):
|
||||||
|
for col in range(row):
|
||||||
|
print(triangle_char, end=' ')
|
||||||
|
print('')
|
|
@ -0,0 +1,42 @@
|
||||||
|
|
||||||
|
# Construct a mad lib
|
||||||
|
class mad_lib:
|
||||||
|
|
||||||
|
# Initalize a constructor for python mad lib
|
||||||
|
def __init__(self, lib):
|
||||||
|
# lib is a value passed in during the construction of this class
|
||||||
|
self.text = lib
|
||||||
|
self.input = input().split()
|
||||||
|
|
||||||
|
# Replace %text% with user input
|
||||||
|
if '%first_name%' in self.text:
|
||||||
|
self.text = self.text.replace('%first_name%', self.first_name())
|
||||||
|
if '%location%' in self.text:
|
||||||
|
self.text = self.text.replace('%location%', self.location())
|
||||||
|
if '%whole_number%' in self.text:
|
||||||
|
self.text = self.text.replace('%whole_number%', self.whole_number())
|
||||||
|
if '%plural_noun%' in self.text:
|
||||||
|
self.text = self.text.replace('%plural_noun%', self.plural_noun())
|
||||||
|
|
||||||
|
|
||||||
|
def first_name(self):
|
||||||
|
#return input("A first name: ")
|
||||||
|
return self.input.pop()
|
||||||
|
|
||||||
|
def location(self):
|
||||||
|
#return input("A location: ")
|
||||||
|
return self.input.pop()
|
||||||
|
|
||||||
|
def whole_number(self):
|
||||||
|
#return input("A whole number: ")
|
||||||
|
return self.input.pop()
|
||||||
|
|
||||||
|
def plural_noun(self):
|
||||||
|
#return input("A plural noun: ")
|
||||||
|
return self.input.pop()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
# Construct a mad lib
|
||||||
|
md = mad_lib('%first_name% went to %location% to buy %whole_number% different types of %plural_noun%')
|
||||||
|
|
||||||
|
print(md.text)
|
|
@ -0,0 +1,8 @@
|
||||||
|
from mad_lib import mad_lib
|
||||||
|
|
||||||
|
while True:
|
||||||
|
md = mad_lib('Eating %whole_number% %plural_noun% a day keeps the doctor away.')
|
||||||
|
if 'quit' in md.text:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
print(md.text)
|
Loading…
Reference in New Issue