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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:47:58+00:00 2026-06-05T23:47:58+00:00

I am trying to write this loop in Python but get confused. Basically I

  • 0

I am trying to write this loop in Python but get confused. Basically I have a starting angle 90 that I want to use a range of -90 to 90, iterating 10 times. After the loop is done, I want to divide the angle by half and repeat the process of using -45 to 45, by 10 iterations, etc.

The end values must be included, so 90 is the last value for the first loop, then 45 is the last value for the second loops, etc.

How can I write this elegantly and efficiently in Python?

startAngle = 90
for i in range(5):
    for x in range(10):
        print values from -startAngle to startAngle (startAngle included)
    startAngle = startAngle / 2
  • 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-05T23:48:00+00:00Added an answer on June 5, 2026 at 11:48 pm
    def angles(x):
        return [ i * x / 5 - x for i in xrange(11)]
    

    angles(90) returns [-90, -72, -54, -36, -18, 0, 18, 36, 54, 72, 90]

    angles(45) returns [-45, -36, -27, -18, -9, 0, 9, 18, 27, 36, 45]

    You can now iterate over the return value, it is a list.

    There are ten steps in my angles method returning eleven values.

    If you want another number of steps:

    def angles(angle, steps):
        return [ i * angle * 2 / (steps - 1) - angle for i in xrange(steps)]
    

    angles(90, 5) returns [-90, -45, 0, 45, 90]

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

Sidebar

Related Questions

I am trying to write a python script that takes record data like this
I have this for loop in C: for (x=100;x>=3.0;x/=2){......} I am trying to write
I am trying to write a program in Python that will loop to keep
I'm trying to write this code using mostly arrays. I'm trying to get Correct
I've been trying myself, and searching online, to write this regular expression but without
I'm trying to write a code that could print something like this -xv -xvv
I am trying to write a python program using Python 3 I have to
I am new to python (and this site); I am trying to write a
I have the following line of xml that I'm trying transform using XSLT but
I have a Django query and some Python code that I'm trying to optimize

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.