From 9b0fcc5a4480c79e2c57821314c06f9f1542b45e Mon Sep 17 00:00:00 2001 From: talita Date: Tue, 14 Jul 2026 15:16:55 -0400 Subject: [PATCH 1/2] Complete Assignment 2: Warmups and Mini-Project --- week-2/assignment-2/mini_project.py | 5 +++++ week-2/assignment-2/warmup1.py | 4 ++++ week-2/assignment-2/warmup2.py | 6 ++++++ week-2/assignment-2/warmup3.py | 2 ++ week-2/assignment-2/warmup4.py | 8 ++++++++ 5 files changed, 25 insertions(+) create mode 100644 week-2/assignment-2/mini_project.py create mode 100644 week-2/assignment-2/warmup1.py create mode 100644 week-2/assignment-2/warmup2.py create mode 100644 week-2/assignment-2/warmup3.py create mode 100644 week-2/assignment-2/warmup4.py diff --git a/week-2/assignment-2/mini_project.py b/week-2/assignment-2/mini_project.py new file mode 100644 index 0000000..7c35138 --- /dev/null +++ b/week-2/assignment-2/mini_project.py @@ -0,0 +1,5 @@ +temp_input = float(input("Enter a temperature in Fahrenheit: ")) + +celsius = (temp_input - 32) * 5 / 9 + +print(f"The temperature in celsius is {celsius:.1f}") \ No newline at end of file diff --git a/week-2/assignment-2/warmup1.py b/week-2/assignment-2/warmup1.py new file mode 100644 index 0000000..2ba24a8 --- /dev/null +++ b/week-2/assignment-2/warmup1.py @@ -0,0 +1,4 @@ +# Command used: python3 warmup1.py +# Output: Python is working! + +print("Python is working!") \ No newline at end of file diff --git a/week-2/assignment-2/warmup2.py b/week-2/assignment-2/warmup2.py new file mode 100644 index 0000000..1367621 --- /dev/null +++ b/week-2/assignment-2/warmup2.py @@ -0,0 +1,6 @@ +# Commands used: mkdir {foldernames}, touch {filename.py}, cd week-2/assignment-2 + + +today_date = input("What's today's date? ") + +print(f" Today is {today_date}") \ No newline at end of file diff --git a/week-2/assignment-2/warmup3.py b/week-2/assignment-2/warmup3.py new file mode 100644 index 0000000..c1b9a4d --- /dev/null +++ b/week-2/assignment-2/warmup3.py @@ -0,0 +1,2 @@ +# git log --oneline output: +# 21a8d02 (HEAD -> assignment-2) Add warmup structure folders & designated files \ No newline at end of file diff --git a/week-2/assignment-2/warmup4.py b/week-2/assignment-2/warmup4.py new file mode 100644 index 0000000..6d39751 --- /dev/null +++ b/week-2/assignment-2/warmup4.py @@ -0,0 +1,8 @@ +# What the error message is: +# print(f"Hi, {name}") NameError: name 'name' is not defined +# What caused it: not defining the variable name before using it. +# How you fixed it: assigned a value to the variable name + +name = input("What is your name? ") + +print(f"Hi, {name}") \ No newline at end of file From abb0fe91f32a1e10ebd520fb5e1306ee35a62b2b Mon Sep 17 00:00:00 2001 From: talita Date: Tue, 4 Aug 2026 21:54:11 -0400 Subject: [PATCH 2/2] Add assignment 5: iteration and algorithms Warmup exercises cover a for-loop sum, while-loop input validation, linear search, and FizzBuzz. Mini project is a menu-driven number cruncher with hand-rolled min/max, linear search, and bubble sort. --- week-5/assignment-5/mini_project.py | 56 +++++++++++++++++++++++++++++ week-5/assignment-5/warmup1.py | 5 +++ week-5/assignment-5/warmup2.py | 8 +++++ week-5/assignment-5/warmup3.py | 14 ++++++++ week-5/assignment-5/warmup4.py | 9 +++++ 5 files changed, 92 insertions(+) create mode 100644 week-5/assignment-5/mini_project.py create mode 100644 week-5/assignment-5/warmup1.py create mode 100644 week-5/assignment-5/warmup2.py create mode 100644 week-5/assignment-5/warmup3.py create mode 100644 week-5/assignment-5/warmup4.py diff --git a/week-5/assignment-5/mini_project.py b/week-5/assignment-5/mini_project.py new file mode 100644 index 0000000..6d21aee --- /dev/null +++ b/week-5/assignment-5/mini_project.py @@ -0,0 +1,56 @@ +numbers = [42, 17, 83, 5, 61, 29, 74, 8, 55, 93, 31, 66, 14, 47, 78, 3, 59, 22, 86, 40] + +while True: + print("=== Number Cruncher ===") + print("1. Find minimum") + print("2. Find maximum") + print("3. Search for a number") + print("4. Sort the list") + print("5. Quit") + choice = input("Choose an option (1-5): ") + + if choice == "1": + smallest = numbers[0] + for number in numbers: + if number < smallest: + smallest = number + print(f'Minimum: {smallest}') + + elif choice == "2": + largest = numbers[0] + for number in numbers: + if number > largest: + largest = number + print(f'Maximum: {largest}') + + elif choice == "3": + target = int(input("Enter a number to search for: ")) + found_index = -1 + for i in range(len(numbers)): + if numbers[i] == target: + found_index = i + break + + if found_index == -1: + print(f'{target} was not found in the list.') + else: + print(f'Found {target} at index {found_index}.') + + elif choice == "4": + swapped = True + while swapped: + swapped = False + for i in range(len(numbers) - 1): + if numbers[i] > numbers[i + 1]: + numbers[i], numbers[i + 1] = numbers[i + 1], numbers[i] + swapped = True + print(f'Sorted list: {numbers}') + + elif choice == "5": + print("Goodbye!") + break + + else: + print("That's not a valid option. Try again.") + + print() diff --git a/week-5/assignment-5/warmup1.py b/week-5/assignment-5/warmup1.py new file mode 100644 index 0000000..9d448f8 --- /dev/null +++ b/week-5/assignment-5/warmup1.py @@ -0,0 +1,5 @@ +total = 0 +for number in range(1, 101): + total += number + +print(f'The sum of 1 to 100 is {total}.') diff --git a/week-5/assignment-5/warmup2.py b/week-5/assignment-5/warmup2.py new file mode 100644 index 0000000..d7dfbe6 --- /dev/null +++ b/week-5/assignment-5/warmup2.py @@ -0,0 +1,8 @@ +while True: + user_input = input("Enter a positive integer: ") + + if user_input.isdigit() and int(user_input) > 0: + print(f'Got it: {int(user_input)}') + break + + print("That's not a positive integer. Try again.") diff --git a/week-5/assignment-5/warmup3.py b/week-5/assignment-5/warmup3.py new file mode 100644 index 0000000..d89a5a8 --- /dev/null +++ b/week-5/assignment-5/warmup3.py @@ -0,0 +1,14 @@ +names = ["Aiko", "Devon", "Priya", "Marcus", "Sara", "Luis", "Mia"] + +search_name = input("Enter a name to search for: ") + +found_index = -1 +for i in range(len(names)): + if names[i] == search_name: + found_index = i + break + +if found_index == -1: + print(f'"{search_name}" was not found in the list.') +else: + print(f'Found "{search_name}" at index {found_index}.') diff --git a/week-5/assignment-5/warmup4.py b/week-5/assignment-5/warmup4.py new file mode 100644 index 0000000..81e13ca --- /dev/null +++ b/week-5/assignment-5/warmup4.py @@ -0,0 +1,9 @@ +for number in range(1, 31): + if number % 3 == 0 and number % 5 == 0: + print("FizzBuzz") + elif number % 3 == 0: + print("Fizz") + elif number % 5 == 0: + print("Buzz") + else: + print(number)