from tkinter import *
import datetime
import time
import winsound
from threading import *

root = Tk()
root.geometry("400x200")

def Threading():
	t1=Thread(target=alarm)
	t1.start()

def alarm():
	while True:
		set_alarm_time = f"{hour.get()}:{minute.get()}:{second.get()}"
		time.sleep(1)
		current_time = datetime.datetime.now().strftime("%H:%M:%S")
		print(current_time,set_alarm_time)
		if current_time == set_alarm_time:
			print("Time to Wake up")
			winsound.PlaySound("sound.wav",winsound.SND_ASYNC)
			quit()

Label(root,text="Alarm Clock",font=("Helvetica 20 bold"),fg="red").pack(pady=10)
Label(root,text="Set Time",font=("Helvetica 15 bold")).pack()

frame = Frame(root)
frame.pack()

hour = StringVar(root)
hours = ('00', '01', '02', '03', '04', '05', '06', '07',
		'08', '09', '10', '11', '12', '13', '14', '15',
		'16', '17', '18', '19', '20', '21', '22', '23', '24'
		)
hour.set(hours[0])

hrs = OptionMenu(frame, hour, *hours)
hrs.pack(side=LEFT)

minute = StringVar(root)
minutes = ('00', '01', '02', '03', '04', '05', '06', '07',
		'08', '09', '10', '11', '12', '13', '14', '15',
		'16', '17', '18', '19', '20', '21', '22', '23',
		'24', '25', '26', '27', '28', '29', '30', '31',
		'32', '33', '34', '35', '36', '37', '38', '39',
		'40', '41', '42', '43', '44', '45', '46', '47',
		'48', '49', '50', '51', '52', '53', '54', '55',
		'56', '57', '58', '59', '60')
minute.set(minutes[0])

mins = OptionMenu(frame, minute, *minutes)
mins.pack(side=LEFT)

second = StringVar(root)
seconds = ('00', '01', '02', '03', '04', '05', '06', '07',
		'08', '09', '10', '11', '12', '13', '14', '15',
		'16', '17', '18', '19', '20', '21', '22', '23',
		'24', '25', '26', '27', '28', '29', '30', '31',
		'32', '33', '34', '35', '36', '37', '38', '39',
		'40', '41', '42', '43', '44', '45', '46', '47',
		'48', '49', '50', '51', '52', '53', '54', '55',
		'56', '57', '58', '59', '60')
second.set(seconds[0])

secs = OptionMenu(frame, second, *seconds)
secs.pack(side=LEFT)

Button(root,text="Set Alarm",font=("Helvetica 15"),command=Threading).pack(pady=20)

root.mainloop()

AlarmClock/alarm_clock.py
SamarthTech/Hacktoberfest-Project-and-Games
import pygame
import math
import random

from pygame import mixer

'''Initialize pygame''' 
pygame.init() #Always be there

'''Create a screen'''
screen = pygame.display.set_mode((800,600))

'''Background sound'''
mixer.music.load("background.mp3")
mixer.music.play(-1)


'''Title and Icon'''
pygame.display.set_caption("Alien Attack Developed by Aatif Ahmad ")
icon = pygame.image.load("spaceshuttle.png")
pygame.display.set_icon(icon)

sad_face = pygame.image.load("sad.png")
 
'''Adding the player'''
playerImg = pygame.image.load("spaceshuttle.png")
playerX = 370
playerY = 480
playerX_change = 0

'''Enemy'''
enemyImg = []
enemyX = []
enemyY = []
enemyX_change = []
enemyY_change = []

num_of_enemies = 6


for i in range(num_of_enemies):
    enemyImg.append(pygame.image.load("ufo.png"))
    enemyX.append(random.randint(0,740))
    enemyY.append(random.randint(0,140))
    enemyX_change.append(1.2)
    enemyY_change.append(50)

'''ready - you can't see the bullet on screen.'''
'''fire - the bullet is currently moving.'''

bulletImg = pygame.image.load("bullet.png")
bulletX = 0
bulletY = 480
bulletY_change = 5
bullet_state = "ready"

'''Score'''
score_value = 0
font = pygame.font.Font("freesansbold.ttf",32)

textX = 10
textY = 10

game_overX = 160
game_overY = 200

'''Game Over Text'''

game_over_font = pygame.font.Font("freesansbold.ttf",80)

def show_score(x,y):
    score = font.render("Score : "+str(score_value),True,(0,0,0))
    screen.blit(score,(x,y))

def game_over_text(x,y):
    over_text = game_over_font.render("GAME OVER",True,(255,0,0))
    screen.blit(over_text,(x,y))
    screen.blit(sad_face,(390,280))

def player(x,y):
    screen.blit(playerImg,(x,y))

def enemy(x,y,i):
    screen.blit(enemyImg[i],(x,y))

def fire_bullet(x,y):
    global bullet_state
    bullet_state = "fire"
    screen.blit(bulletImg,(x + 14,y + 10))

def isCollision(enemyX,enemyY,bulletX,bulletY):
    distance = math.sqrt(math.pow((enemyX - bulletX),2) + math.pow((enemyY - bulletY),2))
    if distance < 27:
        return True
    else:
        return False

'''Game loop'''
running = True
while running:

    screen.fill((225,100,100))
    

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False 

        '''If keystroke is pressed check whether its right or left'''

        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_LEFT:
                playerX_change = -1.2

            if event.key == pygame.K_RIGHT:
                playerX_change = 1.2

            if event.key == pygame.K_SPACE:
                bullet_sound = mixer.Sound("gun_shoot.mp3")
                bullet_sound.play()
                if bullet_state == "ready":
                    bulletX = playerX
                    fire_bullet(bulletX,bulletY)

        if event.type == pygame.KEYUP:
            if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
                playerX_change = 0

    '''Checking the boundary of player'''

    if (playerX + playerX_change) <=736 and (playerX + playerX_change) >=0:
        playerX += playerX_change
    else:
        playerX += 0

    for i in range(num_of_enemies):

        '''Game Over'''
        if enemyY[i] > 430:
            for j in range(num_of_enemies):
                enemyY[j] = 2000
            game_over_text(game_overX,game_overY)
            break

        enemyX[i] += enemyX_change[i]
        '''Checking the boundaries of enemy'''

        if (enemyX[i] + enemyX_change[i]) >= 736:
            enemyX_change[i] = -1.2
            enemyY[i] += enemyY_change[i]

        elif (enemyX[i] + enemyX_change[i]) <= 0:
            enemyX_change[i] = 1.2
            enemyY[i] += enemyY_change[i]

        '''Check Collision'''
        collision = isCollision(enemyX[i],enemyY[i],bulletX,bulletY)
        if collision == True:
            explosion_sound = mixer.Sound("bad-explosion-6855.mp3")
            explosion_sound.play()
            bulletY = 480
            bullet_state = "ready"
            score_value += 10
            enemyX[i] = random.randint(0,740)
            enemyY[i] = random.randint(0,140)

        enemy(enemyX[i],enemyY[i],i)

    '''Bullet Movement'''
    if bulletY <= 0:
        bulletY = 480
        bullet_state = "ready"

    if bullet_state == "fire":
        fire_bullet(bulletX,bulletY)
        bulletY -= bulletY_change

    
    player(playerX,playerY)
    show_score(textX,textY)
    pygame.display.update() #This is always there
AlienAttack/main.py
SamarthTech/Hacktoberfest-Project-and-Games
package io.flutter.plugins;

import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import io.flutter.Log;

import io.flutter.embedding.engine.FlutterEngine;

/**
 * Generated file. Do not edit.
 * This file is generated by the Flutter tool based on the
 * plugins that support the Android platform.
 */
@Keep
public final class GeneratedPluginRegistrant {
  private static final String TAG = "GeneratedPluginRegistrant";
  public static void registerWith(@NonNull FlutterEngine flutterEngine) {
  }
}

Graph-Generator-Flutter-App/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
SamarthTech/Hacktoberfest-Project-and-Games
/**
 * Automatically generated file. DO NOT MODIFY
 */
package com.example.graph;

public final class BuildConfig {
  public static final boolean DEBUG = Boolean.parseBoolean("true");
  public static final String APPLICATION_ID = "com.example.graph";
  public static final String BUILD_TYPE = "debug";
  public static final int VERSION_CODE = 1;
  public static final String VERSION_NAME = "1.0.0";
}

Graph-Generator-Flutter-App/build/app/generated/source/buildConfig/debug/com/example/graph/BuildConfig.java
SamarthTech/Hacktoberfest-Project-and-Games
/**
 * Automatically generated file. DO NOT MODIFY
 */
package com.example.graph;

public final class BuildConfig {
  public static final boolean DEBUG = false;
  public static final String APPLICATION_ID = "com.example.graph";
  public static final String BUILD_TYPE = "release";
  public static final int VERSION_CODE = 1;
  public static final String VERSION_NAME = "1.0.0";
}

Graph-Generator-Flutter-App/build/app/generated/source/buildConfig/release/com/example/graph/BuildConfig.java
SamarthTech/Hacktoberfest-Project-and-Games
import pyttsx3,webbrowser,datetime,wikipedia
import speech_recognition as sr
def Com_Input():
    Recognizer=sr.Recognizer()
    with sr.Microphone() as source:
        print ("InitiliZation completed")
        
        Recognizer.pause_threshold = 0.7
        audio=Recognizer.listen(source)
        while True:
            try:
                print ("Recognizing audio...")
                Query= Recognizer.recognize_google(audio,language='en-in')
                print("Command received = ",Query)
            except Exception as e:
                print(e)
                print("Please try again")
            return Query.lower()
def speak(audio):
    engine=pyttsx3.init()
    voices = engine.getProperty('voices')
    engine.setProperty('voice', voices[1].id)
    engine.say(audio)
    engine.runAndWait()
def tellDay():
    day = datetime.datetime.today().weekday() + 1
    Day_dict = {1: 'Monday', 2: 'Tuesday',
                3: 'Wednesday', 4: 'Thursday',
                5: 'Friday', 6: 'Saturday',
                7: 'Sunday'}
    if day in Day_dict.keys():
        day_of_the_week = Day_dict[day]
        print(day_of_the_week)
        speak("The day is " + day_of_the_week)
def tellTime():
    time = str(datetime.datetime.now())
    print(time)
    hour = time[11:13]
    min = time[14:16]
    speak("Yeah Abhi , the time is " + hour + "Hours and" + min + "Minutes") 
def Hello():
    speak("What's up O V ! How may I help you?")
def Take_query():
    Hello()
    while(True):
        query = Com_Input()
        if "open spotify" in query:
            speak("Opening Spotify... ")
            webbrowser.open("www.spotify.com")
            continue
        elif "open ddg"in query:
            speak("Opening DuckDuckGo... ")
            webbrowser.open("www.duckduckgo.com")
            continue
        elif "which day is it "in query:
            tellDay()
            continue
        elif "tell me the time"in query:
            tellTime()
            continue
        elif "from wikipedia" in query:
            speak("Checking Wikipedia...")
            query = query.replace("wikipedia", "")
            result = wikipedia.summary(query, sentences=4)
            speak("According to wikipedia,")
            speak(result)
            continue
        elif "tell me your name"in query:
            speak("I am Jenny . Your desktop Assistant")
            continue
        elif "bye" in query:
            speak("Bye O V")
            exit()
        else:
            speak("I didnt understand you . Please say that again.")
if __name__ == '__main__':
    Take_query()
JenAI_Prototype/JenAI_Prototype.py
SamarthTech/Hacktoberfest-Project-and-Games
import pickle
import time

#checks if the lengths of phone number, password, pin and account number are valid or not
def check_len(category,variable):
    if category=="password":
        l=8
        p="Your password is not of 8 characters. Please enter a password consisting of 8 characters: "
    elif category=="phone_number":
        l=10
        p="Enter a valid 10 digit phone number: "
    elif category=="pin":
        l=5
        p="Your pin is not of 5 digits. Please enter a valid 5 digit pin: "
    elif category=="acc_no":
        l=5
        p="Enter only the last 5 characters of your bank account number: "
    c=0
    if len(str((variable)))!=l:
        c=1
        while True:
            variable=int(input(p))
            if len(str(variable))==l:
                c=0
                break
    if category=="phone_number" or category=="acc_no":
        return c,variable
    else:
        return variable

#To open a new online bank account for the customer with unique username and password:-
def create_account_customer():       
    firstname=input("Enter your 1st name: ")
    lastname=input("Enter your last name: ")
    password=input("Create your password of 8 characters: ")
    password=check_len("password",password)
    pin=abs(int(input("Enter a 5 digit pin for account recovery and transactional actions: ")))
    pin=check_len("pin",pin)
    counter=1
    filehandle=open("UserID.dat",'rb+')
    try:
        while True:
            contents=pickle.load(filehandle)
            counter+=1
    except:
        pass
    username=firstname+'@'+str(counter)+lastname
    records={}
    records={"Sl. no.":counter,"Category":"Customer","Username":username,"Password":password,"PIN":pin}
    pickle.dump(records,filehandle)
    filehandle.close()
    print ("Your username:",username,',',"password:",password)
    print ("Congratulations, your account is created. Please exit and log in again to continue.")

    
#Checks if the user-entered password is correct:-
def check_password(username,password):
    filehandle=open("UserID.dat",'rb')
    check=3
    try:
        while True:
             contents=pickle.load(filehandle)
             if contents["Username"]==username and contents["Password"]!=password:
                 check=2
                 break
             if contents["Username"]!=username:
                 check=3
             if contents["Username"]==username and contents["Password"]==password:
                 check=1
                 break
    except:
        filehandle.close()
    return check

def check_pin(pin):
    filehandle=open("UserID.dat",'rb')
    check=3
    try:
        while True:
             contents=pickle.load(filehandle)
             if contents["PIN"]==pin:
                 check=1
                 break
             elif contents["PIN"]!=pin:
                 check=2
                 break
    except:
        filehandle.close()
    return check

#checks if unique phone number and account number are entered or not            
def check_uniqueness(category,variable,contents):
    if category=="acc_no":
        p="Enter another account number: "
        p1="account"
    else:
        p="Enter another phone number: "
        p1="phone"
    for j in contents:
        if category=="acc_no":
            i=j[5:10]
        else:
            i=j
        if str(variable)==str(i):
            while True:
                print("This",p1,"number is already in use.")
                variable=int(input(p))
                e=check_len(category,variable)
                if str(i)!=str(e[1]) and e[0]==0:
                    variable=e[1]
                    break
    return variable

        
#To enter initial account details of the customer:-
def enter_customer_account_details(username):
    print("Enter account details: ")
    phn,acc=[],[]
    filehandle3=open("Customer Account Details.dat",'rb')
    try:
        while True:
             contents=pickle.load(filehandle3)
             phn.append(contents["Phone Number"])
             acc.append(contents["Account No."])
    except:
        filehandle3.close()
    phone_number=abs(int(input("Enter the phone number linked with bank: ")))
    d=check_len("phone_number",phone_number)
    if d[0]==0:
        phone_number=check_uniqueness("phone_number",d[1],phn)
    acc_no=int(input("Enter last 5 digits of your bank account number: "))
    f=check_len("acc_no",acc_no)
    if f[0]==0:
        acc_no=check_uniqueness("acc_no",f[1],acc)
    final_acc_no="A0NBI"+str(acc_no)
    balance=abs(int(input("Enter your current balance for verification: Rs. ")))
    record={"Username":username,"Account No.":final_acc_no,"Current Balance":balance,"Phone Number":phone_number}
    filehandle=open("Customer Account Details.dat",'ab')
    pickle.dump(record,filehandle)
    filehandle.close()
    print ("Account details taken successfully.\nThe details of your account are: \n",record)

#Retrieves bank account details of the customer according to the username entered:-
def check_account_details(username):
    filehandle=open("Customer Account Details.dat",'rb')
    check=2
    details={}
    try:
        while True:
            contents=pickle.load(filehandle)
            if contents['Username']==username:
                details=contents.copy()
                print("Account Details:")
                trash=details.pop("Current Balance")
                print(details)
                check=1
    except:
        filehandle.close()
    return check

#To deposit or withdraw money from customer's bank account:-
def deposit_or_withdraw_or_loan(username,amount,task):
    filehandle=open("Customer Account Details.dat",'rb+')
    check_invalid=1
    try:
        while True:
            position=filehandle.tell()
            contents=pickle.load(filehandle)
            if contents['Username']==username:
                if task=="Withdrawal":
                    pin=int(input("Enter your 5 digit pin: "))
                    check=check_pin(pin)
                    if check==1:
                        amount=abs(int(input("Enter the amount of money you want to withdraw: Rs. ")))
                        if amount>contents["Current Balance"]:
                            print("Enough funds unavailable.")
                            check_invalid=0
                        else:
                            contents["Current Balance"]-=amount
                    else:
                        print("Invalid pin entered. Please try again.") 
                        check_invalid=0                      
                else:
                    contents["Current Balance"]+=amount
        
                if check_invalid!=0:
                    filehandle.seek(position)
                    pickle.dump(contents,filehandle)
                    updated_balance=contents["Current Balance"]
                    print ("Your updated balance is: Rs.",updated_balance)
    except:
        filehandle.close()
    if check_invalid!=0:
        filehandle2=open("Customer Transaction Details.dat",'ab+')
        records={"Username":username,"Transaction Type":task,"Amount":amount,"Current Balance":updated_balance}
        pickle.dump(records,filehandle2)
        filehandle2.close()

