Python Projects for Beginners

10+ Best, Easy, and Cool Python Projects for Beginners with Source code and resources to refer

Spread this useful information with your friends if you liked.

10+ Best, Easy and Cool Python Projects for Beginners with Source code and resources to refer

Have you learnt all the concepts in Python? And are searching for the best projects that can bring your theoretical knowledge in practical and cool projects. So, this is the best article that will help you to get with your first few amazing and exciting projects.

These Python Projects includes a wide variety application from games to industrial level applications.

Why to Develop Python Projects?

Let’s first understand the whole phenomenon behind the word projects. So, projects are basically some real-life problems that are to be solved by any means.

So, we all know that the whole world is based on problem solving and improving the quality of human life. Hence, to get prepared to solve those kinds of problems “projects” are just way to prepare ourselves to solve some problems those are not solved till date.

And the second aspect would be projects helps us to strengthen our skills and get a more command on those skills which we have already concurred.

Projects also play a huge role in making a armature programmer a matured and disciplined programmer for which the companies are hunting for.

So in short Projects help us to make a warrior in our field that hunt down the problems that occur.

What skills do these projects help a developer to improve

  1. It helps a programmer gain more command on his programming skills.
  2. Helps programmer to write a disciplined and necessary code.
  3. Teaches some ethics of working as a team.
  4. Forces to get hands on new technologies.
  5. Projects helps in Identify and embrace your strengths and weaknesses

Prerequisites for the Projects

  1. Python basic concepts should be done fairly.
  2. Should have logic building approach.
  3. Have worked on small problems like star printing pattern and fizzbuzz etc.
  4. IDEs form project development such as Sublime Text, Pycharm, VScode.

Here is an amazing article on IDE’s for Python with benefits of using IDE, so make sure you check it out.

Best 8 Python IDEs and Code Editors in 2021

Python Projects for Beginners

These are some easy yet interesting projects that will make you think twice that you have developed it.

Word Guessing Game.

Word Guessing Game

Intro to project:

This is a very simple project that will basically test your Python basic concepts and little bit if logical thinking.

This project is for beginners in python and give a little brief on loops, conditional statements and using strings.

These kinds of projects are asked multiple times in coding round by the tech companies.

Working with these projects you will encounter some concepts like:

  • Loops
  • Conditional Statements and
  • Using Strings.

Source Code:

import random 
name = input("What is your name? ") 
print("Good Luck ! ", name)
 
words = ['rainbow', 'computer', 'science', 'programming',
         'python', 'mathematics', 'player', 'condition',
         'reverse', 'water', 'board', 'studyber']
word = random.choice(words)
 
 
print("Guess the characters")
 
guesses = ''
turns = 12
 
 
while turns > 0:
    failed = 0
    for char in word:
        if char in guesses:
            print(char)
             
        else:
            print("_")
            failed += 1
             
 
    if failed == 0:
        print("You Win")
        print("The word is: ", word)
        break
     
    guess = input("guess a character:")
     
    guesses += guess
     
    if guess not in word:
         
        turns -= 1
        print("Wrong")
        print("You have", + turns, 'more guesses')
         
         
        if turns == 0:
            print("You Loose")

Output:

What is your name? Aditya
Good Luck !  Aditya
Guess the characters
_
_
_
_
_
guess a character:w
w
_
_
_
_
guess a character:a
w
a
_
_
_
guess a character:t
w
a
t
_
_
guess a character:e
w
a
t
e
_
guess a character:r
w
a
t
e
r
You Win
The word is:  water

Although this seems a simple project but is very crucial for those who are a little week in logic building and basic syntax on Python

Alarm Clock:

Alarm Clock

Intro to project:

Developing a “Alarm Clock”! Seems a tricky project to develop. Don’t worry this is a little advanced projects than the previous one but believe me this is a really a fun project. Imagine developing your personal Alarm Clock for you!

The main objective of this project is to develop an alarm clock using Python.

Prerequisites:

  1. Need some knowledge of GUI (Graphical User Interface).
  2. Some basic concepts of Tkinter (As it provides a fast and easy way to create GUI applications.)

Working with these projects you will encounter some concepts like:

  1. Using imported Python libraries.
  2. Using GUI with Python for User Interface.
  3. Use of functions and their implementations.

Source code:

#Importing all the necessary libraries to form the alarm clock:
from tkinter import *
import datetime
import time
import winsound
def alarm(set_alarm_timer):
    while True:
        time.sleep(1)
        current_time = datetime.datetime.now()
        now = current_time.strftime("%H:%M:%S")
        date = current_time.strftime("%d/%m/%Y")
        print("The Set Date is:",date)
        print(now)
        if now == set_alarm_timer:
            print("Time to Wake up")
            winsound.PlaySound("sound.wav",winsound.SND_ASYNC)
            break
