Posts

Showing posts from September, 2021

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(...

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("...