In: Computer Science
Write this code in Python only.
Draw a 12" ruler on the screen. A ruler is basically a rectangular outline with tick marks extending from the top edge. The tick marks should be drawn at each quarter-inch mark. Below the tick marks, your ruler should show large integers at each full-inch position.
def draw_line(tick_len, tick_label): print('-'*tick_len, tick_label) def draw_ruler(length, tick_count): if length > 0: draw_line(tick_count, '0') helper(1, length, tick_count) def drawSegment(max_len): if(max_len == 1): draw_line(1, '') else: drawSegment(max_len - 1) draw_line(max_len, '') drawSegment(max_len - 1) def helper(start, max_length, ticks): if(start > max_length): return drawSegment(ticks - 1) draw_line(ticks, str(start)) helper(start+1, max_length, ticks) draw_ruler(12, 3)
************************************************** Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.
Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.