Building games, one line of code at a time!
Welcome to my Python learning hub! Here I document what I'm learning, share code examples, and provide resources for anyone interested in getting started with Python.
I'm currently working through Harvard's CS50 course, which teaches C first and then transitions to Python. Here's my current focus:
Next up: Object-Oriented Programming (OOP) with classes and inheritance!
Here are some examples of things I've been practicing:
# My first Python program!
name = input("What's your name? ")
print(f"Hello, {name}!")
# Working with numbers
age = int(input("How old are you? "))
years_until_100 = 100 - age
print(f"You'll be 100 in {years_until_100} years.")
# FizzBuzz challenge (classic interview question)
for i in range(1, 101):
if i % 15 == 0:
print("FizzBuzz")
elif i % 3 == 0:
print("Fizz")
elif i % 5 == 0:
print("Buzz")
else:
print(i)
# Shopping list manager
shopping_list = []
while True:
item = input("Add item (or 'done' to finish): ")
if item.lower() == 'done':
break
shopping_list.append(item)
print("\nYour shopping list:")
for i, item in enumerate(shopping_list, 1):
print(f"{i}. {item}")
# Temperature converter
def celsius_to_fahrenheit(celsius):
return (celsius * 9/5) + 32
def fahrenheit_to_celsius(fahrenheit):
return (fahrenheit - 32) * 5/9
temp_c = float(input("Temperature in Celsius: "))
print(f"That's {celsius_to_fahrenheit(temp_c)}°F")
After learning C first, Python feels like a breath of fresh air:
// C version - verbose, manual memory management
#include <stdio.h>
int main() {
int numbers[5] = {1, 2, 3, 4, 5};
for (int i = 0; i < 5; i++) {
printf("%d\n", numbers[i]);
}
return 0;
}
# Python version - clean and simple
numbers = [1, 2, 3, 4, 5]
for num in numbers:
print(num)
Here are the best resources I've found for learning Python:
Here's what I want to accomplish as I continue learning:
I'll be updating this page regularly as I progress on my journey!