#Displays the transaction history of the required bank account:-
def view_transaction_history(username):
    filehandle=open("Customer Transaction Details.dat",'rb')
    check=1
    list=[]
    try:
        while True:
            contents=pickle.load(filehandle)
            if contents['Username']==username:  
                list.append(contents)
                check=2
    except:
        filehandle.close()
    pin=int(input("Enter your 5 digit pin: "))
    checkpin=check_pin(pin)
    if checkpin==1:
        print ("Transaction History:")
        for contents in list:
            print (contents)
    elif checkpin==2:
        print("Invalid pin entered. Please try again.") 
        check=3  
    return check   


#If the customer wants to change his/her password or to reset the password for account recovery:-
def change_or_reset_password(category, username):
    check=0
    if category=="change":
        pin=int(input("Enter your 5 digit pin: "))
        check=check_pin(pin)
    filehandle=open("UserID.dat",'rb+')
    try:
        while True:
             position=filehandle.tell()
             contents=pickle.load(filehandle)
             if contents['Username']==username:
                 if check==2:
                     print ("Invalid pin entered. Please try again.")
                 elif check==0 or check==1:
                    new_password=input("Enter new password: ")
                    new_password=check_len("password",new_password)
                    contents["Password"]=(new_password)
                    filehandle.seek(position)
                    pickle.dump(contents,filehandle)
                    print ("Password successfully changed. Please log in again to continue.")                
             else:
                 pass         
    except:
        filehandle.close()


#If the customer wishes to apply for a loan:-
def personal_car_home_education_loan(username,choice):
    filehandle=open("Customer Account Details.dat",'rb')
    if choice==1:
        minimum_balance=15000
        rate_of_interest=15
        type_of_loan="Personal Loan"
    elif choice==2:
        minimum_balance=75000
        rate_of_interest=8.25
        type_of_loan="Car Loan"        
    elif choice==3:
        minimum_balance=55000
        rate_of_interest=7.5
        type_of_loan="Home Loan"
    elif choice==4:
        minimum_balance=40000
        rate_of_interest=7.1
        type_of_loan="Educational Loan"
    check=0
    try:
        while True:
            contents=pickle.load(filehandle)
            if contents['Username']==username:
                if contents["Current Balance"]>=minimum_balance:
                    check=1
                else:
                    check=0
    except:
        filehandle.close()
    if check==1:
        amount=abs(int(input("Enter the amount of loan you need: Rs. ")))
        years=abs(int(input("Enter the number of years for which you need the loan (max. 5 years): ")))
        if years<=5 and years>0:
            print ("You will be charged an interest rate of",rate_of_interest,"% p.a. and a processing fee of 1.25%")
            total_amount=int(amount+((rate_of_interest*amount*years)/100)+(0.0125*amount))
            monthly_amount=int((total_amount/12)/years)
            print ("So, you will have to pay a total sum of Rs.",total_amount,"in monthly installments of Rs.",monthly_amount,"via cash or cheque.")
            choice=input("Do you agree to the terms and conditions? (y/n): ")
            if choice in ('y','Y'):
                print("The amount of Rs.",amount,"has been credited to your account.")
                deposit_or_withdraw_or_loan(username,amount,type_of_loan)
            else:
                print ("Loan application terminated.")
        else:
            print ("Invalid Input")
            print ("Loan application unsuccessful. Please retry")
    elif check==0:
        print ("You do not have the minimum account balance required for loan application")

#Loan options(personal,car,home or education):-
def loan(username):
    choice=int(input('''Enter 1 for personal loan,
Enter 2 for car loan,
Enter 3 for home loan,
Enter 4 for educational loan: '''))
    if choice not in (1,2,3,4):
        print ("Invalid Input. Try again.")
    else:
        personal_car_home_education_loan(username,choice)    
        
#Customer care details:-  
def customer_care():
    print ('''To contact us, write to us at customersupport@nbi.in or
contact us at 033 6571 8888/8889. Thank you.''')


print ("Welcome to National Bank of India's Online Banking System")
username=input("Enter your username: ")
password=input("Enter your password: ")
check=check_password(username,password)
if check==1:
    acc_details=check_account_details(username)
    if acc_details==2:
        print ("Account Details not found.")
        enter_customer_account_details(username)
    while True:
        choice=int(input('''Enter 1 for viewing your account details,
Enter 2 to to deposit money,
Enter 3 to withdraw money,
Enter 4 for viewing your transaction history and checking balance,
Enter 5 for loan,
Enter 6 for changing password,
Enter 7 to contact us at our customer care,
Enter 8 to log out: '''))
        if choice in (1,2,3,4,5,6,7,8):
            if choice==2:
                amount=abs(int(input("Enter the amount of money you want to deposit: Rs. ")))
                task="Deposit"
                deposit_or_withdraw_or_loan(username,amount,task)
            if choice==3:
                amount=0
                task="Withdrawal"
                deposit_or_withdraw_or_loan(username,amount,task)
            if choice==4:
                transaction_history=view_transaction_history(username)
                if transaction_history==1:
                    print ("No transaction details found")
            if choice==6:
                change_or_reset_password("change",username)
                break          
            if choice==1:
                acc_details=check_account_details(username)
                if acc_details==2:
                    print ("Account Details not found.")
            if choice==7:
                customer_care()
            if choice==5:
                loan(username)
            if choice==8:
                print ("Successfully Logged Out. Please do not share your username or password with anyone.")
                break
        else:
            print ("Invalid Input")
        time.sleep(2)
elif check==3:
    print ("Username does not exist.")
    choice=input("Do you want to create a new account? (y/n): ")
    if choice in ('y','Y'):
        create_account_customer()
elif check==2:
    print ("Invalid Password")
    choice=input("To reset your password press '1':")
    if choice=='1':
        for i in range (1,4):
            pin=int(input("Enter your 5 digit pin: "))
            checkpin=check_pin(pin)
            if checkpin==1:
                change_or_reset_password("reset",username)
                c=1
                break
            elif checkpin==2:
                print("Invalid pin entered.") 
                print (3-i,"attempt(s) left.")
            if i==3:
                print("Please contact our branch with valid documents to recover account.")

Online Banking Software/Main.py
SamarthTech/Hacktoberfest-Project-and-Games
# password strength checker
import re
import random

class PasswordStrengthChecker:
    def __init__(self, password):
        self.password = password

    def check_password_strength(self):
        score = 0

        # Check length of password
        if len(self.password) < 8:
            return "Very Weak"
        elif len(self.password) >= 8 and len(self.password) <= 10:
            score += 1
        elif len(self.password) > 10:
            score += 2

        # Check for uppercase letters
        if re.search(r'[A-Z]', self.password):
            score += 1

        # Check for lowercase letters
        if re.search(r'[a-z]', self.password):
            score += 1

        # Check for numbers
        if re.search(r'\d', self.password):
            score += 1

        # Check for special characters
        if re.search(r'[^A-Za-z0-9]', self.password):
            score += 2

        # Return password strength based on score
        if score == 0:
            return "Very Weak"
        elif score == 1:
            return "Weak"
        elif score == 2:
            return "Medium"
        elif score == 3:
            return "Strong"
        else:
            return "Very Strong"

class User:
    def __init__(self, username, password):
        self.username = username
        self.password = PasswordStrengthChecker(password)
        self.password_history = [password]

    def change_password(self, new_password):
        """
        This function changes the user's password and adds the old password to
        the password history.
        """
        old_password = self.password.password
        self.password_history.append(old_password)
        self.password = PasswordStrengthChecker(new_password)

    def reset_password(self):
        """
        This function generates a new random password for the user and adds it to
        the password history.
        """
        new_password = self.generate_random_password()
        self.password_history.append(self.password.password)
        self.password = PasswordStrengthChecker(new_password)
        return new_password

    def generate_random_password(self):
        """
        This function generates a random password of length 10 with at least one
        uppercase letter, one lowercase letter, one number, and one special
        character.
        """
        chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()'
        password = ''.join(random.choice(chars) for i in range(10))
        while not (re.search(r'[A-Z]', password) and re.search(r'[a-z]', password) and re.search(r'\d', password) and re.search(r'[^A-Za-z0-9]', password)):
            password = ''.join(random.choice(chars) for i in range(10))
        return password

    def login(self, password):
        """
        This function checks if the password is valid for the user and returns True
        if it is, or False if it is not.
        """
        if self.password.password != password:
            print("Incorrect password.")
            return False
        else:
            print("Welcome back, {}!".format(self.username))
            return True

# example usage
# create a new user with a password
user1 = User("johndoe", "MyPassword1!")

# check the strength of the password
print(user1.password.check_password_strength())  # prints "Medium"

# attempt to login with the wrong password
user1.login("WrongPassword1!")  # prints "Incorrect password." and returns False

# attempt to login with the correct password
user1.login("MyPassword1!")  # prints "Welcome back, johndoe!" and returns True

# change the user's password
user1.change_password("NewPassword123!")

# check the strength of the new password
print(user1.password.check_password_strength())  # prints "Strong"

# reset the user's password
new_password = user1.reset_password()

# check the strength of the new password
print(user1.password.check_password_strength())  # prints "Very Strong"

