Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions week-2/assignment-2/mini_project.py
Original file line number Diff line number Diff line change
@@ -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}")
4 changes: 4 additions & 0 deletions week-2/assignment-2/warmup1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Command used: python3 warmup1.py
# Output: Python is working!

print("Python is working!")
6 changes: 6 additions & 0 deletions week-2/assignment-2/warmup2.py
Original file line number Diff line number Diff line change
@@ -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}")
2 changes: 2 additions & 0 deletions week-2/assignment-2/warmup3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# git log --oneline output:
# 21a8d02 (HEAD -> assignment-2) Add warmup structure folders & designated files
8 changes: 8 additions & 0 deletions week-2/assignment-2/warmup4.py
Original file line number Diff line number Diff line change
@@ -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}")
56 changes: 56 additions & 0 deletions week-5/assignment-5/mini_project.py
Original file line number Diff line number Diff line change
@@ -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()
5 changes: 5 additions & 0 deletions week-5/assignment-5/warmup1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
total = 0
for number in range(1, 101):
total += number

print(f'The sum of 1 to 100 is {total}.')
8 changes: 8 additions & 0 deletions week-5/assignment-5/warmup2.py
Original file line number Diff line number Diff line change
@@ -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.")
14 changes: 14 additions & 0 deletions week-5/assignment-5/warmup3.py
Original file line number Diff line number Diff line change
@@ -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}.')
9 changes: 9 additions & 0 deletions week-5/assignment-5/warmup4.py
Original file line number Diff line number Diff line change
@@ -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)