This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#I added quite a bit of additional functionality so the project created more real world class instance objects | |
class Business: | |
def __init__(self, name, franchises): | |
self.name = name | |
self.franchises = [] | |
class Franchise: | |
def __init__(self, address, menus, name): | |
self.address = address |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HashMap: | |
def __init__(self, array_size): | |
self.array_size = array_size | |
self.array = [None for item in range(array_size)] | |
def hash(self, key, count_collisions=0): | |
key_bytes = key.encode() | |
hash_code = sum(key_bytes) | |
return hash_code + count_collisions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#task 1 | |
from roster import student_roster | |
import itertools | |
#task 2 | |
from classroom_organizer import ClassroomOrganizer | |
new_student = ClassroomOrganizer() | |
student_roster_iterator = iter(student_roster) | |
print("task 1") | |
print("The full student roster (dictionary):") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def flatten_array(arr): | |
# Write your code here | |
flat_list = [] | |
# Iterate through the outer list | |
for element in arr: | |
#if type(element) is list: #using type() to check for nested array OR | |
if isinstance(element, list): #using isinstance() to check for nested (multi-dimensional array | |
# If the element is of type list, iterate through the sublist or inner list | |
for item in element: | |
flat_list.append(item) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Reverse Words | |
Write a function, word_reverser(), that will take a given string and reverse the order of the words. | |
You may assume that the string is a sentence that contains only letters and spaces, with all words separated by one space. | |
For example, word_reverser("Codecademy rules") should return "rules Codecademy" | |
and word_reverser("May the Fourth be with you") should return "you with be Fourth the May". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const caesarCipher = (str, amount = 0) => { | |
if (amount < 0) { | |
return caesarCipher(str, amount + 26); | |
} | |
let output = ''; | |
for (let i = 0; i < str.length; i++) { | |
let char = str[i]; | |
if (char.match(/[a-z]/i)) { | |
let code = str.charCodeAt(i); | |
if (code >= 65 && code <= 90) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Task 1-13 and my own task 14 | |
const menu = { | |
_courses: { | |
appetizers:[], | |
mains:[], | |
desserts:[], | |
}, | |
get appetizers() { | |
return this._courses.appetizers; | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Forget about the past, you can’t change it. | |
Forget about the future, you can’t predict it. | |
And forget about the present, I didn’t get you one. | |
Happy birthday! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PoemFiles: | |
def __init__(self, poem_file, mode): | |
print('Starting up a poem context manager') | |
self.file = poem_file | |
self.mode = mode | |
def __enter__(self): | |
print('Opening poem file') | |
self.opened_poem_file = open(self.file, self.mode) | |
return self.opened_poem_file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
name = "Zebra" | |
question = "Will I grow wings?" | |
answer = "" | |
random_number = random.randint(1, 11) | |
#print(random_number) | |
if random_number == 1: |
NewerOlder