100 Days of Code: Recap of Days 1-7
Challenge: 100 Days of Code with Python
Introduction
Welcome to the first-week recap of my 100 Days of Code challenge with Python! Over the past seven days, I've worked on a variety of projects that have helped me enhance my Python skills and gain a deeper understanding of different concepts. Here's a detailed look at what I've accomplished so far.
Day 1: Cyber Guard Name Generator
Project: Cyber Guard Name Generator
Summary: I kicked off the challenge by creating a simple Python script that generates strong and secure-sounding names for cybersecurity firms. This project introduced me to basic Python concepts such as functions, loops, and randomization.
Key Learnings:
Using the
random
module to generate random names.Defining and calling functions.
Using loops to iterate through lists.
Code Example:
import random
adjectives = ["Secure", "Trusted", "Defender", "Guardian"]
nouns = ["Shield", "Protector", "Fortress", "Sentinel"]
def generate_name():
adj = random.choice(adjectives)
noun = random.choice(nouns)
return f"{adj} {noun}"
print(generate_name())
Day 2: Tip Calculator
Project: Tip Calculator
Summary: On Day 2, I built a simple tip calculator that helps users calculate the tip and total bill amount. This project reinforced my understanding of user input, type conversion, and arithmetic operations in Python.
Key Learnings:
Handling user input with the
input()
function.Converting strings to integers and floats.
Performing arithmetic operations.
Code Example:
print("Welcome to the best tip calculator!")
bill = float(input("What was the total bill? $"))
tip = int(input("How much tip would you like to give? 15, 20, or 25? "))
people = int(input("How many people to split the bill?"))
tip_as_percent = tip / 100
total_tip_amount = bill * tip_as_percent
total_bill = bill + total_tip_amount
bill_per_person = total_bill / people
final_amount = round(bill_per_person, 2)
print(f"Each person should pay: ${final_amount}")
Day 3: Cyber-Security-Breach Maze Game
Project: Cyber-Security-Breach Maze Game
Summary: On Day 3, I created a maze game that simulates navigating through a cybersecurity breach. This project involved using nested lists and loops, and it helped me understand how to manage complex data structures in Python.
Key Learnings:
Working with nested lists.
Using loops to navigate through a grid.
Implementing game logic.
Code Example:
maze = [
["#", "#", "#", "#", "#"],
["#", " ", " ", " ", "#"],
["#", " ", "#", " ", "#"],
["#", " ", "#", " ", "#"],
["#", "#", "#", "#", "#"]
]
def display_maze():
for row in maze:
print("".join(row))
display_maze()
Day 4: Rock, Paper, Scissors Game
Project: Rock, Paper, Scissors Game
Summary: I built a Rock, Paper, Scissors game on Day 4. This classic game introduced me to conditional statements and handling user input effectively.
Key Learnings:
Using conditional statements to control the game flow.
Comparing user input with computer-generated choices.
Implementing basic game logic.
Code Example:
import random
choices = ["rock", "paper", "scissors"]
user_choice = input("Choose your weapon! Type rock, paper, or scissors: ").lower()
computer_choice = random.choice(choices)
print(f"Computer chose: {computer_choice}")
if user_choice == computer_choice:
print("It's a draw.")
elif (user_choice == "rock" and computer_choice == "scissors") or \
(user_choice == "paper" and computer_choice == "rock") or \
(user_choice == "scissors" and computer_choice == "paper"):
print("You win!")
else:
print("You lose.")
Day 5: Password Generator
Project: Password Generator
Summary: On Day 5, I developed a password generator that creates strong and secure passwords. This project focused on lists, loops, and the random
module to generate random characters.
Key Learnings:
Creating lists of characters (letters, numbers, symbols).
Using loops to select random characters.
Combining characters to form a password.
Code Example:
import random
letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
numbers = '0123456789'
symbols = '!@#$%^&*()'
def generate_password(length):
all_chars = letters + numbers + symbols
password = ''.join(random.choice(all_chars) for _ in range(length))
return password
print(generate_password(12))
Day 6: Solving Reeborg's World Game Puzzles
Project: Reeborg's World Game Puzzles
Summary: Day 6 was dedicated to solving various puzzles in Reeborg's World. This platform helps practice programming by guiding a robot through different challenges, reinforcing the importance of loops and conditional statements.
Key Learnings:
Using loops to navigate through obstacles.
Implementing functions to control robot actions.
Solving puzzles using logical thinking.
Code Example:
def turn_right():
turn_left()
turn_left()
turn_left()
while not at_goal():
if right_is_clear():
turn_right()
move()
elif front_is_clear():
move()
else:
turn_left()
Day 7: Cybersecurity Hangman Game
Project: Cybersecurity Hangman Game
Summary: On Day 7, I created a Hangman game with a focus on cybersecurity terms. This project was fun and educational, helping me understand game logic and user interaction.
Key Learnings:
Using lists to manage the game state.
Implementing game logic with loops and conditionals.
Enhancing the user experience with ASCII art.
Code Example:
import random
from hangman_words import word_list
from hangman_art import logo, stages
print(logo)
chosen_word = random.choice(word_list)
word_length = len(chosen_word)
display = ["_"] * word_length
end_of_game = False
lives = 6
while not end_of_game:
guess = input("Guess a letter: ").lower()
if guess in display:
print(f"You've already guessed {guess}")
else:
for position in range(word_length):
if chosen_word[position] == guess:
display[position] = guess
if guess not in chosen_word:
lives -= 1
if lives == 0:
end_of_game = True
print("You lose.")
print(" ".join(display))
if "_" not in display:
end_of_game = True
print("You win.")
print(stages[lives])
Conclusion
The first week of my 100 Days of Code challenge has been an exciting journey, filled with learning and hands-on practice. Each project has helped me build a solid foundation in Python and develop essential coding skills. I'm looking forward to the upcoming days and the new challenges they'll bring. Stay tuned for more updates!
Stay Connected
Follow my progress and join me on this coding journey:
Happy coding!