binary_calc.py

Created by wperez274

Created on January 12, 2022

2.98 KB


from math import *
from kandinsky import *
from ion import *
from time import *
from random import *

screen="cyan"
panel=(25,30,90)
default_f="black"
default_f2="white"

cursor_x=10
num=0

fill_rect(0,0,322,80,screen)
fill_rect(0,82,322,170,panel)  

fill_rect(0,0,322,2,"black")
fill_rect(0,35,322,2,"black")
fill_rect(0,80,322,2,"black")


draw_string("[OK] = Random Number 1-1000",5,85,default_f2,panel)
draw_string("[Left]/[Right] Arrows = +10/-10",5,105,default_f2,panel)
draw_string("[Up]/[Down] Arrows = +1/-1",5,125,default_f2,panel)
draw_string("BackSpace = Reset to value 0",5,145,default_f2,panel)
draw_string("Keys [+]/[-] = Number +/- 100",5,165,default_f2,panel)
draw_string("Keys [(]/[)] = Number +/- 10^8",5,185,default_f2,panel)
draw_string("Keys [4]/[6] =  +/- Scroll Left",5,205,default_f2,panel)
  
while 1:
  b_code=bin(num)
  draw_string(str(num),10,12)
  draw_string(str(b_code),cursor_x,50,default_f,screen)
  
  if keydown(KEY_OK):
    num=randint(0,10000)
    fill_rect(2,2,322,78,screen)
    fill_rect(0,0,322,2,"black")
    fill_rect(0,35,322,2,"black")
    fill_rect(0,80,322,2,"black")
    sleep(.1)
  
  if keydown(KEY_UP):
    fill_rect(2,2,322,78,screen)
    fill_rect(0,0,322,2,"black")
    fill_rect(0,35,322,2,"black")
    fill_rect(0,80,322,2,"black")
    sleep(0.2)
    num+=1
  
  if keydown(KEY_DOWN):
    fill_rect(2,2,322,78,screen)
    fill_rect(0,0,322,2,"black")
    fill_rect(0,35,322,2,"black")
    fill_rect(0,80,322,2,"black")
    sleep(0.2)
    num-=1
  
  if keydown(KEY_PLUS):
    fill_rect(2,2,322,78,screen)
    fill_rect(0,0,322,2,"black")
    fill_rect(0,35,322,2,"black")
    fill_rect(0,80,322,2,"black")
    sleep(0.2)
    num+=100
  if keydown(KEY_MINUS):
    fill_rect(2,2,322,78,screen)
    fill_rect(0,0,322,2,"black")
    fill_rect(0,35,322,2,"black")
    fill_rect(0,80,322,2,"black")
    sleep(0.2)
    num-=100
  
  if keydown(KEY_RIGHTPARENTHESIS):
    fill_rect(2,2,322,78,screen)
    fill_rect(0,0,322,2,"black")
    fill_rect(0,35,322,2,"black")
    fill_rect(0,80,322,2,"black")
    sleep(0.2)
    num+=100000000
  if num>4294967295:
    num=4294967295
  if keydown(KEY_LEFTPARENTHESIS):
    fill_rect(2,2,322,78,screen)
    sleep(0.2)
    num-=100000000
  
  if keydown(KEY_LEFT):
    fill_rect(2,2,322,78,screen)
    fill_rect(0,0,322,2,"black")
    fill_rect(0,35,322,2,"black")
    fill_rect(0,80,322,2,"black")
    sleep(0.2)
    num-=10
  if num<=0:
    num=0
  
  if keydown(KEY_RIGHT):
    fill_rect(2,2,322,78,screen)
    fill_rect(0,0,322,2,"black")
    fill_rect(0,35,322,2,"black")
    fill_rect(0,80,322,2,"black")
    sleep(0.2)
    num+=10
  
  if keydown(KEY_BACKSPACE):
    fill_rect(2,2,322,78,screen)
    fill_rect(0,0,322,2,"black")
    fill_rect(0,35,322,2,"black")
    fill_rect(0,80,322,2,"black")
    num=0
    sleep(0.2)
  if keydown(KEY_FOUR):
    for s in range(1):
      cursor_x-=1
    fill_rect(cursor_x+72,27,322,15,screen)
  if keydown(KEY_SIX):
    for s in range(1):
      cursor_x+=1
  if cursor_x>10:
    cursor_x=10

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.