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

  • Home
  • SEARCH
  • 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 8914341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:41:45+00:00 2026-06-15T04:41:45+00:00

I’m trying to get this block of code to determine planet type based off

  • 0

I’m trying to get this block of code to determine planet type based off of distance from the star and the only one it will print out the info for is the terraform planet.

If I have it print planet type before the third if statement it will print all the planet type’s it chooses, but the only if statement it seems to follow through on is “if planet_type is “terraform”:

for distance in (a):
    while True:
        random_x = random.randint(-distance,distance)
        random_y = random.randint(-distance,distance)

        if(random_x <distance and random_x >-distance and random_y <distance and random_y >-distance):
            continue
        else:
            print "Creating planets"
            time.sleep(.5)
            print distance

       if star_size*100 >= distance:
           possible_planet_type = ('mineral' , 'gas', 'organic', 'terraform', 'ice')
           planet_type = random.choice(possible_planet_type)
       if planet_type is "mineral":
           planet_diameter = random.randint(3000,8000)
           iron = planet_diameter*random.randint(10,100)    
           carbon = planet_diameter*random.randint(5,50)
           oxygen = planet_diameter*random.randint(0,0)
           h2o = planet_diameter*random.randint(0,1)
           deuterium = planet_diameter*random.randint(0,5)
           helium_3 = planet_diameter*random.randint(0,2)
           print planet_type, planet_diameter, iron, carbon, oxygen, h2o, deuterium, helium_3
           # name = a[distance]

        elif planet_type is "organic":
            planet_diameter = random.randint(8000,10000)
            iron = planet_diameter*random.randint(10,20)
            carbon = planet_diameter*random.randint(5,10)
            oxygen = planet_diameter*random.randint(40,100)
            h2o = planet_diameter*random.randint(30,100)
            deuterium = planet_diameter*random.randint(0,3)
            helium_3 = planet_diameter*random.randint(0,2)
            print planet_type, planet_diameter, iron, carbon, oxygen, h2o, deuterium, helium_3
            # name = a[distance]

        elif planet_type is "terraform":
            planet_diameter = random.randint(8000,10000)
            iron = planet_diameter*random.randint(10,20)
            carbon = planet_diameter*random.randint(5,10)
            oxygen = planet_diameter*random.randint(40,100)
            h2o = planet_diameter*random.randint(30,100)
            deuterium = planet_diameter*random.randint(0,3)
            helium_3 = planet_diameter*random.randint(0,2)
            print planet_type, planet_diameter, iron, carbon, oxygen, h2o, deuterium, helium_3
            # name = a[distance]

        elif planet_type is "gas":
            planet_diameter = random.randint(20000,90000)
            iron = planet_diameter*random.randint(10,20)
            carbon = planet_diameter*random.randint(5,10)
            oxygen = planet_diameter*random.randint(40,100)
            h2o = planet_diameter*random.randint(30,100)
            deuterium = planet_diameter*random.randint(0,0)
            helium_3 = planet_diameter*random.randint(0,2)
            print planet_type, planet_diameter, iron, carbon, oxygen, h2o, deuterium, helium_3
            # name = a[distance]

       elif planet_type is "ice":
            planet_diameter = random.randint(2000,6000)
            iron = planet_diameter*random.randint(10,20)
            carbon = planet_diameter*random.randint(5,10)
            oxygen = planet_diameter*random.randint(40,100)
            h2o = planet_diameter*random.randint(30,100)
            deuterium = planet_diameter*random.randint(0,1)
            helium_3 = planet_diameter*random.randint(0,1)
            print planet_type, planet_diameter, iron, carbon, oxygen, h2o, deuterium, helium_3
            # name = a[distance]

I get the following output:

Creating planets
6199
terraform 8578 162982 77202 737708 660506 17156 17156
Creating planets
4664
Creating planets
9844
Creating planets
4410
terraform 8280 99360 41400 819720 571320 0 0
Creating planets
7483
Creating planets
7882
Creating planets
2111
Creating planets
978
Creating planets
1857
terraform 9446 122798 94460 765126 425070 9446 9446
Creating planets
9155
Creating planets
1093
Creating planets
8646
Creating planets
5313
  • 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-06-15T04:41:46+00:00Added an answer on June 15, 2026 at 4:41 am

    Change all is to ==, e.g.:

    if planet_type == "mineral":
    

    While using is might work in some cases, the correct way to compare strings is by using ==.

    To give some more background, is compares object identity rather than their contents. Two string literals containing the same text may or may not have the same identity.

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is

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.