Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- import pyfiglet as pyfl
- import matplotlib as mt
- import matplotlib.pyplot as plt
- import numpy as np
- from random import randint
- from random import choice
- import sys
- import os
- import time
- #GeekForGeek Project (In Progress)
- class GeekForGeekProject:
- def __init__(self):
- self.textart = pyfl.Figlet()
- self.textart.width = 150
- def GuessNumberGame(self, minNum : int, maxNum : int, chance : int):
- print(self.textart.renderText("Number Guessing Game..."))
- randnumber = randint(minNum, maxNum)
- while chance > 0:
- print("Current Chance Live : {}".format(chance))
- try:
- n = int(input(f"You Number From {minNum} To {maxNum} : "))
- if n == randnumber:
- print("Correct! The Number Was {}".format(n))
- break
- else:
- print("Incorrect Try Again", end="\r")
- chance -= 1
- time.sleep(1)
- os.system("cls" if os.name == "nt" else "clear")
- if chance == 0:
- print("Game Over Try Again Later You Ran Out of Chance")
- except ValueError as ex:
- raise ValueError("Invaild Value : ", ex)
- def GuessWordGame(self, listofword : list[str], chance : int):
- print(self.textart.renderText("Word Guessing Game..."))
- correctword = choice(listofword).lower()
- guesses = ""
- lenword = 0
- while chance > 0:
- if guesses == correctword and lenword == len(correctword):
- print("You Won You Word is {}".format(correctword.lower()))
- break
- print("Current Word : ", end="")
- displayword = ''.join([char if char in guesses else "_" for char in correctword])
- print(displayword)
- try:
- print(" You Have {} Chance of Guessing".format(chance))
- n = input("Guess the Character of The Word : ").lower()
- if len(n) != 1 or not n.isalpha():
- print("invaild Character")
- continue
- if n == correctword[lenword]:
- guesses += n
- lenword += 1
- print("Correct!")
- else:
- print("Wrong TryAgain")
- chance -= 1
- time.sleep(1)
- os.system("cls" if os.name == "nt" else "clear")
- if chance == 0:
- print("Game Over Try Again Later")
- except ValueError as ex:
- raise ValueError("Invaild Value : ", ex)
- def CalcautorConsoleApp(self):
- print(self.textart.renderText("ConsoleApp Calacutor 101..."))
- expr = ""
- resshow = False
- BoarderLim = 14
- while True:
- print('-'*BoarderLim)
- print(f"|{expr}|" if resshow == False else f"|={expr}|")
- print("| 1 2 3 |\n| 4 5 6 |\n| 7 8 9 |\n| + - * |\n| / C = |")
- n = input('input Here : ')
- vaildopreator = ['-', '+', "/", "*"]
- vaildnum = [str(i) for i in range(10)]
- print('-'*BoarderLim)
- if n.isdigit() and n in vaildnum:
- if resshow:
- expr = ''
- resshow = False
- expr += n
- elif n in vaildopreator:
- if resshow:
- resshow = False
- expr = ''
- if expr and expr[-1] not in vaildopreator:
- expr += n
- else:
- print('invaild Input')
- elif n == "=":
- resshow = True
- try:
- expr = str(eval(expr))
- except Exception as ex:
- print("invaild Experisson While Resulting... error : ", ex)
- expr = ''
- elif n == "OFF":
- print("Calacutor Shutting Down...")
- break
- else:
- print("invaild input")
- def SimBankGame(self):
- print(self.textart.renderText("Sim Bank Game..."))
- currentmoney = int(input("input You Current Money : "))
- currentstored = int(input("input You Stored Money : "))
- vaildin = ['e', 'w', 'd']
- print(self.textart.renderText("Starting..Sim Bank Game"))
- while True:
- os.system("cls" if os.name == "nt" else "clear")
- print("Current Money in Bank : {}\nCurrent Money : {}".format(currentstored, currentmoney))
- print('What You Wish For :\nw: WithDraw\nd: Despoit\ne: Exit')
- n = input("input Here : ")
- match n:
- case 'w':
- while True:
- try:
- j = int(input("How Much Do you Wish To WithDraw : "))
- if j <= currentstored:
- currentmoney += j
- currentstored -= j
- else:
- print("Cannot WithDraw Too Many")
- continue
- except ValueError as ex:
- print("invaild input Did you Input a Actual Number?\n... error : ", ex)
- break
- case "d":
- while True:
- try:
- j = int(input("How Much Do you Wish To Despoit : "))
- if j <= currentmoney:
- currentstored += j
- currentmoney -= j
- else:
- print("Cannot Despoit Too Many")
- continue
- except ValueError as ex:
- print("invaild input Did you Input a Actual Number?\n.. error : ", ex)
- break
- case 'e':
- print("Exiting..Sim Bank Game")
- break
- case _:
- print("invaild input")
- time.sleep(1)
- os.system("cls" if os.name == "nt" else "clear")
- # Vaildator (in Progress)
- class VaildatorRegex:
- def IsVaildPassword(self, password : str) -> bool:
- return True if re.fullmatch(r'^(?=.*[a-z])(?=.*\d)[a-zA-Z0-9._@#$%^&*()<>+\-!]+$', password) and len(password) >= 8 else False
- def IsVaildEmail(self, email : str):
- return True if re.search('[a-zA-Z0-9._]+@+[a-zA-Z]{3,}', email) else False
- def FormatPhoneNumber(self, dig : str) -> bool:
- patterned = re.findall(r'(\d{3})(\d{3})(\d{4})', dig)
- return f'({patterned[0][0]})-{patterned[0][1]}-{patterned[0][2]}' if patterned else 'invaild Phone number'
- #Test Result For gProject
- if __name__ == "__main__":
- pass
- #gProject = GeekForGeekProject()
- #gProject.GuessNumberGame(0, 10, 11)
- #gProject.GuessWordGame(["Mawin", "John"], 100)
- #gProject.CalcautorConsoleApp()
- #gProject.SimBankGame()
- #Test Result For VaildatorRegex Project
- #vd = VaildatorRegex()
- #print(vd.FormatPhoneNumber('12345678910'))
- #print(vd.IsVaildEmail("[email protected]"))
- #print(vd.IsVaildPassword("sigmaSIGMA!@"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement