DEV Community

Abdulla Ansari
Abdulla Ansari

Posted on • Edited on

Day 2: Some Amaging Programs in Python | 100 Days Python

Day-1: Installing Python in Different OS | 100 Days Python

Are you ready to dive deep into Python and discover the power of programming beyond theory? I want to share a journey that took me from the basics of C and C++ in college to real-world Python projects that are fun, interactive, and valuable in industry. This article gives you a sneak peek into some amazing projects we'll build together in my 100 Days of Code series. From virtual assistants to classic games, these projects highlight how Python can transform simple code into practical, engaging applications.


Getting Started with Python in Real Life

In my second year of college, I mastered C and C++ concepts and built several logic-based projects. However, I struggled to find industry opportunities because of limited project exposure and a mismatch with industry demands. It wasn’t until I discovered Python that I realized the versatility and industry relevance of programming.

Python, with its simple syntax and robust libraries, opened new doors for me. I started doing freelance work like web scraping, creating GUIs, and building Flask applications. These projects were my first taste of how impactful programming could be. Today, I want to introduce you to some projects that showcase the real power of Python.

Project Highlights: What You’ll Learn in This Series

In this 100 Days of Code series, we’ll work on projects that take Python from a basic scripting language to a powerful tool for solving real-world problems. Below, I’ve highlighted five key projects we’ll build together.


1. Jarvis: A Virtual Assistant

One of our standout projects will be Jarvis, a virtual assistant that listens to your commands and performs tasks like opening Google, YouTube, and other applications. It’s similar to the voice assistants we use every day but customized to your own requirements.

# Basic code snippet for voice commands in Jarvis
import pyttsx3
import speech_recognition as sr
import webbrowser

# Initialize text-to-speech engine
engine = pyttsx3.init()

def speak(audio):
    engine.say(audio)
    engine.runAndWait()

def take_command():
    r = sr.Recognizer()
    with sr.Microphone() as source:
        print("Listening...")
        r.adjust_for_ambient_noise(source)
        audio = r.listen(source)
    try:
        query = r.recognize_google(audio)
        print(f"You said: {query}\n")
    except Exception as e:
        print("Say that again please...")
        return "None"
    return query

# Executing basic commands
if __name__ == "__main__":
    speak("Hello! I am Jarvis, your assistant. How can I help you?")
    while True:
        command = take_command().lower()
        if 'open google' in command:
            webbrowser.open("google.com")
        elif 'open youtube' in command:
            webbrowser.open("youtube.com")
Enter fullscreen mode Exit fullscreen mode

Imagine giving voice commands to a virtual assistant that you built yourself—this is the power of Python.


2. Love Calculator

The Love Calculator is a fun project that uses Python’s random module to calculate a “compatibility score” between two people based on their names. Although not a serious application, it’s a great project to explore randomness and basic Python logic.

import random

def love_calculator(name1, name2):
    score = random.randint(0, 100)
    print(f"Love score between {name1} and {name2} is {score}%")

# Sample usage
love_calculator("Sam", "Linda")  # Output: The love score between Harry and Payal is 97%
Enter fullscreen mode Exit fullscreen mode

3. Face Recognition Program with Haar Cascade Algorithm

Python’s power becomes evident in applications that involve machine learning and computer vision. Using OpenCV’s Haar Cascade algorithm, this project detects faces within an image. It’s a practical application for those interested in AI and deep learning.

import cv2

# Load the Haar cascade file
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')

# Load an image
image = cv2.imread('sample.jpg')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

# Detect faces in the image
faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5)

# Draw rectangles around faces
for (x, y, w, h) in faces:
    cv2.rectangle(image, (x, y), (x+w, y+h), (255, 0, 0), 2)

# Show the output
cv2.imshow('Image', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
Enter fullscreen mode Exit fullscreen mode

This project is a great way to experience how Python can interact with images, detect faces, and apply machine learning models.


4. Flappy Bird Game

If you’ve ever enjoyed playing Flappy Bird on your phone, imagine creating it yourself. With the Pygame library, we’ll design and develop a playable version of Flappy Bird from scratch. This project is ideal for understanding game development basics.

import pygame
import random

# Initialize game
pygame.init()

# Define game variables
width, height = 400, 600
win = pygame.display.set_mode((width, height))

# Game loop skeleton (placeholder for full code)
running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
    # Add bird movement, pipes, and collision logic here
    pygame.display.update()
pygame.quit()
Enter fullscreen mode Exit fullscreen mode

This project demonstrates Python’s flexibility in game development and how coding can create entertainment experiences.


5. Snake Game

The classic Snake Game is another fun project we’ll create. The objective of this game is to control a snake as it grows by “eating” food on the screen. This project involves fundamental concepts in game logic, such as event handling and collision detection.

import pygame
import time
import random

# Define game parameters
snake_speed = 15
window_x = 720
window_y = 480

# Initialize game window
pygame.init()
game_window = pygame.display.set_mode((window_x, window_y))
pygame.display.set_caption('Snake Game')

# Game Over function
def game_over():
    pygame.quit()
    quit()

# Main function to drive the game
def main():
    # Game initialization code
    while True:
        # Game logic for movement and collision
        pass  # Placeholder for complete game logic

if __name__ == "__main__":
    main()
Enter fullscreen mode Exit fullscreen mode

Creating a game like Snake will give you confidence in using Python for more complex logic and interactivity.


A Journey into the World of Python Programming

The 100 Days of Code series is designed to go beyond basic syntax and theory. We’ll not only make fun projects but also dive into newer features of Python like the Walrus Operator and more efficient data handling techniques. With each project, you’ll gain hands-on experience, making Python a tool you can wield skillfully to bring ideas to life.

Getting the Code and Resources

As you follow along, I’ll provide you with all the source code. Try running each program and installing the necessary modules using pip install. If you encounter issues, don’t worry. We’ll cover every necessary skill to make these projects work, and by the end of this series, you’ll feel confident taking on even more advanced projects.

Join the Journey

This 100 Days of Code series isn’t just about learning Python; it’s about building the projects that will give you confidence and capability. Bookmark this blog and the series playlist to stay on track, and get ready for a fun and productive journey into Python programming.

Buy me a Coffee

Next

Day 3: Modules and Pip | 100 Days Python

Top comments (0)