Merge pull request 'week-4' (#5) from week-4 into master
Reviewed-on: https://kitsunehosting.net/gitea/Kenwood/SNHU-IT-140/pulls/5
This commit is contained in:
commit
2bbeb9da06
|
@ -0,0 +1,13 @@
|
||||||
|
user_score = 0
|
||||||
|
simon_pattern = input()
|
||||||
|
user_pattern = input()
|
||||||
|
|
||||||
|
#user_score = sum(a==b for a, b in zip(simon_pattern, user_pattern))
|
||||||
|
|
||||||
|
for char in enumerate(list(simon_pattern)):
|
||||||
|
if user_pattern[char[0]] == char[1]:
|
||||||
|
user_score += 1
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
|
print('User score:', user_score)
|
|
@ -0,0 +1,12 @@
|
||||||
|
user_text = input()
|
||||||
|
|
||||||
|
autograder_exceptions = ['!']
|
||||||
|
|
||||||
|
def count_letters(string):
|
||||||
|
result = 0;
|
||||||
|
for letter in list(string):
|
||||||
|
if letter.isalpha() or letter in autograder_exceptions:
|
||||||
|
result += 1
|
||||||
|
return(result)
|
||||||
|
|
||||||
|
print(count_letters(user_text))
|
|
@ -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)
|
|
@ -0,0 +1,5 @@
|
||||||
|
user_num = int(input())
|
||||||
|
|
||||||
|
while user_num >= 1:
|
||||||
|
user_num = user_num / 2 # We operate on the value first, before printing it
|
||||||
|
print(user_num)
|
|
@ -0,0 +1,9 @@
|
||||||
|
num_insects = int(input()) # Must be >= 1
|
||||||
|
|
||||||
|
result = []
|
||||||
|
|
||||||
|
while num_insects <= 100:
|
||||||
|
result.append(num_insects)
|
||||||
|
num_insects = num_insects * 2
|
||||||
|
|
||||||
|
print(*result, end = ' ')
|
|
@ -0,0 +1,12 @@
|
||||||
|
contact_emails = {
|
||||||
|
'Sue Reyn' : 's.reyn@email.com',
|
||||||
|
'Mike Filt': 'mike.filt@bmail.com',
|
||||||
|
'Nate Arty': 'narty042@nmail.com'
|
||||||
|
}
|
||||||
|
|
||||||
|
new_contact = input()
|
||||||
|
new_email = input()
|
||||||
|
contact_emails[new_contact] = new_email
|
||||||
|
|
||||||
|
for contact in contact_emails:
|
||||||
|
print('{0} is {1}'.format(contact_emails.get(contact), contact))
|
|
@ -0,0 +1,8 @@
|
||||||
|
num_rows = int(input())
|
||||||
|
num_cols = int(input())
|
||||||
|
|
||||||
|
for _i in range(num_rows):
|
||||||
|
print('*', end=' ')
|
||||||
|
for _i in range(num_cols - 1):
|
||||||
|
print('*', end=' ')
|
||||||
|
print()
|
|
@ -0,0 +1,11 @@
|
||||||
|
num_rows = int(input())
|
||||||
|
num_cols = int(input())
|
||||||
|
|
||||||
|
# Note 1: You will need to declare more variables
|
||||||
|
# Note 2: Place end=' ' at the end of your print statement to separate seats by spaces
|
||||||
|
|
||||||
|
for row_num in range(1, num_rows + 1):
|
||||||
|
for col_char in map(chr, range(ord('A'), ord('A') + num_cols)):
|
||||||
|
print('{0}{1}'.format(row_num, col_char), end=' ')
|
||||||
|
|
||||||
|
print()
|
Loading…
Reference in New Issue