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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:07:13+00:00 2026-06-14T21:07:13+00:00

i have this huge function and i am wondering how to make it recursive.

  • 0

i have this huge function and i am wondering how to make it recursive. i have the base case which should never come true, so it should always go to else and keep calling itself with the variable t increases. any help would be great
thanks

 def draw(x, y, t, planets):
    if 'Satellites' in planets["Moon"]:
        print ("fillcircle", x, y, planets["Moon"]['Radius']*scale)
    else:
            print("refresh")
            print("colour 0 0 0")
            print("clear")
            print("colour 255 255 255")
            print("fillcircle",x,y,planets['Sun']['Radius']*scale)
            print("text ", "\"Sun\"",x+planets['Sun']['Radius']*scale,y)
            if "Mercury" in planets:
                r_Mercury=planets['Mercury']['Orbital Radius']*scale;
                print("circle",x,y,r_Mercury)
                r_Xmer=x+math.sin(t*2*math.pi/planets['Mercury']['Period'])*r_Mercury
                r_Ymer=y+math.cos(t*2*math.pi/planets['Mercury']['Period'])*r_Mercury
                print("fillcircle",r_Xmer,r_Ymer,3)
                print("text ", "\"Mercury\"",r_Xmer+planets['Mercury']['Radius']*scale,r_Ymer)
            if "Venus" in planets:
                r_Venus=planets['Venus']['Orbital Radius']*scale;
                print("circle",x,y,r_Venus)
                r_Xven=x+math.sin(t*2*math.pi/planets['Venus']['Period'])*r_Venus
                r_Yven=y+math.cos(t*2*math.pi/planets['Venus']['Period'])*r_Venus
                print("fillcircle",r_Xven,r_Yven,3)
                print("text ", "\"Venus\"",r_Xven+planets['Venus']['Radius']*scale,r_Yven)
            if "Earth" in planets:
                r_Earth=planets['Earth']['Orbital Radius']*scale;
                print("circle",x,y,r_Earth)
                r_Xe=x+math.sin(t*2*math.pi/planets['Earth']['Period'])*r_Earth
                r_Ye=y+math.cos(t*2*math.pi/planets['Earth']['Period'])*r_Earth
                print("fillcircle",r_Xe,r_Ye,3)
                print("text ", "\"Earth\"",r_Xe+planets['Earth']['Radius']*scale,r_Ye)
            if "Moon" in planets:
                r_Moon=planets['Moon']['Orbital Radius']*scale;
                print("circle",r_Xe,r_Ye,r_Moon)
                r_Xm=r_Xe+math.sin(t*2*math.pi/planets['Moon']['Period'])*r_Moon
                r_Ym=r_Ye+math.cos(t*2*math.pi/planets['Moon']['Period'])*r_Moon
                print("fillcircle",r_Xm,r_Ym,3)
                print("text ", "\"Moon\"",r_Xm+planets['Moon']['Radius']*scale,r_Ym)
            if "Mars" in planets:
                r_Mars=planets['Mars']['Orbital Radius']*scale;
                print("circle",x,y,r_Mars)
                r_Xmar=x+math.sin(t*2*math.pi/planets['Mars']['Period'])*r_Mars
                r_Ymar=y+math.cos(t*2*math.pi/planets['Mars']['Period'])*r_Mars
                print("fillcircle",r_Xmar,r_Ymar,3)
                print("text ", "\"Mars\"",r_Xmar+planets['Mars']['Radius']*scale,r_Ymar)
            if "Phobos" in planets:
                r_Phobos=planets['Phobos']['Orbital Radius']*scale;
                print("circle",r_Xmar,r_Ymar,r_Phobos)
                r_Xpho=r_Xmar+math.sin(t*2*math.pi/planets['Phobos']['Period'])*r_Phobos
                r_Ypho=r_Ymar+math.cos(t*2*math.pi/planets['Phobos']['Period'])*r_Phobos
                print("fillcircle",r_Xpho,r_Ypho,3)
                print("text ", "\"Phobos\"",r_Xpho+planets['Phobos']['Radius']*scale,r_Ypho)
            if "Deimos" in planets:
                r_Deimos=planets['Deimos']['Orbital Radius']*scale;
                print("circle",r_Xmar,r_Ymar,r_Deimos)
                r_Xdei=r_Xmar+math.sin(t*2*math.pi/planets['Deimos']['Period'])*r_Deimos
                r_Ydei=r_Ymar+math.cos(t*2*math.pi/planets['Deimos']['Period'])*r_Deimos
                print("fillcircle",r_Xdei,r_Ydei,3)
                print("text ", "\"Deimos\"",r_Xpho+planets['Deimos']['Radius']*scale,r_Ydei)
            if "Ceres" in planets:
                r_Ceres=planets['Ceres']['Orbital Radius']*scale;
                print("circle",x,y,r_Ceres)
                r_Xcer=x+math.sin(t*2*math.pi/planets['Ceres']['Period'])*r_Ceres
                r_Ycer=y+math.cos(t*2*math.pi/planets['Ceres']['Period'])*r_Ceres
                print("fillcircle",r_Xcer,r_Ycer,3)
                print("text ", "\"Ceres\"",r_Xcer+planets['Ceres']['Radius']*scale,r_Ycer)
            if "Jupiter" in planets:
                r_Jupiter=planets['Jupiter']['Orbital Radius']*scale;
                print("circle",x,y,r_Jupiter)
                r_Xjup=x+math.sin(t*2*math.pi/planets['Jupiter']['Period'])*r_Jupiter
                r_Yjup=y+math.cos(t*2*math.pi/planets['Jupiter']['Period'])*r_Jupiter
                print("fillcircle",r_Xjup,r_Yjup,3)
                print("text ", "\"Jupiter\"",r_Xjup+planets['Jupiter']['Radius']*scale,r_Yjup)
            if "Io" in planets:
                r_Io=planets['Io']['Orbital Radius']*scale;
                print("circle",r_Xjup,r_Yjup,r_Io)
                r_Xio=r_Xjup+math.sin(t*2*math.pi/planets['Io']['Period'])*r_Io
                r_Yio=r_Yjup+math.cos(t*2*math.pi/planets['Io']['Period'])*r_Io
                print("fillcircle",r_Xio,r_Yio,3)
                print("text ", "\"Io\"",r_Xio+planets['Io']['Radius']*scale,r_Yio)
            if "Europa" in planets:
                r_Europa=planets['Europa']['Orbital Radius']*scale;
                print("circle",r_Xjup,r_Yjup,r_Europa)
                r_Xeur=r_Xjup+math.sin(t*2*math.pi/planets['Europa']['Period'])*r_Europa
                r_Yeur=r_Yjup+math.cos(t*2*math.pi/planets['Europa']['Period'])*r_Europa
                print("fillcircle",r_Xeur,r_Yeur,3)
                print("text ", "\"Europa\"",r_Xeur+planets['Europa']['Radius']*scale,r_Yeur)
            if "Ganymede" in planets:
                r_Ganymede=planets['Ganymede']['Orbital Radius']*scale;
                print("circle",r_Xjup,r_Yjup,r_Ganymede)
                r_Xgan=r_Xjup+math.sin(t*2*math.pi/planets['Ganymede']['Period'])*r_Ganymede
                r_Ygan=r_Yjup+math.cos(t*2*math.pi/planets['Ganymede']['Period'])*r_Ganymede
                print("fillcircle",r_Xgan,r_Ygan,3)
                print("text ", "\"Ganymede\"",r_Xgan+planets['Ganymede']['Radius']*scale,r_Ygan)
            if "Callisto" in planets:
                r_Callisto=planets['Callisto']['Orbital Radius']*scale;
                print("circle",r_Xjup,r_Yjup,r_Callisto)
                r_Xcal=r_Xjup+math.sin(t*2*math.pi/planets['Callisto']['Period'])*r_Callisto
                r_Ycal=r_Yjup+math.cos(t*2*math.pi/planets['Callisto']['Period'])*r_Callisto
                print("fillcircle",r_Xcal,r_Ycal,3)
                print("text ", "\"Callisto\"",r_Xcal+planets['Callisto']['Radius']*scale,r_Ycal)
            if "Saturn" in planets:
                r_Saturn=planets['Saturn']['Orbital Radius']*scale;
                print("circle",x,y,r_Saturn)
                r_Xsat=x+math.sin(t*2*math.pi/planets['Saturn']['Period'])*r_Saturn
                r_Ysat=y+math.cos(t*2*math.pi/planets['Saturn']['Period'])*r_Saturn
                print("fillcircle",r_Xsat,r_Ysat,3)
                print("text ", "\"Saturn\"",r_Xsat+planets['Saturn']['Radius']*scale,r_Ysat)
            if "Mimas" in planets:
                r_Mimas=planets['Mimas']['Orbital Radius']*scale;
                print("circle",r_Xsat,r_Ysat,r_Mimas)
                r_Xmim=r_Xsat+math.sin(t*2*math.pi/planets['Mimas']['Period'])*r_Mimas
                r_Ymim=r_Ysat+math.cos(t*2*math.pi/planets['Mimas']['Period'])*r_Mimas
                print("fillcircle",r_Xmim,r_Ymim,3)
                print("text ", "\"Mimas\"",r_Xmim+planets['Mimas']['Radius']*scale,r_Ymim)
            if "Enceladus" in planets:
                r_Enceladus=planets['Enceladus']['Orbital Radius']*scale;
                print("circle",r_Xsat,r_Ysat,r_Enceladus)
                r_Xenc=r_Xsat+math.sin(t*2*math.pi/planets['Enceladus']['Period'])*r_Enceladus
                r_Yenc=r_Ysat+math.cos(t*2*math.pi/planets['Enceladus']['Period'])*r_Enceladus
                print("fillcircle",r_Xenc,r_Yenc,3)
                print("text ", "\"Enceladus\"",r_Xenc+planets['Enceladus']['Radius']*scale,r_Yenc)
            if "Tethys" in planets:
                r_Tethys=planets['Tethys']['Orbital Radius']*scale;
                print("circle",r_Xsat,r_Ysat,r_Tethys)
                r_Xtet=r_Xsat+math.sin(t*2*math.pi/planets['Tethys']['Period'])*r_Tethys
                r_Ytet=r_Ysat+math.cos(t*2*math.pi/planets['Tethys']['Period'])*r_Tethys
                print("fillcircle",r_Xtet,r_Ytet,3)
                print("text ", "\"Tethys\"",r_Xtet+planets['Tethys']['Radius']*scale,r_Ytet)
            if "Dione" in planets:
                r_Dione=planets['Dione']['Orbital Radius']*scale;
                print("circle",r_Xsat,r_Ysat,r_Dione)
                r_Xdio=r_Xsat+math.sin(t*2*math.pi/planets['Dione']['Period'])*r_Dione
                r_Ydio=r_Ysat+math.cos(t*2*math.pi/planets['Dione']['Period'])*r_Dione
                print("fillcircle",r_Xdio,r_Ydio,3)
                print("text ", "\"Dione\"",r_Xdio+planets['Dione']['Radius']*scale,r_Ydio)
            if "Rhea" in planets:
                r_Rhea=planets['Rhea']['Orbital Radius']*scale;
                print("circle",r_Xsat,r_Ysat,r_Rhea)
                r_Xrhe=r_Xsat+math.sin(t*2*math.pi/planets['Rhea']['Period'])*r_Rhea
                r_Yrhe=r_Ysat+math.cos(t*2*math.pi/planets['Rhea']['Period'])*r_Rhea
                print("fillcircle",r_Xrhe,r_Yrhe,3)
                print("text ", "\"Rhea\"",r_Xrhe+planets['Rhea']['Radius']*scale,r_Yrhe)
            if "Titan" in planets:
                r_Titan=planets['Titan']['Orbital Radius']*scale;
                print("circle",r_Xsat,r_Ysat,r_Titan)
                r_Xtit=r_Xsat+math.sin(t*2*math.pi/planets['Titan']['Period'])*r_Titan
                r_Ytit=r_Ysat+math.cos(t*2*math.pi/planets['Titan']['Period'])*r_Titan
                print("fillcircle",r_Xtit,r_Ytit,3)
                print("text ", "\"Titan\"",r_Xtit+planets['Titan']['Radius']*scale,r_Ytit)
            if "Iapetus" in planets:
                r_Iapetus=planets['Iapetus']['Orbital Radius']*scale;
                print("circle",r_Xsat,r_Ysat,r_Iapetus)
                r_Xiap=r_Xsat+math.sin(t*2*math.pi/planets['Iapetus']['Period'])*r_Iapetus
                r_Yiap=r_Ysat+math.cos(t*2*math.pi/planets['Iapetus']['Period'])*r_Iapetus
                print("fillcircle",r_Xiap,r_Yiap,3)
                print("text ", "\"Iapetus\"",r_Xiap+planets['Iapetus']['Radius']*scale,r_Yiap)
            if "Uranus" in planets:
                r_Uranus=planets['Uranus']['Orbital Radius']*scale;
                print("circle",x,y,r_Uranus)
                r_Xura=x+math.sin(t*2*math.pi/planets['Uranus']['Period'])*r_Uranus
                r_Yura=y+math.cos(t*2*math.pi/planets['Uranus']['Period'])*r_Uranus
                print("fillcircle",r_Xura,r_Yura,3)
                print("text ", "\"Uranus\"",r_Xura+planets['Uranus']['Radius']*scale,r_Yura)
            if "Puck" in planets:
                r_Puck=planets['Puck']['Orbital Radius']*scale;
                print("circle",r_Xura,r_Yura,r_Puck)
                r_Xpuc=r_Xura+math.sin(t*2*math.pi/planets['Puck']['Period'])*r_Puck
                r_Ypuc=r_Yura+math.cos(t*2*math.pi/planets['Puck']['Period'])*r_Puck
                print("fillcircle",r_Xpuc,r_Ypuc,3)
                print("text ", "\"Puck\"",r_Xpuc+planets['Puck']['Radius']*scale,r_Ypuc)
            if "Miranda" in planets:
                r_Miranda=planets['Miranda']['Orbital Radius']*scale;
                print("circle",r_Xura,r_Yura,r_Miranda)
                r_Xmira=r_Xura+math.sin(t*2*math.pi/planets['Miranda']['Period'])*r_Miranda
                r_Ymira=r_Yura+math.cos(t*2*math.pi/planets['Miranda']['Period'])*r_Miranda
                print("fillcircle",r_Xmira,r_Ymira,3)
                print("text ", "\"Miranda\"",r_Xmira+planets['Miranda']['Radius']*scale,r_Ymira)
            if "Ariel" in planets:
                r_Ariel=planets['Ariel']['Orbital Radius']*scale;
                print("circle",r_Xura,r_Yura,r_Ariel)
                r_Xari=r_Xura+math.sin(t*2*math.pi/planets['Ariel']['Period'])*r_Ariel
                r_Yari=r_Yura+math.cos(t*2*math.pi/planets['Ariel']['Period'])*r_Ariel
                print("fillcircle",r_Xari,r_Yari,3)
                print("text ", "\"Ariel\"",r_Xari+planets['Ariel']['Radius']*scale,r_Yari)
            if "Umbriel" in planets:
                r_Umbriel=planets['Umbriel']['Orbital Radius']*scale;
                print("circle",r_Xura,r_Yura,r_Umbriel)
                r_Xumb=r_Xura+math.sin(t*2*math.pi/planets['Umbriel']['Period'])*r_Umbriel
                r_Yumb=r_Yura+math.cos(t*2*math.pi/planets['Umbriel']['Period'])*r_Umbriel
                print("fillcircle",r_Xumb,r_Yumb,3)
                print("text ", "\"Umbriel\"",r_Xumb+planets['Umbriel']['Radius']*scale,r_Yumb)
            if "Titania" in planets:
                r_Titania=planets['Titania']['Orbital Radius']*scale;
                print("circle",r_Xura,r_Yura,r_Titania)
                r_Xtita=r_Xura+math.sin(t*2*math.pi/planets['Titania']['Period'])*r_Titania
                r_Ytita=r_Yura+math.cos(t*2*math.pi/planets['Titania']['Period'])*r_Titania
                print("fillcircle",r_Xtita,r_Ytita,3)
                print("text ", "\"Titania\"",r_Xtita+planets['Titania']['Radius']*scale,r_Ytita)
            if "Oberon" in planets:
                r_Oberon=planets['Oberon']['Orbital Radius']*scale;
                print("circle",r_Xura,r_Yura,r_Oberon)
                r_Xober=r_Xura+math.sin(t*2*math.pi/planets['Oberon']['Period'])*r_Oberon
                r_Yober=r_Yura+math.cos(t*2*math.pi/planets['Oberon']['Period'])*r_Oberon
                print("fillcircle",r_Xober,r_Yober,3)
                print("text ", "\"Oberon\"",r_Xober+planets['Oberon']['Radius']*scale,r_Yober)
            if "Neptune" in planets:
                r_Neptune=planets['Neptune']['Orbital Radius']*scale;
                print("circle",x,y,r_Neptune)
                r_Xnep=x+math.sin(t*2*math.pi/planets['Neptune']['Period'])*r_Neptune
                r_Ynep=y+math.cos(t*2*math.pi/planets['Neptune']['Period'])*r_Neptune
                print("fillcircle",r_Xnep,r_Ynep,3)
                print("text ", "\"Neptune\"",r_Xnep+planets['Neptune']['Radius']*scale,r_Ynep)
            if "Titan" in planets:
                r_Titan=planets['Titan']['Orbital Radius']*scale;
                print("circle",r_Xnep,r_Ynep,r_Titan)
                r_Xtita=r_Xnep+math.sin(t*2*math.pi/planets['Titan']['Period'])*r_Titan
                r_Ytita=r_Ynep+math.cos(t*2*math.pi/planets['Titan']['Period'])*r_Titan
                print("fillcircle",r_Xtita,r_Ytita,3)
                print("text ", "\"Titan\"",r_Xtita+planets['Titan']['Radius']*scale,r_Ytita)

            t += 0.003
            draw(x, y, t, planets)
