Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6971889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:53:50+00:00 2026-05-27T16:53:50+00:00

I am new to python and doing this homework. I need to create a

  • 0

I am new to python and doing this homework. I need to create a small program with menu. I was very good ’til now. I am a little bit lost. How can I pass a value to the function? Can you please check if there are any other faults in my code.

import turtle as t


def how_many():
    while True:  
        print "  How many of then do you want to draw?"
        print "  (Range is from 1 to 5)"
        shape_no = raw_input('  Enter your choice: ')
        try: 
            shape_no = int(shape_no)
            if (1 <= shape_no <= 5):
                print "Your number is ok"
                break
            else:
                print
                print "from 1 to 5 only"

        except:
            print "Only numbers allowed - Please try again"
    return True


#=========#=========#=========#=========#=========#=========#=========#


def draw_square():
    t.penup() 
    t.setpos(-200,0) 
    t.pendown()

    Number_of = 5
    for a in range(Number_of): 
        for a in range(4): 
            t.forward(60) 
            t.left(90)
        t.penup() 
        t.forward(80)
        t.pendown()

#=========#=========#=========#=========#=========#=========#=========#
def main():
    while True:
        print
        print "  Draw a Shape"
        print "  ============"
        print
        print "  1 - Draw a square"
        print
        print "  X - Exit"
        print

        choice = raw_input('  Enter your choice: ')

        if (choice == 'x') or (choice == 'X'):
            break
        elif choice == '1':
            how_many()
            draw_square()
        else:
            print 'Try again'



#=========#=========#=========#=========#=========#=========#=========#
if __name__ == "__main__":
    main()

#=========#=========#=========#=========#=========#=========#=========#
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:53:51+00:00Added an answer on May 27, 2026 at 4:53 pm

    For how to define and call functions, see the Python tutorial.

    For code review, try https://codereview.stackexchange.com/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to Python and am curious if I am doing this correctly.
I'm new to Ruby (experienced with Python, C++ and C). I need to create
I've never used SOAP before and I'm sort of new to Python. I'm doing
I'm a new Python programmer who is having a little trouble using 'self' in
I'm new to Python (I have been programming in Java for multiple years now
The string.replace() is deprecated on python 3.x. What is the new way of doing
When I first learned Python, I got used to doing this: print text, lineNumber,
Alright, this is probably a really silly question but I am new to Python/Django
I'm a new Python programmer who is making the leap from 2.6.4 to 3.1.1.
Im new two python and am trying to grow a dictionary of dictionaries. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.