Posts

Rock Papper Scissors Mini Game using Python

  This program or a mini-game is designed when you don’t have anyone to play or you are under lockdown alone. There are a number of functions that this program requires so let us have an overview of each. a 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 one the move. Once the move is validated the input is evaluated, the input entered could be a string or an alphabet. 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.  Source Code:- """ Rock Paper Scissors --------------------@only.python-------------------- """ import random import os import re os.system('cls' if os.name=='nt' else 'clear') while (1 < 2):     print(&qu

Tic Tac Toe game using Python

  Source Code:-  #Implementation of Two Player Tic-Tac-Toe game in Python. ''' We will make the board using dictionary      in which keys will be the location(i.e : top-left,mid-right,etc.)     and initialliy it's values will be empty space and then after every move      we will change the value according to player's choice of move. ''' theBoard = {'7': ' ' , '8': ' ' , '9': ' ' ,             '4': ' ' , '5': ' ' , '6': ' ' ,             '1': ' ' , '2': ' ' , '3': ' ' } board_keys = [] for key in theBoard:     board_keys.append(key) ''' We will have to print the updated board after every move in the game and      thus we will make a function in which we'll define the printBoard function     so that we can easily print the board everytime by calling this function. ''' def printBoard(boar

OTP Verification using Python

  Steps to Create an OTP Verification System using Python:- 1.First, create a 6-digit random number.  2.Then store the number in a variable.  3.Then we need to write a program to send emails.  4.When sending email, we need to use OTP as a message.  5.Finally, we need to request two user inputs; first for the user’s email and then for the OTP that the user has received. Source Code:- import os import math import random import smtplib digits = "0123456789" OTP = "" for i in range ( 6 ): OTP += digits [ math . floor ( random . random () * 10 )] otp = OTP + " is your OTP" msg = otp s = smtplib . SMTP ( 'smtp.gmail.com' , 587 ) s . starttls () s . login ( "Your Gmail Account" , "You app password" ) emailid = input ( "Enter your email: " ) s . sendmail ( '&&&&&&&&&&&' , emailid , msg ) a = input ( "Enter Your OTP >>: " ) if a =

Analog clock using Python turtle

 Source Code:- from turtle import Turtle, Screen import datetime #creating window window = Screen() #setting window title window.title("Krazy:Digital Clock") #setting background color window.bgcolor("black") #setting height and width of window window.setup(width=1000, height=800) #creating outer circle circle = Turtle() circle.penup() circle.pencolor("#118893") circle.speed(0) circle.pensize(25) circle.hideturtle() circle.goto(0, -390) circle.pendown() circle.fillcolor("#17202A") circle.begin_fill() circle.circle(400) circle.end_fill() #creating hour hand hHand = Turtle() hHand.shape("arrow") hHand.color("white") hHand.speed(10) hHand.shapesize(stretch_wid=0.4, stretch_len=18) #creating minute hand mHand = Turtle() mHand.shape("arrow") mHand.color("white") mHand.speed(10) mHand.shapesize(stretch_wid=0.4, stretch_len=26) #creating second hand sHand = Turtle() sHand.shape("arrow") sHand.color("

Mad Libs Generator using Python

  This python beginner project is a good start for beginner software developers as it has concepts like strings, variables, and concatenation. Mad Libs Generator teaches to manipulate user-inputted data as the Mad Libs refer to a series of inputs that a user enters. The input from the user could be anything from an adjective, a pronoun, or even a verb. After all the inputs are entered the application takes all the data and arranges it to build a story template.  Here is the Source Code👇 """ Mad Libs Generator ---------------------------------------- """ #Loop back to this point once code finishes loop = 1 while (loop < 10): #All the questions that the program asks the user     noun = input("Choose a noun: ")     p_noun = input("Choose a plural noun: ")     noun2 = input("Choose a noun: ")     place = input("Name a place: ")     adjective = input("Choose an adjective (Describing word): ")     noun3 = inp

Draw Indian Flag using Python turtle

Image
  Source Code:- # required module-pip install turtle import turtle # inializing a turtle flag = turtle.Turtle() turtle.bgcolor("black") # for creating first reactangle flag.begin_fill() flag.fillcolor("orange") flag.forward(500) flag.right(90) flag.forward(100) flag.right(90) flag.forward(500) flag.right(90) flag.forward(100) flag.right(90) flag.end_fill() # for second rectangle flag.right(90) flag.forward(100) flag.begin_fill() flag.fillcolor("white") flag.forward(100) flag.left(90) flag.forward(500) flag.left(90) flag.forward(100) flag.left(90) flag.forward(500) flag.end_fill() # for third rectangle flag.begin_fill() flag.fillcolor("green") flag.left(90) flag.forward(200) flag.left(90) flag.forward(500) flag.left(90) flag.forward(100) flag.left(90) flag.forward(500) flag.end_fill() #big blue circle flag.penup() flag.setpos(250,-105) flag.pendown() flag.begin_fill() flag.fillcolor("navy") flag.circle(45) flag.end_fill() #big white circ

Python Program for Tower of Hanoi

Image
 Tower of Hanoi is a mathematical puzzle where we have three rods and n disks. The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules:  1) Only one disk can be moved at a time.  2) Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack i.e. a disk can only be moved if it is the uppermost disk on a stack.  3) No disk may be placed on top of a smaller disk. Source Code:- # Recursive Python function to solve the tower of hanoi def TowerOfHanoi(n , source, destination, auxiliary):     if n==1:         print "Move disk 1 from source",source,"to destination",destination         return     TowerOfHanoi(n-1, source, auxiliary, destination)     print "Move disk",n,"from source",source,"to destination",destination     TowerOfHanoi(n-1, auxiliary, destination, source)  # Driver code n = 4 TowerOfHanoi(n,'A','B','C')  # A,