Skip to the content.

Team Teach Reflections • 9 min read

my favorite popcorn/hw hacks from each lesson

# iterations
while True:
    user_input = input("Enter something (type 'exit' to quit): ")
    if user_input == "exit":
        break
    print("You entered:", user_input)
You entered: jayden is cool

Iterations keep a program doing something over and over, in this case, bugging the user for input until they finally give in and type ‘exit,’ which keeps the interaction going.

# variables

# Variable 1
numstudents = 26
print(numstudents)

# Variable 2

car = "Tesla"
print(car)

# Variable 3

groupMates = ("Nikki", "Monike", "Ankit", "Varun")
print(groupMates)

# Variable 4

dogsbeatcats = True
print(dogsbeatcats)



# Variable 1

Age = 16
print(Age)

# Variable 2

car = "lexus"
print(car)

# Variable 3

favoritecandy = ["100 Grand", "Swedish Fish", "Twix", "Hershey"]

import json
lst = [favoritecandy]
print(type(lst))
favoritecandy = json.dumps(lst)
print(favoritecandy)
print(type(favoritecandy))

# Variable 4

Jaydeniscool = True
print(Jaydeniscool)
16
lexus
<class 'list'>
[["100 Grand", "Swedish Fish", "Twix", "Hershey"]]
<class 'str'>
True

Variables are like containers that hold different pieces of information in code, allowing you to store and manipulate data, making programs flexible and dynamic.

# Algorithms

thing1 = "Jayden "
thing2 = "Chen"
result = thing1 + thing2
print(result)

word1 = "Jayden "
word2 = "Chen "
word3 = "is "
word4 = "cool."
sentence = word1 + word2 + word3 + word4
print(sentence)
stringLength = len(sentence)
print(f"The sentence length is {stringLength} characters.")
Jayden Chen
Jayden Chen is cool.
The sentence length is 20 characters.

Algorithms are responsible for providing step-by-step instructions for solving problems and performing tasks efficiently and consistently.

# booleons

temperature = 19
weather = "stormy"
result = temperature > 20 and weather == "stormy"
print(result)
if result == True:
    print("go outside stinky pants")
else:
    print("stay at home pookie bear")
False
stay at home pookie bear

Booleans are the digital decision-makers of code, enabling it to make choices, evaluate conditions, and control the flow of programs by representing true or false values.

# Developing Algorithms
list = [50, 30, 70, 40, 60]
mean = sum(list) / len(list)
print("mean", mean)

sortedlist = sorted(list)
n = len(sortedlist)
if n % 2 == 0:
    median = (sortedlist[n // 2 - 1] + sortedlist[n // 2]) / 2
else:
    median = sortedlist[n // 2]
print("Median:", median)
mean 50.0
Median: 50
# list
nums = [30, 45, 95, 56, 73, 98, 25]
min_value = nums[4]  # Start with the first element as the minimum

for score in nums:
    if score < min_value:
            min_value = score


print(min_value)  # Display the minimum value
25

Lists allow you to group and organize multiple items, making it easier to work with collections of data.

# developing procedures
def updateweather(currentweather, weather):
    if currentweather> weather:
        weather = currentweather
        print("today is warmer than yesterday")
    else:
        print("today is colder than yesterday")
    return currentweather

currentweather = 71
weather = 66
currentgrade = updateweather(currentweather, weather)
print("the temperature right now is", currentweather, "degrees")
today is warmer than yesterday
the temperature right now is 71 degrees

Procedures are like pre-defined sets of instructions in code, simplifying complex tasks by breaking them down into manageable, reusable chunks of functionality.

# Libraries
from math import factorial
num = 4
print(factorial(num))
24

Libraries import bunches pre-written code in programming, offering a ton of functions and tools that help developers save time

# simulations
import random

def roll_die():
    # Gives random integer between 1 and 6
    return random.randint(1, 100)

# Defines the variable "result" as the result of function roll_die()
result = roll_die()
print("Your random number is:", result)
Your random number is: 16

Simulations mimick real-world scenarios and events to analyze, test, and predict outcomes, making them valuable tools for research and problem-solving.