Password_Generator_And_Strength_Checker.py
SamarthTech/Hacktoberfest-Project-and-Games
# A Python program which takes data from user's clipboard, Parses it for all Email addresses and Phone Numbers.
#Writes them to separate files and copies the entire data to the clipboard.
import re,pyperclip,pprint
PhoneFile = open("Phone.txt", "a+")
EmailFile = open("Email.txt", "a+")
EmailRegex=re.compile(r'[a-zA-Z0-9.+_]+\@[a-zA-Z0-9.+_]+')
#PhoneRegex=re.compile(r'\d\d\d-\d\d\d-\d\d\d\d') # for US
PhoneRegex=re.compile(r'\+91\d{10}') # for India 
Text=pyperclip.paste()
ExtractedPhone=PhoneRegex.findall(Text)
ExtractedEmail=EmailRegex.findall(Text)
AllPhone=[]
for Number in ExtractedPhone:
    PhoneFile.write(Number)
for Mail in ExtractedEmail:
    EmailFile.write(Mail)
print("Phone Numbers : ",end='\n')
pprint.pprint(ExtractedPhone)
print("Emails : ",end='\n')
pprint.pprint(ExtractedEmail)
Results= '\n'.join(ExtractedPhone)+'\n'+'\n'.join(ExtractedEmail)
pyperclip.copy(Results)
PhoneFile.close()
EmailFile.close()


Phone&Email_Parser/PhoneEmailParsing.py
SamarthTech/Hacktoberfest-Project-and-Games
package SF;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.Random;

import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.Timer;

public class GamePlay extends JPanel implements KeyListener, ActionListener{
	
	private int [] snakeXlength = new int [750];
	private int [] snakeYlength = new int [750];
	
	//check the direction of snake
	private boolean left = false;
	private boolean right = false;
	private boolean up = false;
	private boolean down = false;

	//Image of Head Position of the snake
	private ImageIcon headRight;
	private ImageIcon headLeft;
	private ImageIcon headUp;
	private ImageIcon headDown;
	
	
	//Initial length of the snake
	private int lengthOfSnake = 3;
	
	private Timer timer;
	private int delay = 100;
	
	//Image of Tail of the snake
	private ImageIcon tail;
	
	private int moves=0;
	private int score=0;	//Initial score the game
	
	//Fruit Parameters
	private int [] fruitXpos = {25,50,75,100,125,150,175,200,225,250,275,300,325,250,375,400,425,450,475,500,525,550,575,600,
			625,650,675,700,725,750,775,800,825,850};
	
	private int [] fruitYpos = {75,100,125,150,175,200,225,250,275,300,325,250,375,400,425,450,475,500,525,550,575,600,
			625};
	
	private ImageIcon fruitImage;
	
	private Random random = new Random();
	private int xpos = random.nextInt(34);
	private int ypos = random.nextInt(24);
	
	private ImageIcon titleImage;
	
	public GamePlay()
	{
		addKeyListener(this);
		setFocusable(true);
		setFocusTraversalKeysEnabled(false);
		
		timer = new Timer(delay, this);
		timer.start();
	}
	
	public void paint(Graphics g)
	{
		
		if(moves == 0)
		{
			snakeXlength[0] = 100;
			snakeXlength[1] = 75;
			snakeXlength[2] = 50;
			
			snakeYlength[0] = 100;
			snakeYlength[1] = 100;
			snakeYlength[2] = 100;

		}
		
		//Display Title
//		titleImage = new ImageIcon("res/Images/title.png");
		titleImage = new ImageIcon(getClass().getClassLoader().getResource("title.png"));
		titleImage.paintIcon(this, g, 25, 5);
		
		//Display gamePlay border
		g.setColor(Color.DARK_GRAY);
		g.drawRect(24, 74, 851, 577);
		
		//Display GamePlay Background
		g.setColor(Color.black);
		g.fillRect(25, 75, 850, 575);
		
		
		//Draw Score and length
		g.setColor(Color.white);
		g.setFont(new Font("areal", Font.PLAIN, 15));
		g.drawString("Scores:" + score, 780, 30);
		
		
		g.setColor(Color.white);
		g.setFont(new Font("areal", Font.PLAIN, 14));
		g.drawString("Length:" + lengthOfSnake, 780, 50);
		
		//Initial position of the headRight image
//		headRight = new ImageIcon("res/Images/headRight.png");
		headRight = new ImageIcon(getClass().getClassLoader().getResource("headRight.png"));
		headRight.paintIcon(this, g, snakeXlength[0], snakeYlength[0]);
		
		for(int i = 0; i < lengthOfSnake; i++)
		{
			if(i == 0 && right)
			{
//				headRight = new ImageIcon("res/Images/headRight.png");
				headRight = new ImageIcon(getClass().getClassLoader().getResource("headRight.png"));
				headRight.paintIcon(this, g, snakeXlength[i], snakeYlength[i]);
			}
			
			if(i == 0 && left)
			{
//				headLeft = new ImageIcon("res/Images/headLeft.png");
				headLeft = new ImageIcon(getClass().getClassLoader().getResource("headLeft.png"));
				headLeft.paintIcon(this, g, snakeXlength[i], snakeYlength[i]);
			}
			
			if(i == 0 && up)
			{
//				headUp = new ImageIcon("res/Images/headUp.png");
				headUp = new ImageIcon(getClass().getClassLoader().getResource("headUp.png"));
				headUp.paintIcon(this, g, snakeXlength[i], snakeYlength[i]);
			}
			
			if(i == 0 && down)
			{
//				headDown = new ImageIcon("res/Images/headDown.png");
				headDown = new ImageIcon(getClass().getClassLoader().getResource("headDown.png"));
				headDown.paintIcon(this, g, snakeXlength[i], snakeYlength[i]);
			}
			
			//When we are in tail position
			if(i!=0)
			{
//				tail = new ImageIcon("res/Images/tail.png");
				tail = new ImageIcon(getClass().getClassLoader().getResource("tail.png"));
				tail.paintIcon(this, g, snakeXlength[i], snakeYlength[i]);
			}
			
			//Fruit Image
//			fruitImage = new ImageIcon("res/Images/fruit.png");
			fruitImage = new ImageIcon(getClass().getClassLoader().getResource("fruit.png"));
			
			if(fruitXpos[xpos] == snakeXlength[0] && fruitYpos[ypos] == snakeYlength[0])
			{
				score+=5;
				lengthOfSnake++;
				xpos = random.nextInt(34);
				ypos = random.nextInt(21);
			}
			fruitImage.paintIcon(this, g, fruitXpos[xpos], fruitYpos[ypos]);
		}
		
		
		for(int i = 1; i< lengthOfSnake; i++)
		{
			//If its head touches its body part
			if(snakeXlength[i] == snakeXlength[0] && snakeYlength[i] == snakeYlength[0])
			{
				right = false;
				left = false;
				up = false;
				down = false;
//				timer.stop();
				
				//Display the Game Over
				g.setColor(Color.red);
				g.setFont(new Font("areal", Font.BOLD, 40));
				g.drawString("GAME OVER!!! Score:" + score, 250, 300);
				
				//Display Press any Key to continue
				g.setColor(Color.WHITE);
				g.setFont(new Font("areal", Font.BOLD, 20));
				g.drawString("Press ENTER to Restart", 350, 340);
				
			}
		}
		
		
		
		g.dispose();
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		
		timer.restart();
		
		if(right)
		{
			for(int n = lengthOfSnake-1; n>=0; n--)
			{
				snakeYlength[n+1] = snakeYlength[n];
			}
			
			for(int n = lengthOfSnake; n>=0; n--)
			{
				
				if(n==0)
				{
					snakeXlength[n] = snakeXlength[n] + 25;
				}
				else
				{
					snakeXlength[n] = snakeXlength[n-1];
				}
				//If border crossed
				if(snakeXlength[n] > 850)
				{
					snakeXlength[n] = 25;
				}
			}
			
			repaint();
		}
		
		
		if(left)
		{
			for(int n = lengthOfSnake-1; n>=0; n--)
			{
				snakeYlength[n+1] = snakeYlength[n];
			}
			
			for(int n = lengthOfSnake; n>=0; n--)
			{
				
				if(n==0)
				{
					snakeXlength[n] = snakeXlength[n] - 25;
				}
				else
				{
					snakeXlength[n] = snakeXlength[n-1];
				}
				//If border crossed
				if(snakeXlength[n] < 25)
				{
					snakeXlength[n] = 850;
				}
			}
			
			repaint();
		}
		
		
		if(up)
		{
			for(int n = lengthOfSnake-1; n>=0; n--)
			{
				snakeXlength[n+1] = snakeXlength[n];
			}
			
			for(int n = lengthOfSnake; n>=0; n--)
			{
				
				if(n==0)
				{
					snakeYlength[n] = snakeYlength[n] - 25;
				}
				else
				{
					snakeYlength[n] = snakeYlength[n-1];
				}
				//If border crossed
				if(snakeYlength[n] < 75)
				{
					snakeYlength[n] = 625;
				}
			}
			
			repaint();
		}
		
		
		if(down)
		{
			for(int n = lengthOfSnake-1; n>=0; n--)
			{
				snakeXlength[n+1] = snakeXlength[n];
			}
			
			for(int n = lengthOfSnake; n>=0; n--)
			{
				
				if(n==0)
				{
					snakeYlength[n] = snakeYlength[n] + 25;
				}
				else
				{
					snakeYlength[n] = snakeYlength[n-1];
				}
				//If border crossed
				if(snakeYlength[n] > 625)
				{
					snakeYlength[n] = 75;
				}
			}
			
			repaint();
		}
	}