def actual_time():
    set_alarm_timer = f"{hour.get()}:{min.get()}:{sec.get()}"
    alarm(set_alarm_timer)

clock = Tk()
clock.title("Persoanl Alarm Clock")
clock.iconbitmap(r"dataflair-logo.ico")
clock.geometry("400x200")
time_format=Label(clock, text= "Enter time in 24 hour format!", fg="red",bg="black",font="Arial").place(x=60,y=120)
addTime = Label(clock,text = "Hour  Min   Sec",font=60).place(x = 110)
setYourAlarm = Label(clock,text = "When to wake you up",fg="blue",relief = "solid",font=("Helevetica",7,"bold")).place(x=0, y=29)

# The Variables we require to set the alarm(initialization):
hour = StringVar()
min = StringVar()
sec = StringVar()

#Time required to set the alarm clock:
hourTime= Entry(clock,textvariable = hour,bg = "pink",width = 15).place(x=110,y=30)
minTime= Entry(clock,textvariable = min,bg = "pink",width = 15).place(x=150,y=30)
secTime = Entry(clock,textvariable = sec,bg = "pink",width = 15).place(x=200,y=30)

#To take the time input by user:
submit = Button(clock,text = "Set Alarm",fg="red",width = 10,command = actual_time).place(x =110,y=70)

clock.mainloop()
#Execution of the window.

This is the application that would help you in discovering the (UI) User Interface side of the applications.

So do try this project and increase your programming skills exponentially.

Hangman Game in Python

Hangman Game in Python

Intro to project:

Oh Hangman! Seems a scary one by the name. But it is relatively simple one compared to previous project. As this is a command line project.

This is a project that is been in the programming world for a while now. And according to me this is the project that is definitely present in top 10 of all the programming languages.

Hangman is a lengthy project as it requires many lines of code but it is worth it. This project mainly focuses on using of functions and conditional statements.

Working with these projects you will encounter some concepts like:

  1. Functions and Conditional statements.
  2. Iteration of loops.
  3. Importing “random” library and implementing it.

Source code:

import random
word_list = ["insert", "your", "words", "in", "this", "python", "list"]

def get_word(word_list):
    word = random.choice(word_list)
    return word.upper()


def play(word):
    word_completion = "_" * len(word)
    guessed = False
    guessed_letters = []
    guessed_words = []
    tries = 6
    print("Let's play Hangman")
    print(display_hangman(tries))
    print(word_completion)
    print("\n")
    while not guessed and tries > 0:
        guess = input("guess a letter or word: ").upper()
        if len(guess) == 1 and guess.isalpha():
            if guess in guessed_letters:
                print("you already tried", guess, "!")
            elif guess not in word:
                print(guess, "isn't in the word :(")
                tries -= 1
                guessed_letters.append(guess)
            else:
                print("Nice one,", guess, "is in the word!")
                guessed_letters.append(guess)
                word_as_list = list(word_completion)
                indices = [i for i, letter in enumerate(word) if letter == guess]
                for index in indices:
                    word_as_list[index] = guess
                word_completion = "".join(word_as_list)
                if "_" not in word_completion:
                    guessed = True
        elif len(guess) == len(word) and guess.isalpha():
            if guess in guessed_words:
                print("You already tried ", guess, "!")
            elif guess != word:
                print(guess, " ist nicht das Wort :(")
                tries -= 1
                guessed_words.append(guess)
            else:
                guessed = True
                word_completion = word
        else:
            print("invalid input")
        print(display_hangman(tries))
        print(word_completion)
        print("\n")
    if guessed:
        print("Good Job, you guessed the word!")
    else:
        print("I'm sorry, but you ran out of tries. The word was " + word + ". Maybe next time!")




def display_hangman(tries):
    stages = [  """
                   --------
                   |      |
                   |      O
                   |     \\|/
                   |      |
                   |     / \\
                   -
                   """,
                   """
                   --------
                   |      |
                   |      O
                   |     \\|/
                   |      |
                   |     /
                   -

                   """,
                   """
                   --------
                   |      |
                   |      O
                   |     \\|/
                   |      |
                   |
                   -
                   """,
                   """
                   --------
                   |      |
                   |      O
                   |     \\|
                   |      |
                   |
                   -
                   """,
                   """
                   --------
                   |      |
                   |      O
                   |      |
                   |      |
                   |
                   -
                   """,
                   """
                   --------
                   |      |
                   |      O
                   |
                   |
                   |
                   -
                   """,
                   """
                   --------
                   |      |
                   |      
                   |
                   |
                   |
                   -
                   """
    ]
    return stages[tries]

def main():
    word = get_word(word_list)
    play(word)
    while input("Again? (Y/N) ").upper() == "Y":
        word = get_word(word_list)
        play(word)

