Reflection
Q&A
- a. This is why I know my units: I learned the basics of Python and Javascript programming by reading and listening to the course websites written by each team.
- b. This is how I build a summary in my blog that show how I know or how I will review: I keep a notebook (.ipynb) of what I felt and what I struggled with while writing the course, because it allows me to view the code as well as the text, which helps me to review what Iāve learned.
- c. This is how you know I am more than be perfunctory on my learning journey: After listening to the presentations of my classmates, we were required to do popcorn hacks and homework hacks, which were full of creative topics that made me need to further understand and analyze what they had said and design unique codes based on it.
- d. Here are some memories from my homework, learning, and teaching: The group spent a week creating lessons and collaborating on teaching. If you have trouble with an assignment, ask the group in charge of that section to discuss it and work together to improve.
- e. This is how you know my work is distinctive, unique and genuine:
I used different fonts and colors and emoji to create the course website to make it more personalized and to show the key points clearly. I divided the assignments and lectures into two modules to make the structure more concise.
New Skills
- Making a notebook Blog: I learned how to make notebooks by editing .ipynb files.
- Styling: I learned how to change the font and add
Conclusion
- I gained a solid foundation in Python and JavaScript programming by reading and listening to the course materials created by each team. The structured lessons helped me systematically understand the core concepts of these programming languages. Additionally, I kept an interactive notebook (ipynb) to summarize my learning, where I not only documented the code I wrote but also noted my thoughts and struggles along the way. This method allowed me to review both text and code simultaneously, making it easier to revisit what lāve learned. You can see that Iām more than just going through the motions in my learning journey. After listening to my classmate presentations, we engaged in āpopcorn hacksā and āhomework hacks,ā which were filled with creative challenges. These activities pushed me to think critically and design unique code solutions. Reflecting on our group work, we spent a week creating lessons and collaborating on teaching. Whenever someone had difficulties with an assignment, we would consult the group responsible, discuss the problem, and work together to improve. This collaborative approach not only enhanced my learning but also deepened my appreciation for teamwork. My work is also distinctive and personalized. I used different fonts, colors, and emojis to make my course website more engaging, and I divided the assignments and lessons into two modules to create a clearer structure, I also learned how to edit ipynb files, which allowed me to further personalize and style my notes
3.1
Popcorn Hacks
username = input("What is your username?")
user_age = input("What is your age?")
user_city = input("Which city do you live in?")
user_info_list = [username, user_age, user_city]
user_info_dict = {
"username": username,
"age": user_age,
"city": user_city
}
print(user_info_list)
print(user_info_dict)
print("Hi, my name is " + username + ", I'm " + user_age + " years old," + ", and I live in " + user_city + ".")
Homework Hacks
let nameParts = fullName.split(" ");
let initials = nameParts[0][0] + nameParts[0][1];
let randomNum = Math.floor(Math.random() * 100);
let uniqueId = initials + randomNum;
let personInfo = {
fullName: fullName,
age: age,
email: email,
hobby: hobby,
dietaryPreferences: dietaryPreferences,
uniqueId: uniqueId
};
console.log("Personal Info:");
console.log(`- Full Name: ${personInfo.fullName}`);
console.log(`- Age: ${personInfo.age}`);
console.log(`- Email: ${personInfo.email}`);
console.log(`- Hobby: ${personInfo.hobby}`);
console.log(`- Dietary Preferences: ${personInfo.dietaryPreferences}`);
console.log(`- Unique ID: ${personInfo.uniqueId}`);
3.2
Hacks #1
physics_topics = {
"Mechanics": [
"Newton's Laws",
"Work, Energy, and Power",
"Circular Motion",
"Momentum and Impulse"
],
"Electromagnetism": [
"Coulomb's Law",
"Electric Fields",
"Magnetic Fields",
"Electromagnetic Induction"
],
"Thermodynamics": [
"Laws of Thermodynamics",
"Heat Transfer",
"Carnot Cycle",
"Entropy"
],
"Optics": [
"Reflection and Refraction",
"Lenses and Mirrors",
"Interference and Diffraction",
"Polarization"
],
}
for topic, subtopics in physics_topics.items():
print(f"\n{topic}:")
for subtopic in subtopics:
print(f" - {subtopic}")
Hacks #2
website = {
'About': ['Homwtown', 'Favorite Food', 'Music Taste'],
'Game': ['Snake', 'Cookie Clicker']
}
print(['About'])
if "Hometown" in website['About']:
print(True)
else:
print(False)
Hacks #3
ice_cream_log = [
{
"flavor": "Chocolate",
"price": 15.0,
"date": "2024-10-01",
"shop": "BQ"
},
{
"flavor": "Strawberry",
"price": 12.5,
"date": "2024-10-03",
"shop": "HƤagen-Dazs"
},
{
"flavor": "Vanilla",
"price": 16,
"date": "2024-10-05",
"shop": "Venchi"
}
]
for record in ice_cream_log:
print(f"Date: {record['date']}")
print(f"Flavor: {record['flavor']}")
print(f"Price: ${record['price']}")
print(f"Shop: {record['shop']}")
print("\n")
Homework
ice_cream_flavors = [
{
"flavor": "Chocolate",
"calories_per_serving": 210,
"price": 3.50,
"ingredients": ["cocoa", "sugar", "cream"],
"is_dairy_free": False,
"origin": ("France", 1900),
"toppings": {"sprinkles", "nuts", "whipped cream"},
"seasonal": None
},
{
"flavor": "Strawberry",
"calories_per_serving": 180,
"price": 3.00,
"ingredients": ["strawberries", "sugar", "cream"],
"is_dairy_free": False,
"origin": ("USA", 1851),
"toppings": {"fresh fruit", "granola"},
"seasonal": "Summer"
},
{
"flavor": "Mango Sorbet",
"calories_per_serving": 150,
"price": 4.00,
"ingredients": ["mango puree", "sugar", "water"],
"is_dairy_free": True,
"origin": ("India", None),
"toppings": {"mint leaves", "lime zest"},
"seasonal": None
}
]
for flavor in ice_cream_flavors:
print(f"Flavor: {flavor['flavor']}")
print(f"Calories per Serving: {flavor['calories_per_serving']}")
print(f"Price: ${flavor['price']:.2f}")
print(f"Ingredients: {', '.join(flavor['ingredients'])}")
print(f"Dairy Free: {flavor['is_dairy_free']}")
print(f"Origin: {flavor['origin'][0]} ({flavor['origin'][1]})")
print(f"Toppings: {', '.join(flavor['toppings'])}")
print(f"Seasonal: {flavor['seasonal']}\n")
3.3
Popcorn Hacks
def output(x):
print(7* x + 22)
number1 = 8
number2 = 3
number3 = number1 % number2
number4 = number3 * number1 + 70
print(number4)
num4 = 86
numbers = [4, 7, 8, 12]
for num in numbers:
remainder = num % 3
if remainder == 0:
print(num, "is divisible by 3")
else:
print("The remainder when", num, "is divided by 3 is", remainder)
Homework
import math
def volume_rectangular_prism(base, width, height):
return base * width * height
def volume_sphere(radius):
return (4/3) * math.pi * radius**3
def volume_pyramid(base, width, height):
return (1/3) * base * width * height
# Examples:
# Rectangular Prism
base = 5
width = 6
height = 10
print(f"Volume of rectangular prism: {volume_rectangular_prism(base, width, height)}")
# Sphere
radius = 6
print(f"Volume of sphere: {volume_sphere(radius)}")
# Pyramid
base = 4
width = 4
height = 9
print(f"Volume of pyramid: {volume_pyramid(base, width, height)}")
3.4
Python Hacks
1: String Analyzation Determine metrics about strings (length, chars, palidrome(?), etc.)
# Function to analyze string metrics
def analyze_string(input_string):
# Length of string
length = len(input_string)
# Vowel count
vowels = 'aeiouAEIOU'
vowel_count = sum(1 for char in input_string if char in vowels)
# Character frequency count (ignores spaces)
char_frequency = {}
for char in input_string.replace(" ", ""):
char_frequency[char] = char_frequency.get(char, 0) + 1
# Check if string is a palindrome (ignores spaces and case)
is_palindrome = input_string.replace(" ", "").lower() == input_string.replace(" ", "").lower()[::-1]
# Display results
print(f"String: {input_string}")
print(f"Length: {length}")
print(f"Vowel Count: {vowel_count}")
print(f"Character Frequency: {char_frequency}")
print(f"Palindrome or Not? {'Yes' if is_palindrome else 'No'}")
# Test the function with a sample string
test_string = "Icecream tastes good"
analyze_string(test_string)
2: Password Validator The goal of this homework hack is to create a password validator. A couple examples are given below (Simple and Advanced)
import string
def password_validator(password):
# Check for minimum length of 8 characters
if len(password) < 8:
return "Password too short. Must be at least 8 characters."
# Check for both uppercase and lowercase letters
if password == password.lower() or password == password.upper():
return "Password must contain both uppercase and lowercase letters."
# Check for at least one digit
if not any(char.isdigit() for char in password):
return "Password must contain at least one number."
# Check for at least one special character
special_characters = string.punctuation
if not any(char in special_characters for char in password):
return "Password must contain at least one special character."
# Optional customization: Replace "123" with "abc" if present
customized_password = password.replace("123", "abc")
# Further customize by adding dashes between words (assuming password is space-separated)
words = customized_password.split(" ")
customized_password = "-".join(words)
return f"Password is valid! Hereās a customized version: {customized_password}"
# Test cases
print(password_validator("HelloWorld123!")) # Should be valid
print(password_validator("HELLO123")) # No lowercase letters
print(password_validator("helloworld123")) # No uppercase letters
print(password_validator("Hello123")) # No special characters
Popcorn Hacks
function analyzeString(inputString) {
console.log("Analyzing String: " + inputString);
const length = inputString.length;
console.log("Length: " + length);
const upperCaseString = inputString.toUpperCase();
const lowerCaseString = inputString.toLowerCase();
console.log("Uppercase: " + upperCaseString);
console.log("Lowercase: " + lowerCaseString);
const slicedString = inputString.slice(0, 5);
console.log("Sliced (first 5 chars): " + slicedString);
const substring = "fun";
const index = inputString.indexOf(substring);
console.log("Position of '" + substring + "': " + index);
console.log("");
}
const testString = "I love icecream!";
analyzeString(testString);
JavaScript Homework Hacks
function isValidPassword(password) {
const minLength = 6;
const hasUpperCase = /[A-Z]/.test(password);
const hasLowerCase = /[a-z]/.test(password);
const hasNumbers = /[0-9]/.test(password);
const hasSpecialChars = /[!@#$%^&*(),.?":{}|<>]/.test(password);
const isCommonPassword = checkCommonPassword(password);
if (password.length < minLength) {
console.log("Password must be at least " + minLength + " characters long.");
return false;
}
if (!hasUpperCase) {
console.log("Password must contain at least one uppercase letter.");
return false;
}
if (!hasLowerCase) {
console.log("Password must contain at least one lowercase letter.");
return false;
}
if (!hasNumbers) {
console.log("Password must contain at least one number.");
return false;
}
if (!hasSpecialChars) {
console.log("Password must contain at least one special character.");
return false;
}
if (isCommonPassword) {
console.log("Password is too common. Please choose a different password.");
return false;
}
console.log("Password is valid!");
return true;
}
3.5
Popcorn Hacks
# Check if a single boolean is true
def check_if_true(variable):
if variable:
print("The variable is true!")
else:
print("The variable is false!")
# Example usage:
variableA = True
check_if_true(variableA)
# Check if both are true or if either is true
def check_both_or_either(variableA, variableB):
if variableA and variableB:
print("Both variableA and variableB are true!")
elif variableA or variableB:
print("Either variableA or variableB is true!")
else:
print("Neither variableA nor variableB is true.")
# Example usage:
variableA = True
variableB = False
check_both_or_either(variableA, variableB)
number = 15
if number > 10:
print("number is greater than ten!")
else:
print("number is not greater than ten!")
if number >= 100 and number <= 999:
print("number is three digits!")
else:
print("number is not three digits!")
Homework
def de_morgan_law():
print("A B !(A and B) == (!A or !B) !(A or B) == (!A and !B)")
values = [False, True]
for A in values:
for B in values:
result1 = not (A and B) == (not A or not B) # De Morgan's 1st Law
result2 = not (A or B) == (not A and not B) # De Morgan's 2nd Law
print(f"{A} {B} {result1} {result2}")
de_morgan_law()
result:
A B !(A and B) == (!A or !B) !(A or B) == (!A and !B)
False False True True
False True True True
True False True True
True True True True
3.6
Homework
def compare_numbers():
num1 = float(input("first number: "))
num2 = float(input("second number: "))
if num1 == num2:
print("The numbers are equal.")
else:
if num1 > num2:
print(f"The larger number is: {num1}")
else:
print(f"The larger number is: {num2}")
compare_numbers()
3.7
Homework
1: Determine if a Student Passes a Class
```python
IF exam_score >= 60
{
IF attendance_percentage >= 75
{
DISPLAY "Student passes the class"
}
ELSE
{
DISPLAY "Student fails due to low attendance"
}
}
ELSE
{
DISPLAY "Student fails due to low exam score"
}
2: Write a python segment to decide the shipping cost based on the weight of a package and the delivery speed chosen (standard or express) using nested conditionals.
weight = 10 # in kg
speed = "express" # can be "standard" or "express"
if weight <= 5:
if speed == "standard":
print("Shipping cost is $5")
else:
print("Shipping cost is $10")
else:
if speed == "standard":
print("Shipping cost is $8")
else:
print("Shipping cost is $15")
3: Write a python segment to have different ticket prices for different ages, with a discount for students
age = 22 # age of the person
is_student = True # True or False depending on student status
if age < 13:
print("Ticket price is $5")
elif age < 19:
print("Ticket price is $8")
else:
if is_student:
print("Ticket price is $10 (student discount)")
else:
print("Ticket price is $15")
challenge
a = float(input("Enter side a: "))
b = float(input("Enter side b: "))
c = float(input("Enter side c: "))
if a > 0 and b > 0 and c > 0:
if a + b > c and a + c > b and b + c > a:
if a == b == c:
print("This is an equilateral triangle.")
elif a == b or b == c or a == c:
print("This is an isosceles triangle.")
else:
print("This is a scalene triangle.")
else:
print("The given sides do not form a valid triangle.")
else:
print("All sides must be positive numbers.")
3.8
Popcorn Hacks
#1
ticket_price1 = 10.00
age = int(input("Please enter your age: "))
if age <= 12:
ticket_price = ticket_price1 * 0.5
print(f"Child ticket price: ${ticket_price:.2f}")
elif age <= 63:
ticket_price = ticket_price1
print(f"Adult ticket price: ${ticket_price:.2f}")
else:
ticket_price = ticket_price1 * 0.7
print(f"Senior ticket price: ${ticket_price:.2f}")
has_ticket = input("Do you have a ticket? (yes/no): ").lower() == "yes"
if has_ticket:
while True:
is_student = input("Are you a student? (yes/no): ").lower()
if is_student == "yes":
student_discount = 0.20
final_price = ticket_price * (1 - student_discount)
print(f"You are eligible for a student discount! The ticket price is now: ${final_price:.2f}")
break
elif is_student == "no":
print(f"No student discount applied. The ticket price is: ${ticket_price:.2f}")
break
else:
print('Invalid response. Please answer with "yes" or "no".')
else:
print("You need a ticket to enter.")
#2
try:
num = int(input("Enter a number: "))
result = 10 / num
print("Result:", result)
except ValueError:
print("That's not a valid number")
except ZeroDivisionError:
print("0 can't be put in")
else:
print("success")
if num % 2 == 0:
print(f"The number {num} is even.")
else:
print(f"The number {num} is odd.")
Homework
def get_positive_number():
while True:
try:
num = float(input("Please enter a positive number: "))
if num > 0:
print(f"Success! You entered: {num}")
break
else:
print("Try again. The number has to be positive.")
except ValueError:
print("Error! That's not a valid number. Please enter a number.")
get_positive_number()
3.10
Popcorn Hacks 1
my_list = ['pepperoni', 'cheese', 'pinapple']
my_list.append('basil')
print(my_list)
Popcorn Hacks 2
alist = ['pepperoni', 'cheese', 'pinapple']
alist.insert('cheese', 'a')
alist = ['pepperoni', 'cheese', 'pinapple']
alist.remove('pinnaple')
print(alist)
Popcorn Hacks 3
alist = ['pepperoni', 'cheese', 'pinapple']
alist[1] = 'mushroom'
print(alist)
Homework
nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
even_sum = 0
for score in nums:
if score % 2 == 0:
even_sum += score
print("Sum of even numbers in the list:", even_sum)
nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
min_value = min(nums)
max_value = max(nums)
print("Minimum value:", min_value)
print("Maximum value:", max_value)