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 6391751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:43:44+00:00 2026-05-25T03:43:44+00:00

I am sure this is very simple but I can’t find an answer anywhere.

  • 0

I am sure this is very simple but I can’t find an answer anywhere. Let’s say I have this simple temperature conversion program called ConversionSelector.py that looks like

# Helper function to print all menu items:
def displayMenu():
    print 'Temperature Conversions Menu:';
    print '(1) Convert Fahrenheit to Celsius';
    print '(2) Convert Celsius to Fahrenheit';

# Main function to display menu and invoke user-selected conversion:
def select():
    displayMenu();
    choice = input('Enter choice number: ');
    if (choice == 1):
        F2C();
    elif (choice == 2):
        C2F();
    else:
        print 'Invalid choice: ', choice;
    print 'Bye-bye.';

# Convert Fahrenheit temperature to Celsius temperature:
def F2C():
    Fahrenheit  = input('Enter degrees in Fahrenheit: ');
    Celsius     = (5.0 / 9.0) * (Fahrenheit - 32);
    print Fahrenheit, 'Fahrenheit =', Celsius, 'Celsius';

# Convert Celsius temperature to Fahrenheit temperature:
def C2F():
    Celsius     = input('Enter degrees in Celsius: ');
    Fahrenheit  = (9.0 / 5.0) * Celsius + 32;
    print Celsius, 'Celsius =', Fahrenheit, 'Fahrenheit';

I use a Mac but I can’t get this to run. For example, if I type in the terminal
python ConversionSelector.py it doesn’t do anything. (I have IDLE and Python Launcher installed).

Now when I open up Windows and type select() then it does show the menu with the choice to select from the two conversion methods. Typing the same in the Mac Python Shell gives me this error:

Traceback (most recent call last):
File “”, line 1, in
select()
NameError: name ‘select’ is not defined

I know this is probably something very simple that I am not doing. Any help will be greatly appreciated.

  • 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-25T03:43:45+00:00Added an answer on May 25, 2026 at 3:43 am

    Add this to the bottom of your file:

    if __name__ == '__main__':
       select()
    

    This will make python ConversionSelector.py run your select function. What’s happening here is that __name__ is __main__ when invoking your script directly, so you need to tell the interpreter to run your main function.

    Alternatively, you could import your module from the interpreter. Run python in the same directory as your ConversionSelector.py file. Then run:

    import ConversionSelector
    ConversionSelector.select()
    

    You could also run python with the -i option. Running python -i ConversionSelector.py would import your module and insert all of its names in the global namespace, so you could just run select().

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

Sidebar

Related Questions

I'm sure this has a very simple answer, but I can't seem to find
I'm sure someone will have a very simple answer to this but I can't
I'm sure this is a very simple question, but embarrassed to say I can't
This is probably a very simple question, but I can't find the answer, so
I'm sure its very simple thing, but can't find anything. I have a Dialog:
I'm sure this is very simple, but I can't find it. In the close
I'm sure this is a very simple fix but I cannot seem to find
I'm sure this is very simple. I have gotten colorbox to work before, but
I'm sure this has a very simple answer I am not finding... I have
I am sure this is very simple but I can't get seem to get

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.