	@Override
	public void keyTyped(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyPressed(KeyEvent e) {
		
		
		//For Enter Key is Pressed
		if(e.getKeyCode() == KeyEvent.VK_ENTER)
		{
			moves = 0;
			score = 0;
			lengthOfSnake = 3;
			repaint();
		}
		
		//For Right Arrow Press
		if(e.getKeyCode() == KeyEvent.VK_RIGHT)
		{
			moves++;
			right = true;
			
			//if direction if right keep moving towards right
			if(!left)
			{
				right = true;
			}
			//If direction is left,keep moving towards left, and can't go right even by pressing Right Arrow key
			else
			{
				right = false;
				left = true;
			}
			
			up = false;
			down = false;
		}
		
		
		//For Left Arrow Press
		if(e.getKeyCode() == KeyEvent.VK_LEFT)
		{
			moves++;
			left = true;
			
			//if direction if right keep moving towards right
			if(!right)
			{
				left = true;
			}
			//If direction is left,keep moving towards left, and can't go right even by pressing Right Arrow key
			else
			{
				left = false;
				right = true;
			}
			
			up = false;
			down = false;
		}
		
		
		//For Up Arrow Press
		if(e.getKeyCode() == KeyEvent.VK_UP)
		{
			moves++;
			up = true;
			
			//if direction if right keep moving towards right
			if(!down)
			{
				up = true;
			}
			//If direction is left,keep moving towards left, and can't go right even by pressing Right Arrow key
			else
			{
				up = false;
				down = true;
			}
			
			left = false;
			right = false;
		}
		
		
		//For Down Arrow Press
		if(e.getKeyCode() == KeyEvent.VK_DOWN)
		{
			moves++;
			down = true;
			
			//if direction if right keep moving towards right
			if(!up)
			{
				down = true;
			}
			//If direction is left,keep moving towards left, and can't go right even by pressing Right Arrow key
			else
			{
				down = false;
				up = true;
			}
			
			left = false;
			right = false;
		}
		
	}

	@Override
	public void keyReleased(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

}

Snake-Feeder/src/SF/GamePlay.java
SamarthTech/Hacktoberfest-Project-and-Games
package SF;

import java.awt.Color;

import javax.swing.JFrame;


public class Main {
	
	//Game frame size
	public static int frameWidth = 905;
	public static int frameHeight = 700;

	public static void main(String[] args) {
		
		JFrame obj = new JFrame();
		GamePlay gamePlay = new GamePlay();
		
		obj.setBounds(350, 50,frameWidth, frameHeight); //size of the frame
		obj.setTitle("Developed by  Santanu Pal");	//Title of the Game frame
		obj.setBackground(Color.DARK_GRAY);
		obj.setResizable(false);	// Is frame Re-sizable or not
		obj.setVisible(true);		//Frame visible 
		obj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);		//action on close option
		
		obj.add(gamePlay);

	}

}

Snake-Feeder/src/SF/Main.java
SamarthTech/Hacktoberfest-Project-and-Games
import turtle  #turtle is a library which helps to make shapes/design using turtle object
from time import time   #time is a library used to pause or delay the execution of our code.
from random import randint  #random is library contains randint/randrange/random
from tkinter import * #tkinter is a library used to build GUI in python
from PIL import Image,ImageTk #Python Imaging Library - 2 functions built in
import mysql.connector  #msql is RDBMS,for connectivity with py and sql
import pygame
score=0
W='' #since our W is global , ao to assign some value to it....


def snake2():
     pygame.mixer.init() #initializes the audio mixer in Pygame
     sound = pygame.mixer.Sound("s1.mp3")
     sound.play()
     import turtle 
     import random
     import time
     delay=0.1 #produce gap in between the snake movement
     score=0

     #snakebodies
     bodies=[] #array to store body of snake
     position=[(0,0),(600,600),(-100,200),(0,180),(-250,250),(-220,0),(-290,290)] #array of positions
     
     #Getting a screen canvas
     W.destroy()
     s=turtle.Screen() #get screen
     s.title("Snake Game")
     s.bgcolor("white")
     s.setup(width=position[1][0],height=position[1][1])
     s.bgpic("hell.gif")
     
     
     
     #Create snake head
     head=turtle.Turtle() #turtle.Turtle() function to create a turtle object 
     head.speed(0)        #the turtle object head is being set to the fastest speed of 0(no delay)(random and smooth)
                          #10 is slowest
     head.shape("square")
     head.color("white")
     head.fillcolor("#8B1C62")
     head.penup()         #movement by the turtle will not leave a trace on the screen
     head.goto(position[0]) #goto takes 1 argument atleast
     head.direction="stop" #not move


     #snake food
     food=turtle.Turtle()
     food.speed(0)
     food.shape("square")
     food.color("yellow")
     food.fillcolor("red")
     food.penup()
     food.ht()   #hide turtle
     food.goto(position[3])
     food.st()   #show turtle


     #score board
     sb=turtle.Turtle()
     sb.shape("square")
     sb.fillcolor("black")
     sb.penup()
     sb.ht()#to hide the turtle at that posn
     sb.goto(position[2])
     sb.color("#DC143C")
     sb.write("Score : 0 ",font=("Courier",30,"bold"))

     
     def moveup():
          if head.direction!="down": #only move up when its not down(else reverse movement is there)
               head.direction="up"

     def movedown():
          if head.direction!="up":
               head.direction="down"

     def moveleft():
          if head.direction!="right":
               head.direction="left"

     def moveright():
          if head.direction!="left":
               head.direction="right"

     def movestop():
          head.direction="stop"  #game over on space key

     def move():
          if head.direction=="up":
               y=head.ycor()
               head.sety(y+20) #basically taking prev y coordinate
                               #if going up then move its movement by 20 units. 
          if head.direction=="down":
               y=head.ycor()
               head.sety(y-20)
          if head.direction=="left":
               x=head.xcor()
               head.setx(x-20)
          if head.direction=="right":
               x=head.xcor()
               head.setx(x+20)
          
          
     #Handling - key mappings

     s.listen() #the program can listen for and respond to keyboard events.
     s.onkey(moveup,"Up")
     s.onkey(movedown,"Down")
     s.onkey(moveleft,"Left")
     s.onkey(moveright,"Right")
     s.onkey(movestop,"space")   

     while True:
          s.update() #update the turtle graphics window,any changes made displayed immediately.
          
          #collision with border
          
          if head.xcor()>290:
               head.setx(-290)
          if head.xcor()<-290:
               head.setx(290)
          if head.ycor()>290:
               head.sety(-290)
          if head.ycor()<-290:
               head.sety(290)
               
          #collision with food
          if head.distance(food)<25:
               #random generation
               sound1 = pygame.mixer.Sound("eat.mp3")
               sound1.play()
               x=random.randint(-250,250)
               y=random.randint(-250,250)
               food.goto(x,y)

               #increases the length of the snake
               body=turtle.Turtle()
               body.speed(0)
               body.penup()
               body.shape("square")
               body.color("red")
               body.fillcolor("black")
               bodies.append(body) 

               #increases the score
               score+=10
               
               sb.clear() #means score 0 to change i.e. +10
               sb.color("#DC143C")
               sb.write(f"Score: {score}",font=("Courier",30,"bold"))#f string basically telling that {}is variable not a string

          #move the snake bodies it is the implementation of "stack"
          #basically head stored then others add at back
          #and take last and move and head at last to direction
          for index in range(len(bodies)-1,0,-1): #if 3 objects then head is 0 and else is 1&2 .                    
               x=bodies[index-1].xcor()           #take aage wala part before head and coordin. and goto next part
               y=bodies[index-1].ycor()
               bodies[index].goto(x,y)
          if len(bodies)>0:                       #for head ke peeche to move onto head
               x=head.xcor()
               y=head.ycor()
               bodies[0].goto(x,y)
          move()
           
          #collision with snake body
          for body in bodies:
               if body.distance(head)<20:#each part if distance from body is less than 20
                    sound.stop()
                    head.direction="stop"
               