def draw(x, y, t, planets):
    if 'Satellites' in planets["Moon"]:
        print ("fillcircle", x, y, planets["Moon"]['Radius']*scale)
    else:
        print("refresh")
        print("colour 0 0 0")
        print("clear")
        print("colour 255 255 255")
        print("fillcircle",x,y,planets['Sun']['Radius']*scale)
        print("text ", "\"Sun\"",x+planets['Sun']['Radius']*scale,y)

        for each in planets.keys():
                r_planet=planets[each]['Orbital Radius']*scale;
                print("circle", x, y, r_planet)
                #if "Period" in planets[each]:
                    #r_X = x+math.sin(t*2*math.pi/planets[each]['Period'])*r_planet
                    #r_Y = y+math.cos(t*2*math.pi/planets[each]['Period'])*r_planet
                    #print("fillcircle",r_X,r_Y,3)
                    #print("text ", each, r_X+planets[each]['Radius']*scale,r_Y)
                    #t += 0.003

print(draw(x, y, t, planets))

i trimmed down the draw to the above it calculates where the circle goes but doesnt print it in quickdraw??

  • 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-14T21:07:14+00:00Added an answer on June 14, 2026 at 9:07 pm

    I think you should define the sun first outside your recursive function because the sun is fixed anyway.

    e.g.

            print("fillcircle",400,200,planets['Sun']['Radius']*scale)
            print("text ", "\"Sun\"",x+planets['Sun']['Radius']*scale,y)
                 def planets:
                        if ~~~~~
    

    the scale should be defined as well.

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

Sidebar

Related Questions

I have this huge domain object(say parent) which contains other domain objects. It takes
I have a huge problem with this method im trying to make. I have
So I have this huge tree that is basically a big switch/case with string
I have a recursive function which index a textile and if I use it
i have this dictionary: a) 2012 UN NEWNW = ( 2012/06/04 Saudi Arabia Huge
I have a huge string that looks like this: Text Text Text Text Text
I had a huge file for creating this GUI and I have shortened it
I have a huge autocomplete field with a list of exams. This field prepends
So I have this (huge) table , classed with css (big_conv_tbl) . All empty
am wondering if I'm doing this right. I want to split a huge py

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.