From 22dccbcf8f4ab38e717ac2b24b595ffdbc8e2cb6 Mon Sep 17 00:00:00 2001 From: katarzynakaz Date: Mon, 9 Feb 2026 14:21:19 +0000 Subject: [PATCH 1/6] prep --- prep/1.py | 10 +++++ prep/10.py | 60 +++++++++++++++++++++++++++ prep/11.py | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++ prep/12.py | 41 +++++++++++++++++++ prep/2.py | 10 +++++ prep/3.py | 43 ++++++++++++++++++++ prep/4-5.py | 33 +++++++++++++++ prep/6.py | 9 +++++ prep/7.py | 27 +++++++++++++ prep/8.py | 30 ++++++++++++++ prep/9.py | 25 ++++++++++++ prep/notes.md | 39 ++++++++++++++++++ 12 files changed, 436 insertions(+) create mode 100644 prep/1.py create mode 100644 prep/10.py create mode 100644 prep/11.py create mode 100644 prep/12.py create mode 100644 prep/2.py create mode 100644 prep/3.py create mode 100644 prep/4-5.py create mode 100644 prep/6.py create mode 100644 prep/7.py create mode 100644 prep/8.py create mode 100644 prep/9.py create mode 100644 prep/notes.md diff --git a/prep/1.py b/prep/1.py new file mode 100644 index 000000000..0c87a0eff --- /dev/null +++ b/prep/1.py @@ -0,0 +1,10 @@ +# ✍️exercise +# Predict what double("22") will do. Then run the code and check. Did it do what you expected? +# Why did it return the value it did? + +def double(value): + return value * 2 + +#2222 + +print(double("22")) \ No newline at end of file diff --git a/prep/10.py b/prep/10.py new file mode 100644 index 000000000..b7a435bd3 --- /dev/null +++ b/prep/10.py @@ -0,0 +1,60 @@ +# ✍️exercise +# Try changing the type annotation of Person.preferred_operating_system +# from str to List[str]. + +# Run mypy on the code. + +# It tells us different places that our code is now wrong, because we’re +# passing values of the wrong +# type. + +# We probably also want to rename our field - lists are plural. Rename +# the field to preferred_operating_systems. + +# Run mypy again. + +# Fix all of the places that mypy tells you need changing. Make sure the +# program works as you’d expect. + +from dataclasses import dataclass +from typing import List + +@dataclass(frozen=True) +class Person: + name: str + age: int + preferred_operating_systems: List[str] + + +@dataclass(frozen=True) +class Laptop: + id: int + manufacturer: str + model: str + screen_size_in_inches: float + operating_system: str + + +def find_possible_laptops(laptops: List[Laptop], person: Person) -> List[Laptop]: + possible_laptops = [] + for laptop in laptops: + if laptop.operating_system == person.preferred_operating_systems: + possible_laptops.append(laptop) + return possible_laptops + + +people = [ + Person(name="Imran", age=22, preferred_operating_systems=["Ubuntu"]), + Person(name="Eliza", age=34, preferred_operating_systems=["Arch Linux"]), +] + +laptops = [ + Laptop(id=1, manufacturer="Dell", model="XPS", screen_size_in_inches=13, operating_system="Arch Linux"), + Laptop(id=2, manufacturer="Dell", model="XPS", screen_size_in_inches=15, operating_system="Ubuntu"), + Laptop(id=3, manufacturer="Dell", model="XPS", screen_size_in_inches=15, operating_system="ubuntu"), + Laptop(id=4, manufacturer="Apple", model="macBook", screen_size_in_inches=13, operating_system="macOS"), +] + +for person in people: + possible_laptops = find_possible_laptops(laptops, person) + print(f"Possible laptops for {person.name}: {possible_laptops}") \ No newline at end of file diff --git a/prep/11.py b/prep/11.py new file mode 100644 index 000000000..6a3d9bac7 --- /dev/null +++ b/prep/11.py @@ -0,0 +1,109 @@ +# exercise +# Write a program which: + +# Already has a list of Laptops that a library has to lend out. +# Accepts user input to create a new Person - it should use the input +# function to read a person’s name, age, and preferred operating system. +# Tells the user how many laptops the library has that have that +# operating system. +# If there is an operating system that has more laptops available, +# tells the user that if they’re willing to accept that operating +# system they’re more likely to get a laptop. +# You should convert the age and preferred operating system input from +# the user into more constrained types as quickly as possible, and +# should output errors to stderr and terminate +# the program with a non-zero exit code if the user input bad values. + +from dataclasses import dataclass +from enum import Enum +from typing import List +from collections import Counter +import sys + +class OperatingSystem(Enum): + MACOS = "macOS" + ARCH = "Arch Linux" + UBUNTU = "Ubuntu" + +@dataclass(frozen=True) +class Person: + name: str + age: int + preferred_operating_system: OperatingSystem + + +@dataclass(frozen=True) +class Laptop: + id: int + manufacturer: str + model: str + screen_size_in_inches: float + operating_system: OperatingSystem + +def create_a_new_person() -> Person: + add_name = input("What is your name? \n") + if not add_name or add_name == "" or len(add_name) > 50: + print("Enter a valid name.", file=sys.stderr) + sys.exit(1) + + add_age = int(input("What is your age? \n")) + if add_age < 0 or add_age > 100: + print("Enter a valid age.", file=sys.stderr) + sys.exit(1) + + add_os = input("What is your preferred operating system? \n") + + if add_os not in [os.value for os in OperatingSystem]: + print("Enter a valid operating system.", file=sys.stderr) + sys.exit(1) + + return Person(name=add_name, age=add_age, preferred_operating_system=OperatingSystem(add_os)) + + +def find_possible_laptops(laptops: List[Laptop], person: Person) -> List[Laptop]: + possible_laptops = [] + other_laptops = [] + for laptop in laptops: + if laptop.operating_system == person.preferred_operating_system: + possible_laptops.append(laptop) + else: + other_laptops.append(laptop) + return possible_laptops, other_laptops + +def compare_counts_of_poss_and_others(possible_laptops: List[Laptop], other_laptops: List[Laptop], person: Person) -> None: + # counter to get obj + other_laptops_counted_as_obj = Counter(laptop.operating_system for laptop in other_laptops) + # and here turn to tuple os+count + most_common_laptop = other_laptops_counted_as_obj.most_common(1)[0] + + if len(possible_laptops) < most_common_laptop[1]: + # print(f"There are more laptops available with {str(most_common_laptop[0])} than your preferred OS {person.preferred_operating_system.value}. Consider accepting that OS to increase your chances of getting a laptop.") + print(f"There are more laptops available with {most_common_laptop[0].value} than your preferred OS {person.preferred_operating_system.value}. Consider accepting that OS to increase your chances of getting a laptop.") + else: + print("Your chosen os has the biggest availability.") + +people = [ + # Person(name="Imran", age=22, preferred_operating_system=OperatingSystem.UBUNTU), + # Person(name="Eliza", age=34, preferred_operating_system=OperatingSystem.ARCH), +] + +laptops = [ + Laptop(id=1, manufacturer="Dell", model="XPS", screen_size_in_inches=13, operating_system=OperatingSystem.ARCH), + Laptop(id=2, manufacturer="Dell", model="XPS", screen_size_in_inches=15, operating_system=OperatingSystem.UBUNTU), + Laptop(id=3, manufacturer="Dell", model="XPS", screen_size_in_inches=15, operating_system=OperatingSystem.UBUNTU), + Laptop(id=4, manufacturer="Apple", model="macBook", screen_size_in_inches=13, operating_system=OperatingSystem.MACOS), +] + +for person in people: + possible_laptops = find_possible_laptops(laptops, person) + print(f"Possible laptops for {person.name}: {possible_laptops}") + + +def execute(): + new_person = create_a_new_person() + possible_laptops, other_laptops = find_possible_laptops(laptops, new_person) + print(f"Number of laptops matching your preferred OS: {len(possible_laptops)}") + compare_counts_of_poss_and_others(possible_laptops, other_laptops, new_person) + + +execute() \ No newline at end of file diff --git a/prep/12.py b/prep/12.py new file mode 100644 index 000000000..7fd22dfc6 --- /dev/null +++ b/prep/12.py @@ -0,0 +1,41 @@ +# Play computer with this code. Predict what you expect each line will do. +# Then run the code and check your predictions. (If any lines cause +# errors, you may need to comment them out to check later lines). + +class Parent: + def __init__(self, first_name: str, last_name: str): + self.first_name = first_name + self.last_name = last_name + + def get_name(self) -> str: + return f"{self.first_name} {self.last_name}" + + +class Child(Parent): + def __init__(self, first_name: str, last_name: str): + super().__init__(first_name, last_name) + self.previous_last_names = [] + + def change_last_name(self, last_name) -> None: + self.previous_last_names.append(self.last_name) + self.last_name = last_name + + def get_full_name(self) -> str: + suffix = "" + if len(self.previous_last_names) > 0: + suffix = f" (née {self.previous_last_names[0]})" + return f"{self.first_name} {self.last_name}{suffix}" + +person1 = Child("Elizaveta", "Alekseeva") +print(person1.get_name()) +print(person1.get_full_name()) +person1.change_last_name("Tyurina") +print(person1.get_name()) +print(person1.get_full_name()) + +person2 = Parent("Elizaveta", "Alekseeva") +print(person2.get_name()) +print(person2.get_full_name()) +person2.change_last_name("Tyurina") +print(person2.get_name()) +print(person2.get_full_name()) \ No newline at end of file diff --git a/prep/2.py b/prep/2.py new file mode 100644 index 000000000..47f644599 --- /dev/null +++ b/prep/2.py @@ -0,0 +1,10 @@ +# ✍️exercise +# Read the above code and write down what the bug is. +# How would you fix it? + +def double(number): + return number * 3 + +print(double(10)) + +#Either call it tripple or * 2 \ No newline at end of file diff --git a/prep/3.py b/prep/3.py new file mode 100644 index 000000000..177f443f7 --- /dev/null +++ b/prep/3.py @@ -0,0 +1,43 @@ +# ✍️exercise +# Do not run the following code. + +# This code contains bugs related to types. They are bugs mypy can catch. + +# Read this code to understand what it’s trying to do. +# Add type annotations to the method parameters and return types of this code. +# Run the code through mypy, and fix all of the bugs that show up. +# When you’re confident all of the type annotations are correct, and the bugs are fixed, +# run the code and check it works. + +def open_account(balances, name, amount): + balances[name] = amount + +def sum_balances(accounts): + total = 0 + for name, pence in accounts.items(): + print(f"{name} had balance {pence}") + total += pence + return total + +def format_pence_as_string(total_pence): + if total_pence < 100: + return f"{total_pence}p" + pounds = int(total_pence / 100) + pence = total_pence % 100 + return f"£{pounds}.{pence:02d}" +# File "C:\Users\kkazi\Desktop\cyf\Module-Tools\prep\3.py", line 27, in format_pence_as_string + # return f"£{pounds}.{pence:02d}" + #^^^^^^^^^^^ +#ValueError: Unknown format code 'd' for object of type 'float' +balances = { + "Sima": 700, + "Linn": 545, + "Georg": 831, +} + +open_account(balances, "Tobi", 913) # to solve the float int issue value passed in in pence3.py:35: error: Missing positional argument "amount" in call to "open_account" [call-arg] +open_account(balances, "Olya", 713) #3.py:36: error: Missing positional argument "amount" in call to "open_account" [call-arg] + +total_pence = sum_balances(balances) +total_string = format_pence_as_string(total_pence) # 3.py:39: error: Name "format_pence_as_str" is not defined [name-defined] +print(f"The bank accounts total {total_string}") \ No newline at end of file diff --git a/prep/4-5.py b/prep/4-5.py new file mode 100644 index 000000000..77589bd73 --- /dev/null +++ b/prep/4-5.py @@ -0,0 +1,33 @@ +# Exercise +# Add the is_adult code to the file you saved earlier. + +# Run it through mypy - notice that no errors are reported - mypy understands that Person has a property named age so is happy with the function. + +# Write a new function in the file that accepts a Person as a parameter and tries to access a property that doesn’t exist. +# Run it through mypy and check that it does report an error. + +class Person: + def __init__(self, name: str, age: int, preferred_operating_system: str): + self.name = name + self.age = age + self.preferred_operating_system = preferred_operating_system + +imran = Person("Imran", 22, "Ubuntu") +print(imran.name) +print(imran.address) + +eliza = Person("Eliza", 34, "Arch Linux") +print(eliza.name) +print(eliza.address) + +def is_adult(person: Person) -> bool: + return person.age >= 18 + +print(is_adult(imran)) +#error means prop does not exist + +def get_eye_colour(person: Person): + return person.eye_colour + +print(get_eye_colour(imran)) +#error in mypy no attribute \ No newline at end of file diff --git a/prep/6.py b/prep/6.py new file mode 100644 index 000000000..fb46bf7bb --- /dev/null +++ b/prep/6.py @@ -0,0 +1,9 @@ +# exercise +# Think of the advantages of using methods instead of free functions. Write them down in your notebook. +1 makes data and logic more organised +2 makes it easier to find and reuse code +3 makes the code more specific and it is easier to understand what it is doing for + a junior/learner like me :) +4 reduces errors + + diff --git a/prep/7.py b/prep/7.py new file mode 100644 index 000000000..d510ecc90 --- /dev/null +++ b/prep/7.py @@ -0,0 +1,27 @@ +# exercise +# Change the Person class to take a date of birth +# (using the standard library’s datetime.date class) and store it in a +# field instead of age. + +# Update the is_adult method to act the same as before. + +from datetime import date + +class Person: + def __init__(self, name: str, dob: date, preferred_operating_system: str): + self.name = name + self.dob = dob + self.preferred_operating_system = preferred_operating_system + + + def is_adult(self): + today = date.today() + age = date.today().year - self.dob.year + if (today.month, today.day) < (self.dob.month, self.dob.day): + age -= 1 + return age >= 18 + +imran = Person("Imran", date(1988, 10, 10), "Ubuntu") +print(imran.is_adult()) +imran = Person("Jay", date(2015, 10, 10), "Ubuntu") +print(imran.is_adult()) \ No newline at end of file diff --git a/prep/8.py b/prep/8.py new file mode 100644 index 000000000..b7b4c8b3d --- /dev/null +++ b/prep/8.py @@ -0,0 +1,30 @@ +# ✍️exercise +# Write a Person class using @datatype which uses a datetime.date +# for date of birth, rather than an int for age. + +# Re-add the is_adult method to it. + +from dataclasses import dataclass +from datetime import date + +@dataclass +class Person: + # def __init__(self, name: str, dob: date, preferred_operating_system: str): + # self.name = name + # self.dob = dob + # self.preferred_operating_system = preferred_operating_system + name: str + dob: date + preferred_operating_system: str + + def is_adult(self): + today = date.today() + age = date.today().year - self.dob.year + if (today.month, today.day) < (self.dob.month, self.dob.day): + age -= 1 + return age >= 18 + +imran = Person("Imran", date(1988, 10, 10), "Ubuntu") +print(imran.is_adult()) +imran = Person("Jay", date(2015, 10, 10), "Ubuntu") +print(imran.is_adult()) \ No newline at end of file diff --git a/prep/9.py b/prep/9.py new file mode 100644 index 000000000..7afa54ab9 --- /dev/null +++ b/prep/9.py @@ -0,0 +1,25 @@ +# ✍️exercise +# Fix the above code so that it works. You must not change the print +# on line 17 - we do want to print the children’s ages. +# (Feel free to invent the ages of Imran’s children.) + +from dataclasses import dataclass +from typing import List + +@dataclass(frozen=True) +class Person: + name: str + age: int + children: List["Person"] + +fatma = Person(name="Fatma", age=12, children=[]) +aisha = Person(name="Aisha", age=25, children=[]) + +imran = Person(name="Imran", age=67, children=[fatma, aisha]) + +def print_family_tree(person: Person) -> None: + print(person.name) + for child in person.children: + print(f"- {child.name} ({child.age})") + +print_family_tree(imran) \ No newline at end of file diff --git a/prep/notes.md b/prep/notes.md new file mode 100644 index 000000000..1887d3d54 --- /dev/null +++ b/prep/notes.md @@ -0,0 +1,39 @@ + +def how_many_laptops_match_os(person: Person) -> List[Laptop]: + possible_laptops = [] + for laptop in laptops: + if laptop.operating_system == person.preferred_operating_system: + possible_laptops.append(laptop) + prinet(f"Number of laptops matching your preferred OS: {len(possible_laptops)}") + return possible_laptops + + +# for person in people: +# possible_laptops = find_possible_laptops(laptops, person) +# print(f"Possible laptops for {person.name}: {possible_laptops}") + +# If there is an operating system that has more laptops available, +# tells the user that if they’re willing to accept that operating +# system they’re more likely to get a laptop. + +def get_counts_of_all_laptops_by_os(laptops: List[laptop]) -> dict: + number_of_laptops = {} + + for laptop in laptops: + particular_os = laptop.operating_system + + if particular_os in number_of_laptops: + number_of_laptops[particular_os] += 1 + else: + number_of_laptops[particular_os] = 1 + + return number_of_laptops + +def check_if_there_is_os_with_more_laptops(laptops: List[Laptop], person: Person, possible_laptops: List[Laptop]) -> None: + not_matching_laptop_counts = get_counts_of_all_laptops_by_os(laptops) + + + for laptop in get_counts_of_all_laptops_by_os(laptops): + if laptop.operating_system != person.preferred_operating_system: + not_matching_laptop_counts = get_counts_of_all_laptops_by_os(laptops) + print(f"There are more laptops available with {laptop.operating_system.value} than your preferred OS {person.preferred_operating_system.value}. Consider accepting that OS to increase your chances of getting a laptop.") From 2e3be0b9de7a090df28e77b079ed2f01683f085a Mon Sep 17 00:00:00 2001 From: katarzynakaz Date: Mon, 9 Feb 2026 14:41:29 +0000 Subject: [PATCH 2/6] prep fin --- implement-shell-tools/cat/notes.js | 38 ++++++++++++++++++++ implement-shell-tools/ls/index.js | 50 ++++++++++++++++++++++++++ individual-shell-tools/ls/script-02.sh | 1 + prep/12.py | 21 ++++++----- sprint 5/laptop.py | 50 ++++++++++++++++++++++++++ 5 files changed, 149 insertions(+), 11 deletions(-) create mode 100644 implement-shell-tools/cat/notes.js create mode 100644 implement-shell-tools/ls/index.js create mode 100644 sprint 5/laptop.py diff --git a/implement-shell-tools/cat/notes.js b/implement-shell-tools/cat/notes.js new file mode 100644 index 000000000..dc54e635a --- /dev/null +++ b/implement-shell-tools/cat/notes.js @@ -0,0 +1,38 @@ +import process from "node:process"; +import { promises as fs } from "node:fs"; +// const fs = promises + +// * `cat sample-files/1.txt` +// * `cat -n sample-files/1.txt` +// * `cat sample-files/*.txt` +// * `cat -n sample-files/*.txt` +// * `cat -b sample-files/3.txt` + +//from coursework +// const content = await fs.readFile(path, "utf-8"); +// const countOfWordsContainingEs = content +// .split(" ") +// .filter((word) => word.includes("e")) +// .length; +// console.log(countOfWordsContainingEs); + +// process.argv documentation that process.argv[0] will be the path to node +// process.argv[1] will be the path to this file +// the arguments start at index 2 + + + +// 1 `cat sample-files/1.txt` +// async function caseOne(oneFile) { +// const content = await fs.readFile(file, "utf-8"); +// console.log(content); +// } +// 3 `cat sample-files/*.txt` +// async function caseThree(listOfFiles) { +// for (const file of listOfFiles) { +// const content = await fs.readFile(file, "utf-8"); + +// console.log(content); +// } +// } + diff --git a/implement-shell-tools/ls/index.js b/implement-shell-tools/ls/index.js new file mode 100644 index 000000000..c8d962a86 --- /dev/null +++ b/implement-shell-tools/ls/index.js @@ -0,0 +1,50 @@ +// fs.readdir +import process from "node:process"; +import { promises as fs } from "node:fs"; + + +// `ls -1` +async function showAllFilesInDir(directory) { + const listOfFiles = await fs.readdir(directory); + + for (const eachFile of listOfFiles) { + console.log(eachFile); + } +} + +// `ls -1 sample-files` +async function showVisibleInSampleFiles() { + const listOfFiles = await fs.readdir('sample-files'); + + for (const eachFile of listOfFiles) { + if (eachFile[0] !== '.') { + console.log(eachFile); + } + + } +} + + +// `ls -1 -a sample-files` +async function showAllInSampleFiles() { + const listOfFiles = await fs.readdir('sample-files'); + + for (const eachFile of listOfFiles) { + + console.log(eachFile); + + } +} + + + +const argv = process.argv.slice(2); + +if (argv.includes('-a')) { + await showAllInSampleFiles(); +} else if (argv.includes('sample-files')) { + await showVisibleInSampleFiles(); +} else { + await showCurrentDir(); +} + diff --git a/individual-shell-tools/ls/script-02.sh b/individual-shell-tools/ls/script-02.sh index d0a5a10f4..9fa05d88b 100755 --- a/individual-shell-tools/ls/script-02.sh +++ b/individual-shell-tools/ls/script-02.sh @@ -4,3 +4,4 @@ set -euo pipefail # TODO: Write a command which lists all of the files in the directory named child-directory. # The output should be a list of names: helper-1.txt, helper-2.txt, helper-3.txt. +ls child-directory \ No newline at end of file diff --git a/prep/12.py b/prep/12.py index 7fd22dfc6..65584651e 100644 --- a/prep/12.py +++ b/prep/12.py @@ -10,7 +10,6 @@ def __init__(self, first_name: str, last_name: str): def get_name(self) -> str: return f"{self.first_name} {self.last_name}" - class Child(Parent): def __init__(self, first_name: str, last_name: str): super().__init__(first_name, last_name) @@ -27,15 +26,15 @@ def get_full_name(self) -> str: return f"{self.first_name} {self.last_name}{suffix}" person1 = Child("Elizaveta", "Alekseeva") -print(person1.get_name()) -print(person1.get_full_name()) -person1.change_last_name("Tyurina") -print(person1.get_name()) -print(person1.get_full_name()) +print(person1.get_name()) # prints Elizaveta Alekseeva +print(person1.get_full_name()) # prints Elizaveta Alekseeva +person1.change_last_name("Tyurina") # no print +print(person1.get_name()) # prints Elizaveta Tyurina +print(person1.get_full_name()) # prints Elizaveta Tyurina (née Alekseeva) person2 = Parent("Elizaveta", "Alekseeva") -print(person2.get_name()) -print(person2.get_full_name()) -person2.change_last_name("Tyurina") -print(person2.get_name()) -print(person2.get_full_name()) \ No newline at end of file +print(person2.get_name()) #print Elizaveta Alekseeva +print(person2.get_full_name()) #no full name method +person2.change_last_name("Tyurina") #no change last name method +print(person2.get_name()) # print Elizaveta Alekseeva +print(person2.get_full_name()) #no full name method so err \ No newline at end of file diff --git a/sprint 5/laptop.py b/sprint 5/laptop.py new file mode 100644 index 000000000..83eb38522 --- /dev/null +++ b/sprint 5/laptop.py @@ -0,0 +1,50 @@ +In the prep, there was an exercise around finding possible laptops for a group of people. + +Your exercise is to extend this to actually allocate laptops to the people. + +Given these class definitions: + +from dataclasses import dataclass +from enum import Enum +from typing import List + +class OperatingSystem(Enum): + MACOS = "macOS" + ARCH = "Arch Linux" + UBUNTU = "Ubuntu" + +@dataclass(frozen=True) +class Person: + name: str + age: int + # Sorted in order of preference, most preferred is first. + preferred_operating_system: List[OperatingSystem] + + +@dataclass(frozen=True) +class Laptop: + id: int + manufacturer: str + model: str + screen_size_in_inches: float + operating_system: OperatingSystem +Write a function with this signature: + +def allocate_laptops(people: List[Person], laptops: List[Laptop]) -> Dict[Person, Laptop]: +Every person should be allocated exactly one laptop. + +If we define "sadness" as the number of places down in someone's ranking the +operating system the ended up with (i.e. if your preferences were [UBUNTU, ARCH, MACOS] + +and you were allocated a MACOS machine your sadness would be 2), we want to minimise the total sadness of +all people. If we allocate someone a laptop with an operating system not in their preferred list, treat +them as having a sadness of 100. + +def ranking(): + + +def minimize_sandess(): + + +def allocate_laptops(): + \ No newline at end of file From 9bcad83807a0d150639b3fd8dcacd8f9bdb56dfc Mon Sep 17 00:00:00 2001 From: katarzynakaz Date: Mon, 23 Feb 2026 13:01:27 +0000 Subject: [PATCH 3/6] fixes from the reviewer implemented and files renamed --- .DS_Store | Bin 0 -> 12292 bytes .gitignore | 1 + implement-shell-tools/cat/.DS_Store | Bin 0 -> 8196 bytes implement-shell-tools/cat/notes.js | 38 ------------- implement-shell-tools/ls/index.js | 50 ------------------ prep/.DS_Store | Bin 0 -> 6148 bytes prep/1.py => "prep/1 double(\"22\").py" | 0 prep/{2.py => 1 double-bug.py} | 0 prep/{3.py => 2 type-bugs.py} | 0 prep/{4-5.py => 3 mypy error and is_adult.py} | 0 prep/{7.py => 4 Person class exercise.py} | 0 prep/{6.py => 4 advantages of methods.py} | 0 prep/{8.py => 5 Person dataclass exercise.py} | 0 prep/{9.py => 6 fix code.py} | 0 prep/{10.py => 7 type values fix.py} | 2 +- prep/{11.py => 8 laptop program.py} | 23 +++++--- prep/{12.py => 9 play computer.py} | 0 prep/notes.md | 39 -------------- sprint 5/laptop.py | 50 ------------------ 19 files changed, 17 insertions(+), 186 deletions(-) create mode 100644 .DS_Store create mode 100644 implement-shell-tools/cat/.DS_Store delete mode 100644 implement-shell-tools/cat/notes.js delete mode 100644 implement-shell-tools/ls/index.js create mode 100644 prep/.DS_Store rename prep/1.py => "prep/1 double(\"22\").py" (100%) rename prep/{2.py => 1 double-bug.py} (100%) rename prep/{3.py => 2 type-bugs.py} (100%) rename prep/{4-5.py => 3 mypy error and is_adult.py} (100%) rename prep/{7.py => 4 Person class exercise.py} (100%) rename prep/{6.py => 4 advantages of methods.py} (100%) rename prep/{8.py => 5 Person dataclass exercise.py} (100%) rename prep/{9.py => 6 fix code.py} (100%) rename prep/{10.py => 7 type values fix.py} (96%) rename prep/{11.py => 8 laptop program.py} (89%) rename prep/{12.py => 9 play computer.py} (100%) delete mode 100644 prep/notes.md delete mode 100644 sprint 5/laptop.py diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a3561d92ce888ddd1db151175e4ac8c1aec3ba4e GIT binary patch literal 12292 zcmeGiTWlLeaOaY?d%ZrcA$`)59ZcIabyX*QQ)pc$fxgm5oHUO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IF4oN4Siy@jZUPkGP6!_zk~H719i8rZh{6O3S5sX@#^|+9GX}_DMZbM(PzlNafT! zH0o0@kOqlNc(hRJm5vta+>KMO_P%Y~ckJ9XX;bgZSv=WptDZY=esppDsx=$#**XeI zf#5P||DFs1{>NlZfd2p^Dk(dKY;%OBtTahA(K0;O#5YqRe4QaIF5Hiq_CEVL^(2obqQ2z)X#bbC9PZ9E;CG4NYi+Bky<8_?JTeyI?gB{4HZ{EdZ<+Y_|4H@E;md>(2qSQ7BY?{0baRTWy~F!Iy#L1+%>SYL F|1Y2-iPr!C literal 0 HcmV?d00001 diff --git a/implement-shell-tools/cat/notes.js b/implement-shell-tools/cat/notes.js deleted file mode 100644 index dc54e635a..000000000 --- a/implement-shell-tools/cat/notes.js +++ /dev/null @@ -1,38 +0,0 @@ -import process from "node:process"; -import { promises as fs } from "node:fs"; -// const fs = promises - -// * `cat sample-files/1.txt` -// * `cat -n sample-files/1.txt` -// * `cat sample-files/*.txt` -// * `cat -n sample-files/*.txt` -// * `cat -b sample-files/3.txt` - -//from coursework -// const content = await fs.readFile(path, "utf-8"); -// const countOfWordsContainingEs = content -// .split(" ") -// .filter((word) => word.includes("e")) -// .length; -// console.log(countOfWordsContainingEs); - -// process.argv documentation that process.argv[0] will be the path to node -// process.argv[1] will be the path to this file -// the arguments start at index 2 - - - -// 1 `cat sample-files/1.txt` -// async function caseOne(oneFile) { -// const content = await fs.readFile(file, "utf-8"); -// console.log(content); -// } -// 3 `cat sample-files/*.txt` -// async function caseThree(listOfFiles) { -// for (const file of listOfFiles) { -// const content = await fs.readFile(file, "utf-8"); - -// console.log(content); -// } -// } - diff --git a/implement-shell-tools/ls/index.js b/implement-shell-tools/ls/index.js deleted file mode 100644 index c8d962a86..000000000 --- a/implement-shell-tools/ls/index.js +++ /dev/null @@ -1,50 +0,0 @@ -// fs.readdir -import process from "node:process"; -import { promises as fs } from "node:fs"; - - -// `ls -1` -async function showAllFilesInDir(directory) { - const listOfFiles = await fs.readdir(directory); - - for (const eachFile of listOfFiles) { - console.log(eachFile); - } -} - -// `ls -1 sample-files` -async function showVisibleInSampleFiles() { - const listOfFiles = await fs.readdir('sample-files'); - - for (const eachFile of listOfFiles) { - if (eachFile[0] !== '.') { - console.log(eachFile); - } - - } -} - - -// `ls -1 -a sample-files` -async function showAllInSampleFiles() { - const listOfFiles = await fs.readdir('sample-files'); - - for (const eachFile of listOfFiles) { - - console.log(eachFile); - - } -} - - - -const argv = process.argv.slice(2); - -if (argv.includes('-a')) { - await showAllInSampleFiles(); -} else if (argv.includes('sample-files')) { - await showVisibleInSampleFiles(); -} else { - await showCurrentDir(); -} - diff --git a/prep/.DS_Store b/prep/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 List[Laptop]: possible_laptops = [] for laptop in laptops: - if laptop.operating_system == person.preferred_operating_systems: + if laptop.operating_system in person.preferred_operating_systems: possible_laptops.append(laptop) return possible_laptops diff --git a/prep/11.py b/prep/8 laptop program.py similarity index 89% rename from prep/11.py rename to prep/8 laptop program.py index 6a3d9bac7..59a01a63b 100644 --- a/prep/11.py +++ b/prep/8 laptop program.py @@ -19,6 +19,7 @@ from typing import List from collections import Counter import sys +from typing import Tuple class OperatingSystem(Enum): MACOS = "macOS" @@ -46,8 +47,13 @@ def create_a_new_person() -> Person: print("Enter a valid name.", file=sys.stderr) sys.exit(1) - add_age = int(input("What is your age? \n")) - if add_age < 0 or add_age > 100: + str_add_age = input("What is your age? \n") + if not str_add_age.isdigit(): + print("Enter a number.", file=sys.stderr) + sys.exit(1) + add_age = int(str_add_age) + + if add_age <= 0 or add_age > 100: print("Enter a valid age.", file=sys.stderr) sys.exit(1) @@ -60,7 +66,7 @@ def create_a_new_person() -> Person: return Person(name=add_name, age=add_age, preferred_operating_system=OperatingSystem(add_os)) -def find_possible_laptops(laptops: List[Laptop], person: Person) -> List[Laptop]: +def find_possible_laptops(laptops: List[Laptop], person: Person) -> Tuple[List[Laptop], List[Laptop]]: possible_laptops = [] other_laptops = [] for laptop in laptops: @@ -71,11 +77,14 @@ def find_possible_laptops(laptops: List[Laptop], person: Person) -> List[Laptop] return possible_laptops, other_laptops def compare_counts_of_poss_and_others(possible_laptops: List[Laptop], other_laptops: List[Laptop], person: Person) -> None: + if len(other_laptops) == 0: + print("The os you chose has the biggest availability.)") + return # counter to get obj other_laptops_counted_as_obj = Counter(laptop.operating_system for laptop in other_laptops) # and here turn to tuple os+count most_common_laptop = other_laptops_counted_as_obj.most_common(1)[0] - + if len(possible_laptops) < most_common_laptop[1]: # print(f"There are more laptops available with {str(most_common_laptop[0])} than your preferred OS {person.preferred_operating_system.value}. Consider accepting that OS to increase your chances of getting a laptop.") print(f"There are more laptops available with {most_common_laptop[0].value} than your preferred OS {person.preferred_operating_system.value}. Consider accepting that OS to increase your chances of getting a laptop.") @@ -83,9 +92,7 @@ def compare_counts_of_poss_and_others(possible_laptops: List[Laptop], other_lapt print("Your chosen os has the biggest availability.") people = [ - # Person(name="Imran", age=22, preferred_operating_system=OperatingSystem.UBUNTU), - # Person(name="Eliza", age=34, preferred_operating_system=OperatingSystem.ARCH), -] + ] laptops = [ Laptop(id=1, manufacturer="Dell", model="XPS", screen_size_in_inches=13, operating_system=OperatingSystem.ARCH), @@ -95,7 +102,7 @@ def compare_counts_of_poss_and_others(possible_laptops: List[Laptop], other_lapt ] for person in people: - possible_laptops = find_possible_laptops(laptops, person) + possible_laptops, other_laptops = find_possible_laptops(laptops, person) print(f"Possible laptops for {person.name}: {possible_laptops}") diff --git a/prep/12.py b/prep/9 play computer.py similarity index 100% rename from prep/12.py rename to prep/9 play computer.py diff --git a/prep/notes.md b/prep/notes.md deleted file mode 100644 index 1887d3d54..000000000 --- a/prep/notes.md +++ /dev/null @@ -1,39 +0,0 @@ - -def how_many_laptops_match_os(person: Person) -> List[Laptop]: - possible_laptops = [] - for laptop in laptops: - if laptop.operating_system == person.preferred_operating_system: - possible_laptops.append(laptop) - prinet(f"Number of laptops matching your preferred OS: {len(possible_laptops)}") - return possible_laptops - - -# for person in people: -# possible_laptops = find_possible_laptops(laptops, person) -# print(f"Possible laptops for {person.name}: {possible_laptops}") - -# If there is an operating system that has more laptops available, -# tells the user that if they’re willing to accept that operating -# system they’re more likely to get a laptop. - -def get_counts_of_all_laptops_by_os(laptops: List[laptop]) -> dict: - number_of_laptops = {} - - for laptop in laptops: - particular_os = laptop.operating_system - - if particular_os in number_of_laptops: - number_of_laptops[particular_os] += 1 - else: - number_of_laptops[particular_os] = 1 - - return number_of_laptops - -def check_if_there_is_os_with_more_laptops(laptops: List[Laptop], person: Person, possible_laptops: List[Laptop]) -> None: - not_matching_laptop_counts = get_counts_of_all_laptops_by_os(laptops) - - - for laptop in get_counts_of_all_laptops_by_os(laptops): - if laptop.operating_system != person.preferred_operating_system: - not_matching_laptop_counts = get_counts_of_all_laptops_by_os(laptops) - print(f"There are more laptops available with {laptop.operating_system.value} than your preferred OS {person.preferred_operating_system.value}. Consider accepting that OS to increase your chances of getting a laptop.") diff --git a/sprint 5/laptop.py b/sprint 5/laptop.py deleted file mode 100644 index 83eb38522..000000000 --- a/sprint 5/laptop.py +++ /dev/null @@ -1,50 +0,0 @@ -In the prep, there was an exercise around finding possible laptops for a group of people. - -Your exercise is to extend this to actually allocate laptops to the people. - -Given these class definitions: - -from dataclasses import dataclass -from enum import Enum -from typing import List - -class OperatingSystem(Enum): - MACOS = "macOS" - ARCH = "Arch Linux" - UBUNTU = "Ubuntu" - -@dataclass(frozen=True) -class Person: - name: str - age: int - # Sorted in order of preference, most preferred is first. - preferred_operating_system: List[OperatingSystem] - - -@dataclass(frozen=True) -class Laptop: - id: int - manufacturer: str - model: str - screen_size_in_inches: float - operating_system: OperatingSystem -Write a function with this signature: - -def allocate_laptops(people: List[Person], laptops: List[Laptop]) -> Dict[Person, Laptop]: -Every person should be allocated exactly one laptop. - -If we define "sadness" as the number of places down in someone's ranking the -operating system the ended up with (i.e. if your preferences were [UBUNTU, ARCH, MACOS] - -and you were allocated a MACOS machine your sadness would be 2), we want to minimise the total sadness of -all people. If we allocate someone a laptop with an operating system not in their preferred list, treat -them as having a sadness of 100. - -def ranking(): - - -def minimize_sandess(): - - -def allocate_laptops(): - \ No newline at end of file From 61f4c99ce9a59b32a65968de110685e72392e5c5 Mon Sep 17 00:00:00 2001 From: katarzynakaz Date: Wed, 25 Feb 2026 18:04:29 +0000 Subject: [PATCH 4/6] ignore .DS_Store files --- jq/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 jq/.gitignore diff --git a/jq/.gitignore b/jq/.gitignore new file mode 100644 index 000000000..e43b0f988 --- /dev/null +++ b/jq/.gitignore @@ -0,0 +1 @@ +.DS_Store From 597d67509a11eeb890397e014eca5b70b007bb38 Mon Sep 17 00:00:00 2001 From: katarzynakaz Date: Wed, 25 Feb 2026 18:14:26 +0000 Subject: [PATCH 5/6] remove .DS_Store files from repo --- .DS_Store | Bin 12292 -> 0 bytes implement-shell-tools/cat/.DS_Store | Bin 8196 -> 0 bytes prep/.DS_Store | Bin 6148 -> 0 bytes 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store delete mode 100644 implement-shell-tools/cat/.DS_Store delete mode 100644 prep/.DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index a3561d92ce888ddd1db151175e4ac8c1aec3ba4e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12292 zcmeGiTWlLeaOaY?d%ZrcA$`)59ZcIabyX*QQ)pc$fxgm5oHUO<+_Uf696jH;zO&O1 z1;Q7o1tfkzy#FfTqky1L_(I|>AwH^7L4^bo5)zLePzy*%h}m1)O43xQAAzXdwRUG`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ta+>KMO_P%Y~ckJ9XX;bgZSv=WptDZY=esppDsx=$#**XeI zf#5P||DFs1{>NlZfd2p^Dk(dKY;%OBtTahA(K0;O#5YqRe4QaIF5Hiq_CEVL^(2obqQ2z)X#bbC9PZ9E;CG4NYi+Bky<8_?JTeyI?gB{4HZ{EdZ<+Y_|4H@E;md>(2qSQ7BY?{0baRTWy~F!Iy#L1+%>SYL F|1Y2-iPr!C diff --git a/prep/.DS_Store b/prep/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Wed, 25 Feb 2026 18:27:14 +0000 Subject: [PATCH 6/6] trailing lines added, files renamed with _, DS_store removed --- .gitignore | 2 +- "prep/1 double(\"22\").py" => "prep/1_double(\"22\").py" | 2 +- prep/{1 double-bug.py => 1_double_bug.py} | 2 +- prep/{2 type-bugs.py => 2_type_bugs.py} | 2 +- ...py error and is_adult.py => 3_mypy_error_and_is_adult.py} | 2 +- ...4 Person class exercise.py => 4_Person_class_exercise.py} | 2 +- ...4 advantages of methods.py => 4_advantages_of_methods.py} | 2 -- ... dataclass exercise.py => 5_Person_dataclass_exercise.py} | 2 +- prep/{6 fix code.py => 6_fix_code.py} | 2 +- prep/{7 type values fix.py => 7_type_values_fix.py} | 3 ++- prep/{8 laptop program.py => 8_laptop_program.py} | 5 ++--- prep/{9 play computer.py => 9_play_computer.py} | 2 +- 12 files changed, 13 insertions(+), 15 deletions(-) rename "prep/1 double(\"22\").py" => "prep/1_double(\"22\").py" (90%) rename prep/{1 double-bug.py => 1_double_bug.py} (83%) rename prep/{2 type-bugs.py => 2_type_bugs.py} (97%) rename prep/{3 mypy error and is_adult.py => 3_mypy_error_and_is_adult.py} (97%) rename prep/{4 Person class exercise.py => 4_Person_class_exercise.py} (97%) rename prep/{4 advantages of methods.py => 4_advantages_of_methods.py} (99%) rename prep/{5 Person dataclass exercise.py => 5_Person_dataclass_exercise.py} (97%) rename prep/{6 fix code.py => 6_fix_code.py} (96%) rename prep/{7 type values fix.py => 7_type_values_fix.py} (99%) rename prep/{8 laptop program.py => 8_laptop_program.py} (93%) rename prep/{9 play computer.py => 9_play_computer.py} (96%) diff --git a/.gitignore b/.gitignore index 5c11a4432..28f1ba756 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ node_modules -DS_Store \ No newline at end of file +.DS_Store \ No newline at end of file diff --git "a/prep/1 double(\"22\").py" "b/prep/1_double(\"22\").py" similarity index 90% rename from "prep/1 double(\"22\").py" rename to "prep/1_double(\"22\").py" index 0c87a0eff..435054a79 100644 --- "a/prep/1 double(\"22\").py" +++ "b/prep/1_double(\"22\").py" @@ -7,4 +7,4 @@ def double(value): #2222 -print(double("22")) \ No newline at end of file +print(double("22")) diff --git a/prep/1 double-bug.py b/prep/1_double_bug.py similarity index 83% rename from prep/1 double-bug.py rename to prep/1_double_bug.py index 47f644599..21b70b173 100644 --- a/prep/1 double-bug.py +++ b/prep/1_double_bug.py @@ -7,4 +7,4 @@ def double(number): print(double(10)) -#Either call it tripple or * 2 \ No newline at end of file +#Either call it tripple or * 2 diff --git a/prep/2 type-bugs.py b/prep/2_type_bugs.py similarity index 97% rename from prep/2 type-bugs.py rename to prep/2_type_bugs.py index 177f443f7..3e5fa7a9a 100644 --- a/prep/2 type-bugs.py +++ b/prep/2_type_bugs.py @@ -40,4 +40,4 @@ def format_pence_as_string(total_pence): total_pence = sum_balances(balances) total_string = format_pence_as_string(total_pence) # 3.py:39: error: Name "format_pence_as_str" is not defined [name-defined] -print(f"The bank accounts total {total_string}") \ No newline at end of file +print(f"The bank accounts total {total_string}") diff --git a/prep/3 mypy error and is_adult.py b/prep/3_mypy_error_and_is_adult.py similarity index 97% rename from prep/3 mypy error and is_adult.py rename to prep/3_mypy_error_and_is_adult.py index 77589bd73..e0996dddc 100644 --- a/prep/3 mypy error and is_adult.py +++ b/prep/3_mypy_error_and_is_adult.py @@ -30,4 +30,4 @@ def get_eye_colour(person: Person): return person.eye_colour print(get_eye_colour(imran)) -#error in mypy no attribute \ No newline at end of file +#error in mypy no attribute diff --git a/prep/4 Person class exercise.py b/prep/4_Person_class_exercise.py similarity index 97% rename from prep/4 Person class exercise.py rename to prep/4_Person_class_exercise.py index d510ecc90..1bc569f3f 100644 --- a/prep/4 Person class exercise.py +++ b/prep/4_Person_class_exercise.py @@ -24,4 +24,4 @@ def is_adult(self): imran = Person("Imran", date(1988, 10, 10), "Ubuntu") print(imran.is_adult()) imran = Person("Jay", date(2015, 10, 10), "Ubuntu") -print(imran.is_adult()) \ No newline at end of file +print(imran.is_adult()) diff --git a/prep/4 advantages of methods.py b/prep/4_advantages_of_methods.py similarity index 99% rename from prep/4 advantages of methods.py rename to prep/4_advantages_of_methods.py index fb46bf7bb..8afa5b179 100644 --- a/prep/4 advantages of methods.py +++ b/prep/4_advantages_of_methods.py @@ -5,5 +5,3 @@ 3 makes the code more specific and it is easier to understand what it is doing for a junior/learner like me :) 4 reduces errors - - diff --git a/prep/5 Person dataclass exercise.py b/prep/5_Person_dataclass_exercise.py similarity index 97% rename from prep/5 Person dataclass exercise.py rename to prep/5_Person_dataclass_exercise.py index b7b4c8b3d..1f1cf855c 100644 --- a/prep/5 Person dataclass exercise.py +++ b/prep/5_Person_dataclass_exercise.py @@ -27,4 +27,4 @@ def is_adult(self): imran = Person("Imran", date(1988, 10, 10), "Ubuntu") print(imran.is_adult()) imran = Person("Jay", date(2015, 10, 10), "Ubuntu") -print(imran.is_adult()) \ No newline at end of file +print(imran.is_adult()) diff --git a/prep/6 fix code.py b/prep/6_fix_code.py similarity index 96% rename from prep/6 fix code.py rename to prep/6_fix_code.py index 7afa54ab9..c00bae199 100644 --- a/prep/6 fix code.py +++ b/prep/6_fix_code.py @@ -22,4 +22,4 @@ def print_family_tree(person: Person) -> None: for child in person.children: print(f"- {child.name} ({child.age})") -print_family_tree(imran) \ No newline at end of file +print_family_tree(imran) diff --git a/prep/7 type values fix.py b/prep/7_type_values_fix.py similarity index 99% rename from prep/7 type values fix.py rename to prep/7_type_values_fix.py index 50ec943ef..1184f82f1 100644 --- a/prep/7 type values fix.py +++ b/prep/7_type_values_fix.py @@ -57,4 +57,5 @@ def find_possible_laptops(laptops: List[Laptop], person: Person) -> List[Laptop] for person in people: possible_laptops = find_possible_laptops(laptops, person) - print(f"Possible laptops for {person.name}: {possible_laptops}") \ No newline at end of file + print(f"Possible laptops for {person.name}: {possible_laptops}") + \ No newline at end of file diff --git a/prep/8 laptop program.py b/prep/8_laptop_program.py similarity index 93% rename from prep/8 laptop program.py rename to prep/8_laptop_program.py index 59a01a63b..6c98403cc 100644 --- a/prep/8 laptop program.py +++ b/prep/8_laptop_program.py @@ -78,7 +78,7 @@ def find_possible_laptops(laptops: List[Laptop], person: Person) -> Tuple[List[L def compare_counts_of_poss_and_others(possible_laptops: List[Laptop], other_laptops: List[Laptop], person: Person) -> None: if len(other_laptops) == 0: - print("The os you chose has the biggest availability.)") + print("The os you chose has the biggest availability.") return # counter to get obj other_laptops_counted_as_obj = Counter(laptop.operating_system for laptop in other_laptops) @@ -86,7 +86,6 @@ def compare_counts_of_poss_and_others(possible_laptops: List[Laptop], other_lapt most_common_laptop = other_laptops_counted_as_obj.most_common(1)[0] if len(possible_laptops) < most_common_laptop[1]: - # print(f"There are more laptops available with {str(most_common_laptop[0])} than your preferred OS {person.preferred_operating_system.value}. Consider accepting that OS to increase your chances of getting a laptop.") print(f"There are more laptops available with {most_common_laptop[0].value} than your preferred OS {person.preferred_operating_system.value}. Consider accepting that OS to increase your chances of getting a laptop.") else: print("Your chosen os has the biggest availability.") @@ -113,4 +112,4 @@ def execute(): compare_counts_of_poss_and_others(possible_laptops, other_laptops, new_person) -execute() \ No newline at end of file +execute() diff --git a/prep/9 play computer.py b/prep/9_play_computer.py similarity index 96% rename from prep/9 play computer.py rename to prep/9_play_computer.py index 65584651e..139cead21 100644 --- a/prep/9 play computer.py +++ b/prep/9_play_computer.py @@ -37,4 +37,4 @@ def get_full_name(self) -> str: print(person2.get_full_name()) #no full name method person2.change_last_name("Tyurina") #no change last name method print(person2.get_name()) # print Elizaveta Alekseeva -print(person2.get_full_name()) #no full name method so err \ No newline at end of file +print(person2.get_full_name()) #no full name method so err