if __name__ == "__main__":
    main()

This is the project that would need a lot of looing and use of conditional statements all the further steps depend on the input of the user.

Age Calculator

Age Calculator

Intro to Project:

We all have definitely encounter with some age calculator application till now but it is this time that we will try to calculate our age with the command line project that we will be developing now.

So, this is a Python project that is developed to calculate age in days and months.

This program will ask you your age and will display number of months and numbers of days you have lived. The project focuses on the using of libraries such as time, calendar and isleap.

This seems an easy application but it will force you to think and develop a logic that can even handle the leap year’s conditions.

This is good project for those who are weak in math’s implementation with the logic.

Working with these projects you will encounter some concepts like:

  1. Implementing python libraries like time, calendar and isleap.
  2. Math’s implementation in the real-world problems.
  3. Dealing with the leap year conditions with some math formulae.

Source code:

import time
from calendar import isleap

# judge the leap year
def judge_leap_year(year):
    if isleap(year):
        return True
    else:
        return False


# returns the number of days in each month
def month_days(month, leap_year):
    if month in [1, 3, 5, 7, 8, 10, 12]:
        return 31
    elif month in [4, 6, 9, 11]:
        return 30
    elif month == 2 and leap_year:
        return 29
    elif month == 2 and (not leap_year):
        return 28


name = input("input your name: ")
age = input("input your age: ")
localtime = time.localtime(time.time())

year = int(age)
month = year * 12 + localtime.tm_mon
day = 0

begin_year = int(localtime.tm_year) - year
end_year = begin_year + year

# calculate the days
for y in range(begin_year, end_year):
    if (judge_leap_year(y)):
        day = day + 366
    else:
        day = day + 365

leap_year = judge_leap_year(localtime.tm_year)
for m in range(1, localtime.tm_mon):
    day = day + month_days(m, leap_year)

day = day + localtime.tm_mday
print("%s's age is %d years or " % (name, year), end="")
print("%d months or %d days" % (month, day))

Output:

input your name: Derek
input your age: 19
Derek's age is 19 years or 235 months or 7150 days

This is a simple but challenging project that will brush your logical and mathematical concepts.

Simple Stopwatch application

Simple Stopwatch Application

Intro to project:

By just hearing this title of the project it seems cool. So, this is a Python Project that is built using important libraries like datetime and tkinter.

(This is the similar library that we had already used in the “Alarm Clock” application.)

If you were not able to solve the alarm clock project this is the same kind of project but here the logic used is a bit different form the one.

In this project you would encounter many new keywords but this is the thing that you learn from projects that is constantly learning new things.

The new keywords that you might see new to you are:

  1. .pack
  2. .title
  3. .minsize
  4. global

Source code:

import tkinter as Tkinter
from datetime import datetime
counter = 0
running = False


def counter_label(label):
    def count():
        if running:
            global counter
			# To manage the intial delay. 
            if counter == 0:
                display = 'Ready!'
            else:
                tt = datetime.utcfromtimestamp(counter)
                string = tt.strftime('%H:%M:%S')
                display = string
	
            label['text'] = display
	
			# label.after(arg1, arg2) delays by 
			# first argument given in milliseconds 
			# and then calls the function given as second argument. 
			# Generally like here we need to call the 
			# function in which it is present repeatedly. 
			# Delays by 1000ms=1 seconds and call count again. 
            label.after(1000, count)
            counter += 1
	
	# Triggering the start of the counter. 
    count()
	

# start function of the stopwatch 
def Start(label):
    global running
    running = True
    counter_label(label)
    start['state'] = 'disabled'
    stop['state'] = 'normal'
    reset['state'] = 'normal'
	

# Stop function of the stopwatch 
def Stop():
    global running
    start['state'] = 'normal'
    stop['state'] = 'disabled'
    reset['state'] = 'normal'
    running = False
	

# Reset function of the stopwatch 
def Reset(label):
	global counter
	counter = 0
	# If reset is pressed after pressing stop. 
	if not running:
		reset['state'] = 'disabled'
		label['text'] = '00:00:00'
	# If reset is pressed while the stopwatch is running. 
	else:
		label['text'] = '00:00:00'


root = Tkinter.Tk()
root.title("Stopwatch")

# Fixing the window size.
root.minsize(width=250, height=70)
label = Tkinter.Label(root, text='Ready!', fg='black', font='Verdana 30 bold')
label.pack()
f = Tkinter.Frame(root)
start = Tkinter.Button(f, text='Start', width=6, command=lambda: Start(label))
stop = Tkinter.Button(f, text='Stop', width=6, state='disabled', command=Stop)
reset = Tkinter.Button(f, text='Reset', width=6, state='disabled', command=lambda: Reset(label))
f.pack(anchor='center', pady=5)
start.pack(side='left')
stop.pack(side='left')
reset.pack(side='left')
root.mainloop()

