Example #1
0
def printTime(I, solI, time):
	""" print time and result

	"""
	print '--------------------------------------------------'
	print 'Input: '
	print I
	print 'Output: '
	print_r(solI)
	print '--------------------------------------------------'
	print 'Time:', time, 'sec'
Example #2
0
def printRUsage(no, I, solI, rUsage, pageSize):
	""" print all resource-usage and result

	"""
	print '--------------------------------------------------'
	print 'Input: '
	print I
	print 'Output: '
	print_r(solI)
	print '--------------------------------------------------'
	print 'All resource-usage: '
	print_r(rUsage)
	print 'Page-size: '
	print pageSize
	print 'Max-usage memory size of RAM [MB]: '
	#print float(((rUsage[2]*pageSize)/1024.)/1024.)
	print float((rUsage[2]/1024.)/1024.)
Example #3
0
 def print_r(self, *args):
     import print_r
     if len(args) == 1:
         print_r.print_r(args[0])
     elif len(args) == 2:
         return print_r.print_r(args[0], output=False)
Example #4
0
def print_letter(letter):
    """Prints a letter. The input variable is the index of the letter to print.

    The letters from A to Z are indexed at 0 (so A=0, B=1, etc).

    There are currently 2 addition special 'characters'.

    26 will 'print' a space
    27 will execute a 'new line'

    You are free to add any additional special characters here.

    The pen should be positioned at the top left corner of the letter box
    before calling this myblock.

    After printing the letter, the pen will be moved to the position of the
    next letter. If it is at the end of the line, it will automatically move
    the pen to the beginning of the next line.
    """
    variables['LastLetterWidth'] = variables['Seg4']
    variables['LetterSpacing'] = 20
    if letter == 0:
        print_a(1)
    elif letter == 1:
        print_b(1)
    elif letter == 2:
        print_c(1)
    elif letter == 3:
        print_d(1)
    elif letter == 4:
        print_e(1)
    elif letter == 5:
        print_f(1)
    elif letter == 6:
        print_g(1)
    elif letter == 7:
        print_h(1)
    elif letter == 8:
        print_i(1)
        variables['LastLetterWidth'] = 0
    elif letter == 9:
        print_j(1)
    elif letter == 10:
        print_k(1)
    elif letter == 11:
        print_l(1)
    elif letter == 12:
        print_m(1)
    elif letter == 13:
        print_n(1)
    elif letter == 14:
        print_o(1)
    elif letter == 15:
        print_p(1)
    elif letter == 16:
        print_q(1)
    elif letter == 17:
        print_r(1)
    elif letter == 18:
        print_s(1)
    elif letter == 19:
        print_t(1)
    elif letter == 20:
        print_u(1)
    elif letter == 21:
        print_v(1)
    elif letter == 22:
        print_w(1)
    elif letter == 23:
        print_x(1)
    elif letter == 24:
        print_y(1)
    elif letter == 25:
        print_z(1)
    elif letter == 26:
        if variables['LinePosition'] == 0:
            variables['LetterSpacing'] = 0
            variables['LastLetterWidth'] = 0
        else:
            print_space(1)
    elif letter == 27:
        carriage_move(0)
        line_feed()
        variables['LetterSpacing'] = 0

    # Move the pen to accommodate the letter spacing, and update all the
    # variables tracking the position of the pen on the line.
    letter_spacing = variables['LetterSpacing']
    motor['A'].on_for_degrees(20, letter_spacing)
    line_position = (variables['LastLetterWidth'] + variables['LinePosition'] +
                     letter_spacing)
    variables['LinePosition'] = line_position
    # Do an automatic new line if we are at the end of the current line.
    if line_position > variables['LineWidth']:
        carriage_move(0)
        line_feed()
Example #5
0
 def testb(self):
     self.assert_(print_r(123), "123")
     self.assert_(print_r([1], "1 = 1"))
Example #6
0
 def testc(self):
     import datetime, math, os, pickle
     print_r(datetime)
Example #7
0
 def testa(self):
     print_r(self.tests)