Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
add eval
add mathematical operations
add hint message
add sound
add message box
  • Loading branch information
aliakbartnt authored Apr 24, 2024
1 parent 634b7a0 commit c670cb1
Showing 1 changed file with 62 additions and 46 deletions.
108 changes: 62 additions & 46 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@

#import


import winsound
import ctypes
from colorama import *
import os
import time
from threading import Timer





#setting

#color fix windows
init()

#coppyright

print(Fore.LIGHTCYAN_EX +'''
welcome to calculate !
Welcome to calculater !
create by aliakbartnt !
Create by aliakbartnt !
its simple calculate !
Its simple calculate !
''')

#fake proccese


time.sleep(1)
print(Fore.YELLOW +"app launching processing . . .")
print(Fore.YELLOW +"App launching processing . . .")
time.sleep(3)
print(Fore.RED +"app runing")
print(Fore.RED +"App runing")
time.sleep(1)

#Code cleaning
Expand All @@ -42,6 +49,7 @@ def cleaner_consol():

#Variable


dot = (Fore.LIGHTGREEN_EX +": ")
color_reset = (Fore.RESET +"")

Expand All @@ -51,45 +59,51 @@ def cal():
cleaner_consol()
#Variable

jav = str((Fore.LIGHTGREEN_EX +"\n" "awnser : "))
awnser_1 = str((Fore.LIGHTGREEN_EX +"\n" "Awnser : "))


#input

#1anti-bug
try:

a = float(input(color_reset+F"enter num 1 "+dot+color_reset ))
b = float(input(color_reset+"enter num 2 "+dot+color_reset))
c = str(input(Fore.RESET +"che amal riazi anjam she (+,-,/,*) "))
except:
print(Fore.RED +"please enter number"+color_reset)
ctypes.windll.user32.MessageBoxW(0, "please enter number", "Not Correct", 1)
#input
a = float(input(color_reset+F"Enter num 1 "+dot+color_reset ))
b = float(input(F"Enter num 2 "+dot+color_reset ))

#change type
a = str(a)
b = str(b)
#input
c = input(Fore.RESET +"What mathematical operations should be performed? (+,-,/,*,**,//) "+dot+color_reset)

#1anti-bug

except:
winsound.MessageBeep(winsound.MB_ICONHAND)#sound
print(Fore.RED +"Please enter number"+color_reset)
#message-box
ctypes.windll.user32.MessageBoxW(0, "Please enter number", "Not Correct", 0 | 0x30)
cal()

if c == str("+"):
proccese = str((a+b))

print(jav + proccese)

elif c == str("-"):
proccese = str((a-b))

print(jav + proccese)

elif c == str("/"):
proccese = str((a/b))

print(jav + proccese)

elif c == str("*"):
proccese = str((a*b))

print(jav + proccese)
#2anti-bug
try:
#check for c value true
if c in ['+', '-', '*', '**', '/', '//']:
awnser = eval(a + c + b) #eval mathematical operations
print(f'{awnser_1}{awnser}')
#anti-bug
else :
print(Fore.RED +"Undefined mathematical operations")

#2anti-bug
except:
print(Fore.RED +"Please enter number"+color_reset)#invalid number
winsound.MessageBeep(winsound.MB_ICONHAND)#sound
#message-box
ctypes.windll.user32.MessageBoxW(0, "Please enter number", "Not Correct", 0 | 0x30)
cal()#aggain run main code

else :
print(Fore.RED +"amaliat namoskhas")


#if main code end ask user relaunch
again()


Expand All @@ -98,22 +112,24 @@ def cal():


def again():
rep = str(input(Fore.LIGHTRED_EX +"\n""relunch calculate ? y or n "+dot+color_reset))
print(Fore.RESET +"")
if rep == "y" :
cal()
rep = str(input(Fore.LIGHTRED_EX +"\n""Relaunch calculater ? y or n "+dot+color_reset))#user awnser input
print(Fore.RESET +"") #for color reset with awnser user
if rep == "y" : #check user awnser
cal()#relaunch main code


elif rep == "n" :
elif rep == "n" : #check user awnser
print("5 s to close")
def end():
print("colose now")
def end():#start fake end time
#fake-end-time
print("Close now")
time.sleep(1)
t = Timer(5.0, end)
t.start()

t = Timer(5.0, end)#after 5 s end app
t.start() #start timer
#anti-bug
else :
again()
#call main code
cal()


0 comments on commit c670cb1

Please sign in to comment.