Skip to content
Open
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
8 changes: 8 additions & 0 deletions A regular problem
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
animal = 'elephant'
answer = 'nil'
while not answer == 'elephant':
answer = input('Pick a random animal to sneak into your moms trolley. (all lowercase)')
if answer == 'elephant':
print('Fail :(')
else:
print('Success :D')
73 changes: 73 additions & 0 deletions Adventure BP
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import random

def choose_scenario():
return random.randint(1, 2)

def forest_treasure_hunt():
fruits = {"banana", "apple", "strawberry", "blueberry", "orange"}
guessed = set()
while len(guessed) < 5:
guess = input("Guess a fruit: ").lower()
if guess in fruits:
guessed.add(guess)
print("You passed the monkey!")

def cross_river():
height = int(input("Enter height in cm: "))
if height <= 160:
print("You drown.")
return False
if height <= 180:
print("You cross safely.")
return True
print("The tiger spots you.")
return False

def unlock_door():
password = [random.randint(0, 9) for _ in range(4)]
for _ in range(10):
guess = [int(digit) for digit in input("4-digit guess: ")]
if guess == password:
print("Door unlocked!")
return True
correct = sum(a == b for a, b in zip(guess, password))
print(f"Correct digits: {correct}")
print("Failed to unlock.")
return False

def python_quiz():
questions = [
("2 + 3 =", ["4", "5", "6", "7"], "5"),
("Python data type?", ["String", "Integer", "List", "All of the above"], "All of the above"),
("Start a comment?", ["//", "#", "/*", "--"], "#"),
("Define function?", ["define", "function", "def", "func"], "def"),
("Block of code?", ["Indentation", "Braces", "Parentheses", "Quotes"], "Indentation"),
("Invalid variable?", ["var_name", "1var_name", "_varName", "varName1"], "1var_name")
]

correct = sum(
input(f"{q[0]} {', '.join(q[1])}: ") == q[2]
for q in questions
)
print(f"Score: {correct}/6")

def main():
scenario = choose_scenario()
if scenario == 1:
forest_treasure_hunt()
if not cross_river(): return
unlock_door()
else:
python_quiz()

if input("Try the other game? (yes/no): ").strip().lower() == "yes":
if scenario == 1:
python_quiz()
else:
forest_treasure_hunt()
if cross_river():
unlock_door()
print("Goodbye!")

if __name__ == "__main__":
main()
7 changes: 7 additions & 0 deletions Boolean and Operations
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Money = input("How much money you got?")
if Money == 5:
print('Poor!')
elif Money == 15:
print('Average.')
elif Money == 30:
print('What??')
7 changes: 7 additions & 0 deletions Iteration problem
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
for num in range(1,100):
print(num*num)
answer = input("Is this square?")
if answer == "yes"or"Yes":
print("Correct")
else:
print("Wrong")
35 changes: 35 additions & 0 deletions NYT Wordle BP
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import random

def get_feedback(guess, word):
feedback = ""
for i, letter in enumerate(guess):
if letter == word[i]:
feedback += "🟩"
elif letter in word:
feedback += "🟨"
else:
feedback += "⬛️"
return feedback

def play_game():
word = "light"
print("Welcome to Wordle! You have 6 chances to guess a 5-letter word.")

for attempt in range(6):
guess = input(f"Attempt {attempt + 1}/6: ").lower()

if len(guess) != 5 or not guess.isalpha():
print("Invalid guess. Please enter a 5-letter word with letters only.")
continue

feedback = get_feedback(guess, word)
print(feedback)

if guess == word:
print(f"Congratulations! You guessed '{word}' correctly.")
return

print(f"Unfortunate! The word was '{word}'.")

if __name__ == "__main__":
play_game()
16 changes: 16 additions & 0 deletions Number Problem
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Number Problem

def seen_before(numbers):
seen = set()
results = []
for num in numbers:
if num in seen:
results.append("YES")
else:
results.append("NO")
seen.add(num)
return results

# Example usage
numbers = [1, 3, 8, 35, 4, 2, 3]
print("#".join(seen_before(numbers)))
2 changes: 2 additions & 0 deletions Output and Variables
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = 6
print(x-5)
5 changes: 5 additions & 0 deletions Time problem
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def main():
time = int(input("Enter the current time (Range: 0-24): "))
print(["good night.", "good morning.", "good afternoon.", "good evening."][time//6])
if __name__ == "__main__":
main()