Top 3 Python Projects for Absolute Beginners (with Code)

Top 3 Python Projects for Absolute Beginners (with Code)

  1. Rock Paper Scissors

This rock paper scissors program uses a number of functions so this is a good way of getting that critical concept under your belt.

Random function: to generate rock, paper, or scissors. Valid function: to check the validity of the move. Result function: to declare the winner of the round. Scorekeeper: to keep track of the score. The program requires the user to make the first move before it makes a move. The input could be a string or an alphabet representing either rock, paper, or scissors. After evaluating the input string, a winner is decided by the result function and the score of the round is updated by the scorekeeper function.


import random
import os
import re

os.system('cls' if os.name=='nt' else 'clear')

while (1 < 2):
print ("\n")
print ("Rock, Paper, Scissors - Shoot!")
userChoice = input("Choose your weapon [R]ock], [P]aper, or [S]cissors: ")
if not re.match("[SsRrPp]", userChoice):
print ("Please choose a letter:")
print ("[R]ock, [S]cissors or [P]aper.")
continue
print ("You chose: " + userChoice)
choices = ['R', 'P', 'S']
opponenetChoice = random.choice(choices)
print ("I chose: " + opponenetChoice)
if opponenetChoice == str.upper(userChoice):
print ("Tie! ")
elif opponenetChoice == 'R' and userChoice.upper() == 'S':
print ("Scissors beats rock, I win! ")
continue
elif opponenetChoice == 'S' and userChoice.upper() == 'P':
print ("Scissors beats paper! I win! ")
continue
elif opponenetChoice == 'P' and userChoice.upper() == 'R':
print ("Paper beat rock, I win!")
continue
else:
print ("You Win!")
  1. Dice Roll Generator

This dice roll generator is a fairly simple program that makes use of the random function to simulate dice rolls. You can change the maximum value to any number, making it possible to simulate polyhedral dice used in many board games and roleplaying games.

import random

#Enter the minimum and maximum limits of the dice rolls below

min_val = 1

max_val = 6

#the variable that stores the user’s decision

roll_again = "yes"

#The dice roll loop if the user wants to continue

while roll_again == "yes" or roll_again == "y":

print("Dices rolling...")

print("The values are :")

#Printing the randomly generated variable of the first dice

print(random.randint(min_val, max_val))

#Printing the randomly generated variable of the second dice

print(random.randint(min_val, max_val))

#Here the user enters yes or y to continue and any other input ends the program

roll_again = input("Roll the Dices Again?")
  1. Calculator

This project teaches you to design a graphical interface and is a good way to get familiar with a library like Tkinter. This library lets you create buttons to perform different operations and display results on the screen.


def addition ():

print("Addition")

n = float(input("Enter the number: "))

t = 0 #Total number enter

ans = 0

while n != 0:

ans = ans + n

t+=1

n = float(input("Enter another number (0 to calculate): "))

return [ans,t]

def subtraction ():

print("Subtraction");

n = float(input("Enter the number: "))

t = 0 #Total number enter

sum = 0

while n != 0:

ans = ans - n

t+=1

n = float(input("Enter another number (0 to calculate): "))

return [ans,t]

def multiplication ():

print("Multiplication")

n = float(input("Enter the number: "))

t = 0 #Total number enter

ans = 1

while n != 0:

ans = ans * n

t+=1

n = float(input("Enter another number (0 to calculate): "))

return [ans,t]

def average():

an = []

an = addition()

t = an[1]

a = an[0]

ans = a / t

return [ans,t]

# main...

while True:

list = []

print(" My first python program!")

print(" Simple Calculator in python by Malik Umer Farooq")

print(" Enter 'a' for addition")

print(" Enter 's' for substraction")

print(" Enter 'm' for multiplication")

print(" Enter 'v' for average")

print(" Enter 'q' for quit")

c = input(" ")

if c != 'q':

if c == 'a':

list = addition()

print("Ans = ", list[0], " total inputs ",list[1])

elif c == 's':

list = subtraction()

print("Ans = ", list[0], " total inputs ",list[1])

elif c == 'm':

list = multiplication()

print("Ans = ", list[0], " total inputs ",list[1])

elif c == 'v':

list = average()

print("Ans = ", list[0], " total inputs ",list[1])

else:

print ("Sorry, invilid character")

else:

break

3 beginner Python projects that can be a lot of fun at the same time. These projects put your theoretical learning to the test and help better your practical handling of Python knowledge.