So, this project will teach you many new things and concepts that are generally used in professional applications. If you get the logic behind if try to develop it yourself.

Tic-Tac-Toe

tic tac toe

Intro to project:

Hold on, is that right? Hey you read absolutely right! This is the next project that we will be developing. We all have played this interesting game in our childhood. But hey it is again the time we try this game but this it would be digital and developed by you!!

This “Tic-Tac-Toe” game is completely developed using basic concepts and logic of python programming. This is the project that will use all the resources of python that you have studied till now.

This project uses for and while loops, conditional statements and functions with a “random” library.

This is not a project graphical interface project this is complete command line project .

Concepts of python that we will use in development of this project are :

  1. Define functions.
  2. Variables
  3. Range
  4. Lists
  5. Loops
  6. Conditional statements
  7. Iteration of loops.

Source Code:

board = [' ' for x in range(10)]

def insertLetter(letter,pos):
    board[pos] = letter

def spaceIsFree(pos):
    return board[pos] == ' '

def printBoard(board):
    print('   |   |   ')
    print(' ' + board[1] + ' | ' + board[2] + ' | ' + board[3])
    print('   |   |   ')
    print('------------')
    print('   |   |   ')
    print(' ' + board[4] + ' | ' + board[5] + ' | ' + board[6])
    print('   |   |   ')
    print('------------')
    print('   |   |   ')
    print(' ' + board[7] + ' | ' + board[8] + ' | ' + board[9])
    print('   |   |   ')

def isBoardFull(board):
    if board.count(' ') > 1:
        return False
    else:
        return True

def IsWinner(b,l):
    return ((b[1] == l and b[2] == l and b[3] == l) or
    (b[4] == l and b[5] == l and b[6] == l) or
    (b[7] == l and b[8] == l and b[9] == l) or
    (b[1] == l and b[4] == l and b[7] == l) or
    (b[2] == l and b[5] == l and b[8] == l) or
    (b[3] == l and b[6] == l and b[9] == l) or
    (b[1] == l and b[5] == l and b[9] == l) or
    (b[3] == l and b[5] == l and b[7] == l))

def playerMove():
    run = True
    while run:
        move = input("please select a position to enter the X between 1 to 9")
        try:
            move = int(move)
            if move > 0 and move < 10:
                if spaceIsFree(move):
                    run = False
                    insertLetter('X' , move)
                else:
                    print('Sorry, this space is occupied')
            else:
                print('please type a number between 1 and 9')

        except:
            print('Please type a number')

def computerMove():
    possibleMoves = [x for x , letter in enumerate(board) if letter == ' ' and x != 0  ]
    move = 0

    for let in ['O' , 'X']:
        for i in possibleMoves:
            boardcopy = board[:]
            boardcopy[i] = let
            if IsWinner(boardcopy, let):
                move = i
                return move

    cornersOpen = []
    for i in possibleMoves:
        if i in [1 , 3 , 7 , 9]:
            cornersOpen.append(i)

    if len(cornersOpen) > 0:
        move = selectRandom(cornersOpen)
        return move

    if 5 in possibleMoves:
        move = 5
        return move

    edgesOpen = []
    for i in possibleMoves:
        if i in [2,4,6,8]:
            edgesOpen.append(i)

    if len(edgesOpen) > 0:
        move = selectRandom(edgesOpen)
        return move

def selectRandom(li):
    import random
    ln = len(li)
    r = random.randrange(0,ln)
    return li[r]

def main():
    print("Welcome to the game!")
    printBoard(board)

    while not(isBoardFull(board)):
        if not(IsWinner(board , 'O')):
            playerMove()
            printBoard(board)
        else:
            print("sorry you loose!")
            break

        if not(IsWinner(board , 'X')):
            move = computerMove()
            if move == 0:
                print(" ")
            else:
                insertLetter('O' , move)
                print('computer placed an o on position' , move , ':')
                printBoard(board)
        else:
            print("you win!")
            break



    if isBoardFull(board):
        print("Tie game")

while True:
    x = input("Do you want to play again? (y/n)")
    if x.lower() == 'y':
        board = [' ' for x in range(10)]
        print('--------------------')
        main()
    else:
        break

10 Python Projects for intermediate level programmers.

10 Python Projects for advanced level programmers.

Best Books to master your Python Programming skills

1. Python Crash Course.

 

 

2. Python CookBook.

 

 

3. Automate the Boring Stuff with Python.

 

 

Conclusion

These are all the projects that would be really boosting your programming knowledge and help you become a professional level programmer. Till then keep learning and keep coding.


Spread this useful information with your friends if you liked.

Leave a Comment

Your email address will not be published. Required fields are marked *