                    #hide bodies
                    for body in bodies:
                         body.ht()
                    bodies.clear()
                    head.ht()
                    food.ht()
                    x = turtle.Turtle()
                    x.hideturtle()
                    x.penup()
                    x.goto(position[5])
                    x.color("#FF6103")
                    sound2 = pygame.mixer.Sound("gameover.wav")
                    sound2.play()
                    x.write("  G A M E   O V E R  ",font=("Tahoma",35,"bold"))
                    
                    #update score board
                    sb.clear()
                    con= mysql.connector.connect(
                    user="root",password="tiger",database="snake")
                    cur= con.cursor()
                    query="INSERT INTO score VALUES ({})".format(score)
                    cur.execute(query)
                    cur.execute("commit") #commit to reach successfully
                    con.close()
                    sb.color("#DC143C")
                    sb.write("Score: {}".format(score),font=("Courier",30,"bold"))
                    time.sleep(2)#screen delay for 2s
                    pygame.mixer.stop()
                    s.bye()
                    GUI()
                            
          time.sleep(delay)
          #pauses the execution for sometime so that the game does not run too fast for the player to follow.
     s.mainloop() #to start turtle module
     
     

def viewhigh():
     con= mysql.connector.connect(
     user="root",password="tiger",database="snake")
     cur= con.cursor() #con is to connect py and mysql
                       #cue is to execute query to respond ,cursor do all the things
     W=Tk()       
     W.geometry("200x150")
     W.configure(bg="light blue")
     W.title("HIGH SCORE")
     cur.execute("SELECT max(Score) from score")
     max_score = cur.fetchone()[0] #fetch one record in tuples
     label = Label(W,text="Highest score: {}".format(max_score), font=("Arial", 16), fg="black")
     #its a lable widget to write on window and label use padx , pady (not place method for coodinates)
     label.pack(pady=50)#creates 50pixels (dist) below so in middle it will show
     W.mainloop()

def instruct():
     W=Tk()
     W.geometry("550x450")
     W.configure(bg="orange")
     W.title("READ INSTRUCTIONS")
     L1=Label(W,text=" GAME  INSTRUCTIONS",bg="yellow",font=("TIMES NEW ROMAN",27,"bold"))
     L1.pack(fill=BOTH,padx=0,pady=0)

     L2=Label(W,text=" HOW  TO  PLAY ? ",bg="yellow",font=("TIMES NEW ROMAN",27,"bold"))
     L2.place(x=0,y=50)
     L2.pack(fill=BOTH)
     
     L3=Label(W,text=" 1) Use the arrow keys to navigate. ",bg="green",font=("TIMES NEW ROMAN",17,"bold"))
     L3.pack(fill=BOTH)
     L3.place(x=0,y=120)
     
     L4=Label(W,text=" 2) Eat the fruits to increase your score. ",bg="green",font=("TIMES NEW ROMAN",17,"bold"))
     L4.pack(fill=BOTH)
     L4.place(x=0,y=180)
     
     L5=Label(W,text=" 3) The snake can go through the boundaries. ",bg="green",font=("TIMES NEW ROMAN",17,"bold"))
     L5.pack(fill=BOTH)
     L5.place(x=0,y=240)

     L6=Label(W,text=" 4) If the head of the snake touches its body, you lose. ",bg="green",font=("TIMES NEW ROMAN",17,"bold"))
     L6.pack(fill=BOTH)
     L6.place(x=0,y=300)

     L7=Label(W,text=" 5) Use the space bar to quit. ",bg="green",font=("TIMES NEW ROMAN",17,"bold"))
     L7.pack(fill=BOTH)
     L7.place(x=0,y=360)
     
     
     
def GUI():
     global W
     W=Tk() #creates a window stored in W
     W.geometry("840x540")
     W.configure(bg="#9A32CD")
     W.title("WELCOME TO SNAKE GAME WINDOW")
     image=Image.open("ss.jpeg") #open func to take image 
     R=image.resize((300,400))     #crop and it is pixels
     R1=ImageTk.PhotoImage(R)      #type of image that can be displayed in a Tkinter window.
     Lb=Label(W,image=R1)          #box where image is to be displayed on window
     Lb.place(x=80,y=100)
     L1=Label(W,text=" PYTHON  PLAYGROUND ",bg="yellow",font=("TIMES NEW ROMAN",47,"bold"))
     L1.pack(fill=BOTH,padx=0,pady=0) #label so pad , and to start and end filled completely.fill both means take both xy

     F=Frame(height=400,bg="#E066FF",width=350)
     F.place(x=440,y=100)

     B1=Button(F,text="P L A Y",relief=SUNKEN,bg="#E0FFFF",command=snake2,fg="black",font=("Arial",20,"bold")).place(x=115,y=30)
     B2=Button(F,text="Q U I T",relief=GROOVE,bg="#E0FFFF",fg="black",command=W.destroy,font=("Arial",20,"bold")).place(x=115,y=310)
     B3=Button(F,text="H I G H S C O R E",command=viewhigh,relief=GROOVE,bg="#E0FFFF",fg="black",font=("Arial",20,"bold")).place(x=50,y=120)
     B4=Button(F,text="I N S T R U T I O N S",command=instruct,relief=GROOVE,bg="#E0FFFF",fg="black",font=("Arial",20,"bold")).place(x=25,y=215)
     W.mainloop() #interactions in a timely and efficient manner.
     #relief is txt on button how to display - raised , flat,etc.

GUI()

     



Snake/hello.py
SamarthTech/Hacktoberfest-Project-and-Games
import pygame
import time
import random

pygame.init()


snake_speed = 15
 
window_x = 720
window_y = 480
 
black = pygame.Color(0, 0, 0)
white = pygame.Color(255, 255, 255)
red = pygame.Color(255, 0, 0)
green = pygame.Color(0, 255, 0)
blue = pygame.Color(0, 0, 255)

pygame.display.set_caption('Snake game')
game_window = pygame.display.set_mode((window_x, window_y))
fps = pygame.time.Clock()

snake_position = [100, 50]
 
snake_body = [  [100, 50],
                [90, 50],
                [80, 50],
                [10, 50]
            ]

fruit_position = [random.randrange(1, (window_x//10)) * 10,
                  random.randrange(1, (window_y//10)) * 10]
fruit_spawn = True
 
direction = 'RIGHT'
change_to = direction

score = 0
 
def show_score(choice, color, font, size):
    score_font = pygame.font.SysFont(font, size)
    score_surface = score_font.render('Score : ' + str(score), True, color)
    score_rect = score_surface.get_rect()
    game_window.blit(score_surface, score_rect)

def game_over():
    my_font = pygame.font.SysFont('times new roman', 50)
    game_over_surface = my_font.render('Your Score is : ' + str(score), True, red)
    game_over_rect = game_over_surface.get_rect()
    game_over_rect.midtop = (window_x/2, window_y/4)
    game_window.blit(game_over_surface, game_over_rect)
    pygame.display.flip()
    time.sleep(2)
    pygame.quit() 
    quit()
    
while True:
   
    for event in pygame.event.get():
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_UP:
                change_to = 'UP'
            if event.key == pygame.K_DOWN:
                change_to = 'DOWN'
            if event.key == pygame.K_LEFT:
                change_to = 'LEFT'
            if event.key == pygame.K_RIGHT:
                change_to = 'RIGHT'
 
    if change_to == 'UP' and direction != 'DOWN':
        direction = 'UP'
    if change_to == 'DOWN' and direction != 'UP':
        direction = 'DOWN'
    if change_to == 'LEFT' and direction != 'RIGHT':
        direction = 'LEFT'
    if change_to == 'RIGHT' and direction != 'LEFT':
        direction = 'RIGHT'
 
    if direction == 'UP':
        snake_position[1] -= 10
    if direction == 'DOWN':
        snake_position[1] += 10
    if direction == 'LEFT':
        snake_position[0] -= 10
    if direction == 'RIGHT':
        snake_position[0] += 10
 
    snake_body.insert(0, list(snake_position))
    if snake_position[0] == fruit_position[0] and snake_position[1] == fruit_position[1]:
        score += 10
        fruit_spawn = False
    else:
        snake_body.pop()
         
    if not fruit_spawn:
        fruit_position = [random.randrange(1, (window_x//10)) * 10,
                          random.randrange(1, (window_y//10)) * 10]
         
    fruit_spawn = True
    game_window.fill(black)
     
    for pos in snake_body:
        pygame.draw.rect(game_window, green, pygame.Rect(
          pos[0], pos[1], 10, 10))
         
    pygame.draw.rect(game_window, white, pygame.Rect(
      fruit_position[0], fruit_position[1], 10, 10))
 
    if snake_position[0] < 0 or snake_position[0] > window_x-10:
        game_over()
    if snake_position[1] < 0 or snake_position[1] > window_y-10:
        game_over()
     
    for block in snake_body[1:]:
        if snake_position[0] == block[0] and snake_position[1] == block[1]:
            game_over()
     
    show_score(1, white, 'times new roman', 20)
    pygame.display.update()
    fps.tick(snake_speed)
SnakeGame/SnakeGame.py
SamarthTech/Hacktoberfest-Project-and-Games
import language_tool_python
import csv

def content_filtration(body):
    points=0
    body_lower=body.lower()
    body_list=body_lower.split(" ")
    f=open("spam_emails.csv","r")
    s=csv.reader(f)
    for j in s:
        count=0
        list=j[0].split(" ")
        list=list[1:]
        if len(body_list)<len(list):
            for i in range (len(body_list)):
                if list[i]==body_list[i]:
                    count+=1
        else:
            for i in range (len(list)):
                if list[i]==body_list[i]:
                    count+=1        
        if count>7 or len(body_list)<7:
            points=5
            break
    f.close()
    error_tool=language_tool_python.LanguageTool("en-US")
    error=error_tool.check(body)
    if (len(body_list)>=25 and len(error)>=8) or (len(body_list)<25 and len(error)>0.25*len(body_list)):
        points+=5
    if points>=5  and count!=len(body_list):
        with open("spam_emails.csv",'a',newline="", encoding='utf-8') as f:
            csvwriter=csv.writer(f)
            column1="Subject: "+body_lower
            row=[column1,'1']
            csvwriter.writerow(row)
    return points

def domain_filtration(id):
    f=open("domains.csv","r")
    domain_list=id.split("@")[1].split(".")
    s=csv.reader(f)
    a,b=0,0
    c,d=0,0
    counter=0
    domain_points=0
    if len(domain_list)<=2 and len(domain_list)>0:
        for j in s:
            if domain_list[0]==j[0][1:]:
                a=1
                c=counter
            if domain_list[1]==j[0][1:]:
                b=1
                d=counter
            counter+=1
        if c!=d:
            if a==1 and b==1:
                domain_points=0
            else:
                domain_points=5
        else:
            domain_points=5
    else:
        domain_points=5
    f.close()
    username=id.split("@")[0]
    username_points=0
    if " " in username or "+" in username or username.count(".")>2:
        username_points=5
    return domain_points+username_points

def header_filtration(header):
    header_lower=header.lower()
    header_list=header_lower.split(" ")
    f=open("headers.csv","r")
    points=0
    s=csv.reader(f)
    for j in s:
        count=0
        list=j[1].split(" ")
        list=list[1:]
        if len(header_list)<len(list):
            for i in range (len(header_list)):
                if list[i]==header_list[i]:
                    count+=1
        else:
            for i in range (len(list)):
                if list[i]==header_list[i]:
                    count+=1      
        if count>=len(header_list)-1:
            points=5
            break
    f.close()
    error_tool=language_tool_python.LanguageTool("en-US")
    error=error_tool.check(header)
    if (len(header_list)>=25 and len(error)>=8) or (len(header_list)<25 and len(error)>0.25*len(header_list)):
        points+=5
    if points>=5  and count!=len(header_list):
        with open("headers.csv",'a',newline="", encoding='utf-8') as f:
            csvwriter=csv.writer(f)
            column2="Subject: "+header_lower
            row=['spam',column2,'1']
            csvwriter.writerow(row)
    return points

def mark_as_spam(header,body):
    with open("spam_emails.csv",'a',newline="", encoding='utf-8') as f:
        csvwriter=csv.writer(f)
        column1="Subject: "+body.lower()
        row=[column1,'1']
        csvwriter.writerow(row)
    with open("headers.csv",'a',newline="", encoding='utf-8') as f1:
        csvwriter=csv.writer(f1)
        column2="Subject: "+header.lower()
        row=['spam',column2,'1']
        csvwriter.writerow(row)
    return "Email marked as spam successfully"

id=input("Enter the email id of the sender for domain filtration: ")
id=id.lower()
header=input("Enter the header of the email for header filtration: ")
body=input("Enter the content of the email for content filtration: ")
print("-------------Checking--------------")
id_points=domain_filtration(id)
header_points=header_filtration(header)
print("-----This might take some time-----")
body_points=content_filtration(body)
if id_points+header_points+body_points>=5:
    print("It is a spam email.")
else:
    print("It is not a spam email")
    if "sale" in id or "lottery" in id or "product" in id or "congrat" in body.lower():
        choice=input("Do you want to classify this email as spam? (Y/N)")
        if choice.lower()=="y":
            choice1=input("All such future emails will be marked as spam. Do you want to continue? (Y/N)")
            if choice1.lower()=="y":
                print(mark_as_spam(header,body))

Spam Ham Email Classifier/Main.py
SamarthTech/Hacktoberfest-Project-and-Games
#Some parts have been commented out due to a bug in pip installation of playsound. If you have playsound installed , please remove the comments
import random,string
#from playsound import playsound
board={
        1:' ',2:' ',3:' ',
        4:' ',5:' ',6:' ',
        7:' ',8:' ',9:' '
        }
def printboard(brd):
    print(brd[1] +'|'+brd[2]+'|'+brd[3])
    print('-+-+-')
    print(brd[4] +'|'+brd[5]+'|'+brd[6])
    print('-+-+-')
    print(brd[7] +'|'+brd[8]+'|'+brd[9])
def checkwinner(board):
    if board[1]==board[2]==board[3] !=' ':
        return 1
    elif board[4]==board[5]==board[6]!=' ':
        return 1
    elif board[7]==board[8]==board[9]!=' ':
        return 1
    elif board[1]==board[5]==board[9]!=' ':
        return 1
    elif board[7]==board[5]==board[3]!=' ':
        return 1
    elif board[3]==board[6]==board[9]!=' ':
        return 1
    elif board[1]==board[4]==board[7]!=' ':
        return 1
    elif board[2]==board[5]==board[8]!=' ':
        return 1
def checkdraw(b):
   if b[1]!=' '  and b[2]!=' ' and b[3]!=' ' and b[4]!=' ' and b[5]!=' ' and b[6]!=' ' and b[7]!=' ' and b[8]!=' ' and b[9]!=' ':
       return 2
print('''
The general layout of the board is given below:-
1|2|3
-+-+-
4|5|6
-+-+-
7|8|9
,Where the values of boxes will be used in the program.
I.E. You need to enter 1 to put your sign in 1st box, 5 in 5th box as per above figure. Enjoy!
*To use sound, install the playsound module first. Guide can be found in the readme file.
''')
#This part is commented out because the playsound module is not being able to be installed due to an internal error with pip.
#If you have playsound module installed , please remove the multiline comments to use sound
'''
Sound=str(input("Do you want to play sound(Needs Playsound Module to be installed) . Use Y/N : "))
if Sound.upper()=='Y' or Sound.upper()=='YES':
    Sound=True
elif Sound.upper()=='N' or Sound.upper()=='NO':
    sound=False
else:
    print("Wrong Value entered for sound. Program will be terminated")
    quit()
'''
v=input("Choose your sign :- X or O . If you choose X , you go first and Vice versa for O : ")
v=v.upper()
if v=='X':
    w='O'
    c=1
elif v=='O':
    w='X'
    c=0
else:
    print("Incorrect value of sign given . Program will be terminated")
    '''
    if Sound==True:
        playsound('program_error.mp3')
    '''
    quit()

y=0
check=0
try:
    while y!=1 and check!=2:
        while c<=10:
            if c%2!=0:
                x=int(input("Where do you want to place your sign : "))     
                if x in range(10):
                    if board[x]==' ' :
                        board[x]=v
                        print("Your turn:-",end='\n')
                        printboard(board)
                        y=checkwinner(board)
                        check=checkdraw(board)
                        if y==1:
                            print("You have won!")
                            '''
                            if Sound==True:
                                playsound('Win.wav')
                            '''
                            quit()
                        elif check==2 and y!=1:
                            print(" It is a draw")
                            '''
                            if Sound==True:
                                playsound('boing.mp3')
                            '''
                            quit()
                    else:
                        print("Place is occupied")
                        '''
                        if Sound==True:
                            playsound('program_error.mp3')
                        '''
                        continue
                else:
                    print("Enter value of x in between 1-9")
                    continue
                    
                c+=1
            else:
                x=random.randint(1,9)
                if board[x]==' ':
                    board[x]=w
                    print("computer's turn:-",end='\n')
                    printboard(board)
                    c+=1          
                else:
                    continue
                               
                y=checkwinner(board)
                check=checkdraw(board)
                if y==1:
                    print("The computer has beaten you")
                    '''
                    if Sound==True:
                        playsound('Loss.wav')
                    '''
                    quit()
                
                elif check==2 and y!=1:
                    print("It is a draw")
                    '''
                    if Sound==True:
                        playsound('boing.mp3')
                    '''    
                    quit()
                
except ValueError:
    print("You have entered a non-integral value of x. Program is terminated")
    '''
    if Sound==True:
        playsound('program_error.mp3')
    '''

TicTacToe/Tic_Tac_Toe.py
SamarthTech/Hacktoberfest-Project-and-Games
import pandas as pd

class WhatsAppChat:
    def __init__(self, filename):
        # Initialize the object by reading in the chat file, and counting word frequency and next words
        self.titles = self.read_chat_file(filename)
        self.word_freq_dict = self.count_word_frequency()
        self.next_words_dict = self.find_next_words()

    def read_chat_file(self, filename):
        """Reads in a WhatsApp chat text file and returns a list of titles."""
        chat_df = pd.read_fwf(filename, header=None)
        # Extract the chat titles from the DataFrame and return them as a list
        titles = [title for title in chat_df[2]]
        return titles

    def count_word_frequency(self):
        """Counts the frequency of each word in a list of titles."""
        word_freq_dict = {}
        for title in self.titles:
            # Split each title into words and count their frequency
            for word in str(title).split():
                if len(word) > 1:
                    if word in word_freq_dict.keys():
                        word_freq_dict[word] += 1
                    else:
                        word_freq_dict[word] = 1
        # Sort the word frequency dictionary by value in descending order and return it
        sorted_word_freq_dict = dict(sorted(word_freq_dict.items(),
                                             key=lambda x: -1*int(x[1])))
        return sorted_word_freq_dict

    def find_next_words(self):
        """Finds the most common next word for each word in a list of titles."""
        next_words_dict = {}
        for title in self.titles:
            # Split each title into words and count the frequency of each next word for each word
            words = str(title).split()
            for i in range(len(words)):
                if i != len(words) - 1:
                    current_word = words[i]
                    next_word = words[i+1].replace("\n", "")
                    if current_word in next_words_dict:
                        if next_word in next_words_dict[current_word]:
                            next_words_dict[current_word][next_word] += 1
                        else:
                            next_words_dict[current_word][next_word] = 1
                    else:
                        next_words_dict[current_word] = {next_word: 1}
        # Return the dictionary of next words
        return next_words_dict


class NextWordPredictor:
    def __init__(self, chat, num_predictions=1):
        # Initialize the object with a WhatsAppChat object and the number of predictions to make
        self.chat = chat
        self.num_predictions = num_predictions

    def predict_next_word(self, current_word):
        """Predicts the next word given a current word and a dictionary of next words."""
        if current_word in self.chat.next_words_dict:
            # Get the dictionary of next words for the current word and sort it by frequency
            next_word_freq_dict = self.chat.next_words_dict[current_word]
            sorted_next_words = sorted(next_word_freq_dict.items(),
                                        key=lambda x: x[1],
                                        reverse=True)
            # Get the top num_predictions words and return them
            next_words = [word[0] for word in sorted_next_words[:self.num_predictions]]
            return next_words
        else:
            # If the current word is not in the dictionary of next words, return None
            return None

# Create a WhatsAppChat object and a NextWordPredictor object, and print the predictions
chat = WhatsAppChat('Downloads/Chats.txt')

# Test with the word 'Good'
predictor = NextWordPredictor(chat, num_predictions=3)
print(predictor.predict_next_word("Good"))

Word_Predictor.py
SamarthTech/Hacktoberfest-Project-and-Games
import cv2
import numpy as np

import sys

symbols_list = ["#", "-", "*", ".", "+", "o"]
threshold_list = [0, 50, 100, 150, 200]

def print_out_ascii(array):
    for row in array:
        for e in row:
            print(symbols_list[int(e) % len(symbols_list)], end="")
        print()

def img_to_ascii(image):
    height, width = image.shape
    new_width = int(width / 20) 
    new_height = int(height / 40)
    resized_image = cv2.resize(image, (new_width, new_height),)
    thresh_image = np.zeros(resized_image.shape)
    for i, threshold in enumerate(threshold_list):
        thresh_image[resized_image > threshold] = i
    return thresh_image

if __name__ == "__main__":

    if len(sys.argv) < 2:
        print("Image Path not specified : Using sample_image.png\n")
        image_path = "sample_image.png"  # default image path

    if len(sys.argv) == 2:
        print("Using {} as Image Path\n".format(sys.argv[1]))
        image_path = sys.argv[1]

    image = cv2.imread(image_path, 0)  

    ascii_art = img_to_ascii(image)
    print_out_ascii(ascii_art)

ascii_converter/Main.py
SamarthTech/Hacktoberfest-Project-and-Games
import pygame
import sys
import random

# Initialize Pygame
pygame.init()

# Constants
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 400
GROUND_HEIGHT = 50
DINOSAUR_WIDTH = 50
DINOSAUR_HEIGHT = 50
CLOUD_WIDTH = 50
CLOUD_HEIGHT = 20
CACTUS_WIDTH = 20
CACTUS_HEIGHT = 40
FPS = 60
GRAVITY = 1

# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)

# Create the game window
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("Dinosaur Game")

# Load images
dinosaur_img = pygame.image.load("dino.png")
dinosaur_img = pygame.transform.scale(
    dinosaur_img, (DINOSAUR_WIDTH, DINOSAUR_HEIGHT))
cloud_img = pygame.image.load("dino.png")
cloud_img = pygame.transform.scale(cloud_img, (CLOUD_WIDTH, CLOUD_HEIGHT))
cactus_img = pygame.Surface((CACTUS_WIDTH, CACTUS_HEIGHT))
cactus_img.fill(WHITE)

# Game variables
dinosaur_x = 50
dinosaur_y = SCREEN_HEIGHT - GROUND_HEIGHT - DINOSAUR_HEIGHT
dinosaur_vel_y = 0
dinosaur_jump = False

clouds = []
cacti = []

clock = pygame.time.Clock()

# Game loop
running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_SPACE and not dinosaur_jump:
                dinosaur_jump = True
                dinosaur_vel_y = -15  # Jump velocity

    # Update dinosaur position
    if dinosaur_jump:
        dinosaur_y += dinosaur_vel_y
        dinosaur_vel_y += GRAVITY

    # Check for collisions with the ground
    if dinosaur_y >= SCREEN_HEIGHT - GROUND_HEIGHT - DINOSAUR_HEIGHT:
        dinosaur_jump = False
        dinosaur_y = SCREEN_HEIGHT - GROUND_HEIGHT - DINOSAUR_HEIGHT

    # Generate clouds and cacti
    if random.randint(0, 100) < 2:
        clouds.append([SCREEN_WIDTH, random.randint(50, 150)])
    if random.randint(0, 100) < 2:
        cacti.append([SCREEN_WIDTH, SCREEN_HEIGHT -
                     GROUND_HEIGHT - CACTUS_HEIGHT])

    # Update cloud and cactus positions
    for cloud in clouds:
        cloud[0] -= 5
    for cactus in cacti:
        cactus[0] -= 5

    # Remove off-screen clouds and cacti
    clouds = [cloud for cloud in clouds if cloud[0] > -CLOUD_WIDTH]
    cacti = [cactus for cactus in cacti if cactus[0] > -CACTUS_WIDTH]

    # Draw everything
    screen.fill(WHITE)

    # Draw ground
    pygame.draw.rect(screen, BLACK, (0, SCREEN_HEIGHT -
                     GROUND_HEIGHT, SCREEN_WIDTH, GROUND_HEIGHT))

    # Draw clouds
    for cloud in clouds:
        screen.blit(cloud_img, (cloud[0], cloud[1]))

    # Draw cacti
    for cactus in cacti:
        screen.blit(cactus_img, (cactus[0], cactus[1]))

    # Draw dinosaur
    screen.blit(dinosaur_img, (dinosaur_x, dinosaur_y))

    pygame.display.flip()
    clock.tick(FPS)

pygame.quit()
sys.exit()

dino/dino.py
SamarthTech/Hacktoberfest-Project-and-Games
import random

# List of words to choose from
word_list = ["apple", "banana", "cherry", "orange", "grape", "strawberry", "blueberry"]

# Select a random word from the list
chosen_word = random.choice(word_list)

# Convert the chosen word to a list of characters
word_letters = list(chosen_word)

# Initialize the display word with underscores
display_word = ["_"] * len(chosen_word)

# List to keep track of guessed letters
guessed_letters = []

# Number of chances the player has
lives = 6

while True:
    # Print current state of the game
    print(" ".join(display_word))
    print(f"Guessed letters: {' '.join(guessed_letters)}")
    
    # Ask the player to guess a letter
    guess = input("Guess a letter: ").lower()

    if guess in guessed_letters:
        print("You've already guessed that letter.")
        continue
    
    if guess in word_letters:
        # Update display_word with correctly guessed letters
        for i in range(len(chosen_word)):
            if word_letters[i] == guess:
                display_word[i] = guess
    else:
        # Reduce a life for incorrect guesses
        lives -= 1
        print(f"Wrong guess! You have {lives} lives left.")
    
    guessed_letters.append(guess)

    # Check if the player has won or lost
    if "_" not in display_word:
        print("Congratulations! You've won!")
        break
    elif lives == 0:
        print(f"Sorry, you've run out of lives. The word was '{chosen_word}'.")
        break

hangman/game.py
SamarthTech/Hacktoberfest-Project-and-Games