Question

In: Computer Science

Write the code in python only. You will need the graphics library for this assignment. Please...

Write the code in python only.

You will need the graphics library for this assignment. Please download the library and place it in the same file as your solution.

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.

Solutions

Expert Solution

from graphics import *

def main():
    win = GraphWin('Ruler', 1100, 350) # give title and dimensions

    rulerLen = 12
    eachInchLen = 80
    xStart = 70

    rect = Rectangle(Point(xStart - 10, 50), Point(10 + xStart + rulerLen * eachInchLen, 100))
    rect.setFill("yellow")
    rect.draw(win)

    for i in range(13):
        xS = xStart + i*eachInchLen

        l = Line(Point(xS, 50), Point(xS, 75))  # set endpoints
        l.setWidth(2)
        l.draw(win)

        label = Text(Point(xS, 90), str(i))
        label.draw(win)

        if i != 12:
            xS = xStart + i*eachInchLen + eachInchLen/2
            l = Line(Point(xS, 50), Point(xS, 70))  # set endpoints
            l.setWidth(1)
            l.draw(win)

            xS = xStart + i*eachInchLen + eachInchLen/4
            l = Line(Point(xS, 50), Point(xS, 60))  # set endpoints
            l.setWidth(1)
            l.draw(win)

            xS = xStart + i*eachInchLen + 3*eachInchLen/4
            l = Line(Point(xS, 50), Point(xS, 60))  # set endpoints
            l.setWidth(1)
            l.draw(win)

    win.getMouse()
    win.close()

main()
**************************************************

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.


Related Solutions

Please write code in c++. Use iostream (and any string library if you need it). Create...
Please write code in c++. Use iostream (and any string library if you need it). Create s structure plane : First line contains n(0 < n < 1001). Then n lines inputed in given format:   First - ID[int type]   Second - FromLocation[char*]   Third - ToLocation[char*]   Fourth - DepartureTime[char*] Output: Sorted list of planes should be in UPPER CASE. Example of input:(it's just one of an examples, you need to write code generally) 10 40 Shuch Satp 05:47 89 Kyzy Taldy  07:00...
Sketch! This assignment is to write a Python program that makes use of the OpenGL graphics...
Sketch! This assignment is to write a Python program that makes use of the OpenGL graphics library to make an interactive sketching program that will allow the user to do line drawings. The user should be able to choose from a palette of colors displayed on the screen. When the user clicks the mouse in the color palette area, the drawing tool will switch to using the color selected, much like dipping a paint brush into a new color of...
(please use zelle's Python Graphics library, I've already asked this question and have had to post...
(please use zelle's Python Graphics library, I've already asked this question and have had to post this multiple times. I am working with the Python Graphics library and nothing else. thank you! note that I will downvote anything other than python graphics. this is the 4th time I've had to post this same question) im trying to create a function that has a circle bouncing left to right on a window and when the circle is clicked on, it stops...
(please use zelle's Python Graphics library, I've already asked this question and have had to post...
(please use zelle's Python Graphics library, I've already asked this question and have had to post this multiple times. I am working with the Python Graphics library and nothing else. thank you! note that I will downvote anything other than python graphics. this is the 4th time I've had to post this same question, just a simple code with 1 ball is needed ) im trying to create a function that has a circle bouncing left to right on a...
Python we need to create a game using only the library graphic.py and use only Structure...
Python we need to create a game using only the library graphic.py and use only Structure Functions only.
Write a program: For this assignment, you will need to write three source code files as...
Write a program: For this assignment, you will need to write three source code files as well as two header files. Each of these files is relatively short, but many inexperienced programmers are overwhelmed by the idea of writing a program as multiple files. "Where do I start?!!" is a common refrain. This assignment sheet attempts to walk you through the steps of writing a multi-file program. The steps outlined below should not be thought of as a purely linear...
HOW WOULD YOU WRITE THIS IN PYTHON? SHOW THIS IN PYTHON CODE PLEASE # DEFINE 'all_keywords',...
HOW WOULD YOU WRITE THIS IN PYTHON? SHOW THIS IN PYTHON CODE PLEASE # DEFINE 'all_keywords', A LIST COMPRISED OF ALL OUR NEGATIVE SEARCH KEYWORDS AS REQUIRED BY THE PROJECT # FOR EACH ELEMENT IN 'full_list' (THE LIST OF LISTS YOU WOULD HAVE CREATD ABOVE THE PREVIOUS LINE) # INITIALIZE THE SET 'detected_keywords' TO EMPTY # DEFINE VARIABLE 'current_reviewer' FROM CURRENT ELEMENT OF 'full_list' BY EXTRACTING ITS FIRST SUB-ELEMENT,... # ...CONVERTING IT TO A STRING, AND THEN STRIPPING THE SUBSTRING...
Please write code in c++ using iostream library. Also you can use any string library. Create...
Please write code in c++ using iostream library. Also you can use any string library. Create structure plane with the following: 1)plane's ID[int type] 2) location[char*] 3) departure time[char*] Your task is to find the plane with the smallest departure time for the selected city. Pointer, dynamic array and structures have to be used in this code. Input: NOTE: It's just an example of input, you should write code generally for any inputs. First line contains n(0 < n <...
Please, write this code in c++. Using iostream and cstring library. Write a function that will...
Please, write this code in c++. Using iostream and cstring library. Write a function that will delete all words in the given text that meets more that one time. Also note than WORD is sequence of letters sepereated by whitespace. Note. The program have to use pointer. Input: First line contains one line that is not longer than 1000 symbols with whitespaces. Each word is not longer than 30 symbols. Output: Formatted text. example: input: Can you can the can...
please create a tic tac toe game with python using only graphics.py library
please create a tic tac toe game with python using only graphics.py library
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT