freedom_calc.py
Created by
wperez274
Created on
April 25, 2023
9.02 KB
from math import *
from turtle import *
from random import *
from random import randint as RAND
from kandinsky import *
from kandinsky import fill_rect as F
from ion import *
from time import *
bg = ( 255 ,) * 3
#bg= (179, 227, 161)
#bg=(200,255,255)
#bg= (253, 184, 15)
num = [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ]
alphabet = [
" a " , " b " , " c " , " d " , " e " , " f " , " g " ,
" h " , " i " , " j " , " k " , " l " , " m " ,
" n " , " o " , " p " , " q " , " r " , " s " , " t " ,
" u " , " v " , " w " , " x " , " y " , " z "
]
characters = [ " . " , " * " , " / " ,
" + " , " - " , " ( " , " ) " , " ? " , " ! " ,
" = " , " < " , " > " , " : " ,
" ; " , " , " , " % " ,
" [ " , " ] " , " { " , " } " , " _ " ,
" exp( " , " log( " , " log10( " , " 1j " ,
" ** " , " sin( " , " cos( " , " tan( " ,
" pi " , " sqrt " , " **2 "
]
turtle_on = 0
x = 2
y = 1
w = 2
h = 2
c = ( 0 , 0 , 0 )
mysketch = []
p = [ x , y ]
note = """"""
F ( 0 , 0 , 322 , 222 , bg )
sleep ( 0.4 )
t = 0
alpha = 0
shift = 0
while not keydown ( KEY_EXE ):
if keydown ( KEY_ANS ):
F ( x , y , w , h , c )
else :
draw_string ( str ( " _ " ), x , y , c , bg )
if not keydown ( KEY_ANS ):
if keydown ( KEY_LEFT ):
x -= 2
# sleep(0.2)
# x-=14
# note=note[:-1]
if keydown ( KEY_RIGHT ):
x += 2
if keydown ( KEY_UP ):
y -= 2
if keydown ( KEY_DOWN ):
y += 2
else :
if keydown ( KEY_LEFT ):
x -= 1
if keydown ( KEY_RIGHT ):
x += 1
if keydown ( KEY_UP ):
y -= 1
if keydown ( KEY_DOWN ):
y += 1
if alpha == 0 and not keydown ( KEY_ANS ):
if keydown ( KEY_ZERO ):
sleep ( 0.2 )
draw_string ( str ( num [ 0 ]), x , y , c , bg )
x += 14
note += str ( num [ 0 ])
if keydown ( KEY_ONE ):
sleep ( 0.2 )
draw_string ( str ( num [ 1 ]), x , y , c , bg )
x += 14
note += str ( num [ 1 ])
if keydown ( KEY_TWO ):
sleep ( 0.2 )
draw_string ( str ( num [ 2 ]), x , y , c , bg )
x += 14
note += str ( num [ 2 ])
if keydown ( KEY_THREE ):
sleep ( 0.2 )
draw_string ( str ( num [ 3 ]), x , y , c , bg )
x += 14
note += str ( num [ 3 ])
if keydown ( KEY_FOUR ):
sleep ( 0.2 )
draw_string ( str ( num [ 4 ]), x , y , c , bg )
x += 14
note += str ( num [ 4 ])
if keydown ( KEY_FIVE ):
sleep ( 0.2 )
draw_string ( str ( num [ 5 ]), x , y , c , bg )
x += 14
note += str ( num [ 5 ])
if keydown ( KEY_SIX ):
sleep ( 0.2 )
draw_string ( str ( num [ 6 ]), x , y , c , bg )
x += 14
note += str ( num [ 6 ])
if keydown ( KEY_SEVEN ):
sleep ( 0.2 )
draw_string ( str ( num [ 7 ]), x , y , c , bg )
x += 14
note += str ( num [ 7 ])
if keydown ( KEY_EIGHT ):
sleep ( 0.2 )
draw_string ( str ( num [ 8 ]), x , y , c , bg )
x += 14
note += str ( num [ 8 ])
if keydown ( KEY_NINE ):
sleep ( 0.2 )
draw_string ( str ( num [ 9 ]), x , y , c , bg )
x += 14
note += str ( num [ 9 ])
if keydown ( KEY_DOT ):
sleep ( 0.2 )
draw_string ( str ( characters [ 0 ]), x , y , c , bg )
x += 14
note += str ( characters [ 0 ])
if keydown ( KEY_MULTIPLICATION ):
sleep ( 0.2 )
draw_string ( str ( characters [ 1 ]), x , y , c , bg )
x += 14
note += str ( characters [ 1 ])
if keydown ( KEY_DIVISION ):
sleep ( 0.2 )
draw_string ( str ( characters [ 2 ]), x , y , c , bg )
x += 14
note += str ( characters [ 2 ])
if keydown ( KEY_PLUS ):
sleep ( 0.2 )
draw_string ( str ( characters [ 3 ]), x , y , c , bg )
x += 14
note += str ( characters [ 3 ])
if keydown ( KEY_MINUS ):
sleep ( 0.2 )
draw_string ( str ( characters [ 4 ]), x , y , c , bg )
x += 14
note += str ( characters [ 4 ])
if keydown ( KEY_LEFTPARENTHESIS ):
sleep ( 0.2 )
draw_string ( str ( characters [ 5 ]), x , y , c , bg )
x += 14
note += str ( characters [ 5 ])
if keydown ( KEY_RIGHTPARENTHESIS ):
sleep ( 0.2 )
draw_string ( str ( characters [ 6 ]), x , y , c , bg )
x += 14
note += str ( characters [ 6 ])
if keydown ( KEY_BACKSPACE ) and alpha == 0 and shift == 0 :
sleep ( 0.2 )
draw_string ( str ( note ), 15 , 204 ,( 0 , 0 , 0 ),( 0 , 0 , 0 ))
draw_string ( str ( " _ " ), x , y , bg , bg )
x -= 14
note = note [: - 1 ]
if keydown ( KEY_OK ):
sleep ( 0.2 )
draw_string ( str ( " _ " ), x , y , bg , bg )
x = 2
y += 18
note += " \n "
if not keydown ( KEY_ANS ):
if x > 304 :
x = 2
y += 18
if x < 2 and y > 0 :
x = 304
y -= 18
elif x < 2 :
x = 2
if y < 1 :
y = 1
if alpha == 0 :
if keydown ( KEY_SHIFT ):
sleep ( 0.2 )
shift += 1
if shift > 1 :
shift = 0
draw_string ( " [Sh] " , 280 , 1 , bg , bg )
#///[ shift ]//////
if shift :
draw_string ( " [Sh] " , 280 , 1 , " orange " ,( 0 , 0 , 0 ))
if keydown ( KEY_BACKSPACE ):
sleep ( 0.2 )
F ( 0 , 0 , 322 , 222 , bg )
x = 2
y = 1
note = """"""
if keydown ( KEY_PI ):
sleep ( 0.2 )
draw_string ( str ( characters [ 9 ]), x , y , c , bg )
x += 14
note += characters [ 9 ]
if keydown ( KEY_EXP ):
sleep ( 0.2 )
draw_string ( str ( characters [ 16 ]), x , y , c , bg )
x += 14
note += characters [ 16 ]
if keydown ( KEY_LN ):
sleep ( 0.2 )
draw_string ( str ( characters [ 17 ]), x , y , c , bg )
x += 14
note += characters [ 17 ]
if keydown ( KEY_LOG ):
sleep ( 0.2 )
draw_string ( str ( characters [ 18 ]), x , y , c , bg )
x += 14
note += characters [ 18 ]
if keydown ( KEY_IMAGINARY ):
sleep ( 0.2 )
draw_string ( str ( characters [ 19 ]), x , y , c , bg )
x += 14
note += characters [ 19 ]
"""
characters=[ " . " , " * " , " / " ,
" + " , " - " , " ( " , " ) " , " ? " , " ! " ,
" = " , " < " , " > " , " : " ,
" ; " , " , " , " % " ,
" [ " , " ] " , " { " , " } " , " _ " , " sin( " ,
" cos( " , " tan( " , " pi " , " sqrt( " ,
" **2 "
]
"""
#////[ alpha ]///////
if keydown ( KEY_ALPHA ) and shift == 0 :
sleep ( 0.2 )
alpha += 1
if alpha > 1 :
draw_string ( " [a] " , 290 , 1 , bg , bg )
alpha = 0
if alpha :
draw_string ( " [a] " , 290 , 1 ,( 0 , 0 , 0 ), " orange " )
if keydown ( KEY_ZERO ):
sleep ( 0.2 )
draw_string ( str ( characters [ 7 ]), x , y )
x += 14
note += str ( characters [ 7 ])
if keydown ( KEY_DOT ):
sleep ( 0.2 )
draw_string ( str ( characters [ 8 ]), x , y , c , bg )
x += 14
note += str ( characters [ 8 ])
if keydown ( KEY_MINUS ):
sleep ( 0.2 )
draw_string ( str ( " " ), x , y , c , bg )
x += 14
note += " "
if keydown ( KEY_EXP ):
sleep ( 0.2 )
draw_string ( str ( alphabet [ 0 ]), x , y , c , bg )
x += 14
note += str ( alphabet [ 0 ])
if keydown ( KEY_LN ):
sleep ( 0.2 )
draw_string ( str ( alphabet [ 1 ]), x , y , c , bg )
x += 14
note += str ( alphabet [ 1 ])
if keydown ( KEY_LOG ):
sleep ( 0.2 )
draw_string ( str ( alphabet [ 2 ]), x , y , c , bg )
x += 14
note += str ( alphabet [ 2 ])
if keydown ( KEY_IMAGINARY ):
sleep ( 0.2 )
draw_string ( str ( alphabet [ 3 ]), x , y , c , bg )
x += 14
note += str ( alphabet [ 3 ])
if keydown ( KEY_COMMA ):
sleep ( 0.2 )
draw_string ( str ( alphabet [ 4 ]), x , y , c , bg )
x += 14
note += str ( alphabet [ 4 ])
if keydown ( KEY_POWER ):
sleep ( 0.2 )
draw_string ( str ( alphabet [ 5 ]), x , y , c , bg )
x += 14
note += str ( alphabet [ 5 ])
F ( 0 , 194 , 322 , 28 , ( 39 , 41 , 41 ))
F ( 0 , 194 , 322 , 4 ,( 0 , 0 , 200 ))
draw_string ( str ( note ), 15 , 204 ,( 0 , 255 , 0 ),( 0 , 0 , 0 ))
if y + 16 > 194 :
y = 194 - 16
if keydown ( KEY_VAR ):
sleep ( 0.25 )
speed ( 10 )
goto ( 0 , 0 )
color ( ' red ' )
bg = ( 201 , 232 , 79 )
F ( 0 , 0 , 322 , 222 , bg )
turtle_on += 1
if turtle_on > 1 :
bg = ( 255 ,) * 3
F ( 0 , 0 , 322 , 222 , bg )
penup ()
turtle_on = 0
if turtle_on :
draw_string ( str ( int ( position ()[ 0 ])) + " , " + str ( int ( position ()[ 1 ])), 170 , 200 ,( 0 , 255 , 0 ),( 0 , 0 , 0 ))
pensize ( 3 )
pendown ()
showturtle ()
if keydown ( KEY_LEFT ):
left ( 10 )
if keydown ( KEY_RIGHT ):
right ( 10 )
if keydown ( KEY_DOWN ):
backward ( 3 )
if keydown ( KEY_UP ):
forward ( 5 )
if keydown ( KEY_XNT ):
circle ( 25 )
if alpha == 0 and shift == 0 :
if keydown ( KEY_EXP ):
sleep ( 0.2 )
draw_string ( str ( characters [ 21 ]), x , y )
x += 14 * 3
note += str ( characters [ 21 ])
if keydown ( KEY_LN ):
sleep ( 0.2 )
draw_string ( str ( characters [ 22 ]), x , y )
x += 14 * 3
note += str ( characters [ 22 ])
if keydown ( KEY_LOG ):
sleep ( 0.2 )
draw_string ( str ( characters [ 23 ]), x , y )
x += 14 * 4 + 5
note += str ( characters [ 23 ])
if keydown ( KEY_IMAGINARY ):
sleep ( 0.2 )
draw_string ( str ( characters [ 24 ]), x , y )
x += 14 * 1 + 9
note += str ( characters [ 24 ])
if keydown ( KEY_SQUARE ):
sleep ( 0.2 )
draw_string ( str ( characters [ 25 ]), x , y )
x += 14 * 1 + 12
note += str ( characters [ 25 ])
if keydown ( KEY_SINE ):
sleep ( 0.2 )
draw_string ( str ( characters [ 26 ]), x , y )
x += 14 * 2 + 4
note += str ( characters [ 26 ])
if keydown ( KEY_COSINE ):
sleep ( 0.2 )
draw_string ( str ( characters [ 27 ]), x , y )
x += 14 * 2 + 4
note += str ( characters [ 26 ])
p = [ x , y ]
if keydown ( KEY_ANS ):
sleep ( 0.1 )
mysketch . append ( p )
if keydown ( KEY_LEFT ):
x -= 15
if keydown ( KEY_RIGHT ):
x += 15
if keydown ( KEY_UP ):
y -= 12
if keydown ( KEY_DOWN ):
y += 12
draw_string ( str ( len ( mysketch )), 200 , 1 )
if len ( mysketch ) > 20 :
del mysketch [ - 1 ]
draw_string ( " PRESS [OK] " , 80 , 30 ,( 0 , 0 , 0 ),( 100 , 255 , 255 ))
print ( "" )
print ( " bg= " , bg )
print ( " note= " , '""" \n ' , note , ' \n """' )
print ( "" )
try :
print ( " ----------------- \n\n " , note , " \n " )
print ( " = " , eval ( note ), " (Ans) " , " \n\n ----------------- " )
except :
print ( " Try no letters,spaces or parenthesis " )
print ( " or only 1 decimal (DOT). " )