Python to Asymptote digital clock
by sonone, Apr 22, 2020, 10:37 AM
Like the clock in the last post, you enter enter the time into the Python and it output the Asymptote for that time in digital clock form. Here's the code Example: 12:30
Have fun!
h1=input('enter the tens digit of the hour in word form (i.e. one, two, three...). If there is none, enter none') h2=input('enter the units digit of the hour in word form (i.e. one, two, three...)') m1=input('enter the tens digit of the minute in word form (i.e. one, two, three...). If the minutes is one digit, enter zero') m2=input('enter the units digit of the minutes in word form (i.e. one, two, three...)') print('[asy]path a=(0,0)--(.1,.1)--(.1,.9)--(0,1)--(-.1,.9)--(-.1,.1)--cycle;picture one;filldraw(one,shift(1,0)*a,grey,white);filldraw(one,shift(1,1)*a,grey,white);picture two;filldraw(two,rotate(0)*shift(0,0)*a,grey,white);filldraw(two,rotate(90,(0,1))*a,grey,white);filldraw(two,shift(1,1)*a,grey,white);filldraw(two,rotate(-90)*a,grey,white);filldraw(two,shift(1,2)*rotate(90)*a,grey,white);picture three;add(three, one);filldraw(three,shift(1,1)*rotate(90)*a,grey,white);filldraw(three,shift(1,2)*rotate(90)*a,grey,white);filldraw(three,shift(1,0)*rotate(90)*a,grey,white);picture four;add(four,one);filldraw(four,shift(1,1)*rotate(90)*a,grey,white);filldraw(four,shift(0,1)*a,grey,white);picture five;filldraw(five,rotate(0)*shift(1,0)*a,grey,white);filldraw(five,rotate(90,(0,1))*a,grey,white);filldraw(five,shift(0,1)*a,grey,white);filldraw(five,rotate(-90)*a,grey,white);filldraw(five,shift(1,2)*rotate(90)*a,grey,white);picture six;add(six,five);filldraw(five,a,grey,white);picture seven;add(seven, one);filldraw(seven,shift(1,2)*rotate(90)*a,grey,white);picture eight;add(eight, two);add(eight, five);picture nine;add(nine, four);add(nine, seven);picture zero;add(zero,seven);add(zero,rotate(180,(.5,1))*seven);picture colon;path b=(1.35,.35)--(1.65,.35)--(1.65,.65)--(1.35,.65)--cycle;fill(colon,b,grey);fill(colon,shift(0,1)*b,grey);filldraw((-1.5,-.5)--(5,-.5)--(5,2.5)--(-1.5,2.5)--cycle,white, black);picture none;dot(none,(1.5,1),white);add(shift(-1.5)*'+str(h1)+');add('+str(h2)+');add(colon);add(shift(2,0)*'+str(m1)+');add(shift(3.5,0)*'+str(m2)+');[/asy]')
![[asy]path a=(0,0)--(.1,.1)--(.1,.9)--(0,1)--(-.1,.9)--(-.1,.1)--cycle;picture one;filldraw(one,shift(1,0)*a,grey,white);filldraw(one,shift(1,1)*a,grey,white);picture two;filldraw(two,rotate(0)*shift(0,0)*a,grey,white);filldraw(two,rotate(90,(0,1))*a,grey,white);filldraw(two,shift(1,1)*a,grey,white);filldraw(two,rotate(-90)*a,grey,white);filldraw(two,shift(1,2)*rotate(90)*a,grey,white);picture three;add(three, one);filldraw(three,shift(1,1)*rotate(90)*a,grey,white);filldraw(three,shift(1,2)*rotate(90)*a,grey,white);filldraw(three,shift(1,0)*rotate(90)*a,grey,white);picture four;add(four,one);filldraw(four,shift(1,1)*rotate(90)*a,grey,white);filldraw(four,shift(0,1)*a,grey,white);picture five;filldraw(five,rotate(0)*shift(1,0)*a,grey,white);filldraw(five,rotate(90,(0,1))*a,grey,white);filldraw(five,shift(0,1)*a,grey,white);filldraw(five,rotate(-90)*a,grey,white);filldraw(five,shift(1,2)*rotate(90)*a,grey,white);picture six;add(six,five);filldraw(five,a,grey,white);picture seven;add(seven, one);filldraw(seven,shift(1,2)*rotate(90)*a,grey,white);picture eight;add(eight, two);add(eight, five);picture nine;add(nine, four);add(nine, seven);picture zero;add(zero,seven);add(zero,rotate(180,(.5,1))*seven);picture colon;path b=(1.35,.35)--(1.65,.35)--(1.65,.65)--(1.35,.65)--cycle;fill(colon,b,grey);fill(colon,shift(0,1)*b,grey);filldraw((-1.5,-.5)--(5,-.5)--(5,2.5)--(-1.5,2.5)--cycle,white, black);picture none;dot(none,(1.5,1),white);add(shift(-1.5)*one);add(two);add(colon);add(shift(2,0)*three);add(shift(3.5,0)*zero);[/asy]](http://latex.artofproblemsolving.com/2/c/4/2c4523f2c1a755120215c9a43324ffec0413f667.png)
This post has been edited 1 time. Last edited by sonone, Apr 22, 2020, 10:37 AM