0% found this document useful (0 votes)
100 views

Question: 3. Write A Program On Python That Asks The User For A Color, A L

Uploaded by

Malik Asad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views

Question: 3. Write A Program On Python That Asks The User For A Color, A L

Uploaded by

Malik Asad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

  Textbook Solutions Expert Q&A Practice 

Find solutions for your homework Search

home / study / engineering / computer science / computer science questions and answers / 3. write a program on python that asks the user for a …

Question: 3. Write a program on python that asks the user for a color, a l… Post a question
Answers from our experts for your tough
homework questions

3. Write a program on python that asks the user for a color, a line width, a line length and a shape.Assume Enter question
that the user will specify a that is either a line, a triangle, or a square. Use turtle graphics to draw the shape
that the user requests of the size, color, line width and line length that the user requests. For example, if
these are the user choices for color, width,line length and shape what color? blue whatline width? 25
whatline length? 100 line, triangle or square? triangle
Continue to post
Python code no for loop
only if and elif 1 question remaining

thank you

Snap a photo from your


Expert Answer phone to post a question
We'll send you a one-time download
link
Ethan Bruce answered this
Was this answer helpful? 0 0
1,510 answers

Provided code is done as per your requirements. 888-888-8888 Text me


"Screen shot program code" for better understanding.
"Code to copy" for run the program in your IDE. By providing your phone number, you agree to receive a one-tim
automated text message with a link to get the app. Standard
messaging rates may apply.
Code Image:

My Textbook Solutions

Fortran... Organizatio... Study...

3rd Edition 13th Edition 9th Edition

View all solutions


Sample Output:

Run 1:

Run 2:
Run 3:

Code to Copy:

import turtle

class TurtleDraw():

    def __init__(self,*args):

        #s = turtle.Screen()

        tObject = turtle.Turtle()

        color = None

        length = None

        width = None

        shape = None

        #Iterate the loop up to color is not None

        while not color:

            #Ger the color from user

            color = input('what is line color: ')

            try:

                tObject.pencolor(color)

            except:
                print('please enter one of the given colors')

                color = None

        #Iterate the loop up to width is not None

        while not width:

            try:

                width = int(input('what is line width: '))

            except ValueError:

                print('please enter positive number')

            else:

                if width < 1:

                    print('please enter positive number')

                    width = None

                   

        #Iterate the loop up to length is not None

        while not length:

            try:

                length = oat(input('what is line length: '))

            except ValueError:

                print('It`s not a number,enter number instead of character')

        #Iterate the loop up to shape is not None

        while not shape:

            #Get the input from user

            shape = input('select any one of these to draw:- line, triangle, or square: ')

            if shape.lower() not in ['line', 'triangle', 'square']:

                shape = None

                print('please enter given shapes')

        tObject.pensize(width)

        #check whether shape is line or not

        if shape.lower() == 'line':

            tObject.forward(length)

        elif shape.lower() == 'triangle':

            tObject.forward(length)

            tObject.right(120)

            tObject.forward(length)

            tObject.right(120)

            tObject.forward(length)

        elif shape.lower() == 'square':

            tObject.forward(length)

            tObject.right(90)

            tObject.forward(length)

            tObject.right(90)

            tObject.forward(length)

            tObject.right(90)

            tObject.forward(length)

           

#create an object for TurtleDraw class


drawObject = TurtleDraw()


Comment

Practice with similar questions

Q: 3. Write a program on python that asks the user for a color, a line width, a line length and a shape.Assume that the
user will specify a that is either a line, a triangle, or a square. Use turtle graphics to draw the shape that the user
requests of the size, color, line width and line length that the user requests. For example, if these are the user choices
for color, width,line...

A: See answer

Q: Python Use turtle graphics to draw the shape that the user requests of the size, color, line width and line length that
the user requests. For example, if these are the user choices for color, width, line length and shape

A: See answer 100% (1 rating)

Show more 

Up next for you in Computer Science

Use Python 3 to do the Question 1 1. Use the


following question: substitution method to
show that the recurrence
T(n) = √ n T( √ n) + nhas
solution T(n) = O(n lg lg See more questions for
n).2. Determine the subjects you study
Theta-Bounds of the
following functions by

See answer See answer

Questions viewed by other students

Q: 1. Write Python code that does the following: a. Assigns the values 3, 4 and 5 to the variables a, b and c, respectively
b. Write an if statement that prints "OK" if a is less than b c. Write an if statement that prints "OK" if c is less than b d.
Write an if statement that prints "OK" if the sum of a and b is equal to c e. Write an if statement that prints "OK" if the
sum of a...

A: See answer

Q: Python

A: See answer 100% (1 rating)

Show more 

COMPANY LEGAL & POLICIES CHEGG PRODUCTS AND SERVICES CHEGG NETWORK CUSTOMER SERVICE

About Chegg Advertising Choices Cheap Textbooks Mobile Apps EasyBib Customer Service
Chegg For Good Cookie Notice Chegg Coupon Sell Textbooks Internships.com Give Us Feedback
College Marketing General Policies Chegg Play Solutions Manual Thinkful Help with eTextbooks
Corporate Development Intellectual Property Rights Chegg Study Help Study 101 Help to use EasyBib Plus
Investor Relations Terms of Use College Textbooks Textbook Rental Manage Chegg Study
Jobs Global Privacy Policy eTextbooks Used Textbooks Subscription

Join Our Affiliate Program DO NOT SELL MY INFO Flashcards Digital Access Codes Return Your Books

Media Center Honor Code Learn Chegg Money Textbook Return Policy

Site Map Honor Shield Chegg Math Solver


© 2003-2021 Chegg Inc. All rights reserved.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy