Skip to content

Introduction to Python

Run the hidden code cell below to import the data used in this course.

Slicing list

The start index will be included, while the end index is not.

# Create the areas list
areas = ["hallway", 11.25, "kitchen", 18.0, "living room", 20.0, "bedroom", 10.75, "bathroom", 9.50]

# Use slicing to create downstairs
downstairs = areas[0:6]

# Use slicing to create upstairs
upstairs = areas[6:10]

# Print out downstairs and upstairs
print(downstairs)
print(upstairs)
import random

cipher_text = "_2A7$zZ3L:BEwzfjh*Bq~?V8vzv\"2-/Q,au\"W}5kuLjv@f)r'r7rp_zqeiIv6JO#Azeyf"
SEED = 145556

# Step 1: Generate a pseudo-random sequence using the seed
random.seed(SEED)
key_stream = [random.randint(0, 255) for _ in range(len(cipher_text))]

# Step 2: Reverse the Equinox transformation (assuming XOR-based encryption)
decoded_bytes = [ord(c) ^ k for c, k in zip(cipher_text, key_stream)]

# Step 3: Convert the bytes to characters
decoded_text = ''.join(chr(b) for b in decoded_bytes)

# Step 4: Filter out non-printable characters
import string
readable_text = ''.join(c for c in decoded_text if c in string.printable)

print("Decoded Text:", readable_text)
# Given partially decoded text
decoded_text = "/i824\\-\t]k5\\xV<#-gG1(sH2o#=FH4"

# Try shifting characters forward and backward to see if a pattern emerges
shifted_texts = {}

for shift in range(-5, 6):  # Try shifts from -5 to +5
    shifted_text = ''.join(chr(ord(c) + shift) if c.isprintable() else c for c in decoded_text)
    shifted_texts[shift] = shifted_text

# Output possible shifted texts
shifted_texts