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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:51:39+00:00 2026-06-18T11:51:39+00:00

I’m writing a program that prints a table with the windchill index. Every windchill

  • 0

I’m writing a program that prints a table with the windchill index. Every windchill value should be adequate to a corresponding row and column.

def main():    
    windSpeed = 0
    temp = 0
    windChill = 35.74 + (0.6215 * temp) - 35.75 * (windSpeed ** 0.16) \
            + 0.4275 * temp * (windSpeed ** 0.16)

    # table frame, temps
    for temp in range(-20, 70, 10):
        print 2 * " ", temp, 
    print "\n", " " * 2, "-" * 51    

    #table frame, speeds
    for windSpeed in range (0, 35, 5):
        print windSpeed


main()

This produces:

  -20    -10    0    10    20    30    40    50    60 
  ---------------------------------------------------
0
5
10
15
20
25
30

Obviously, the hard part is to actually print the windchill values. I’ve been playing with the code quite a bit and it only prints out the first windchill value with its coefficients’ values of 0 and 0, which are defined at the very beggining of the program.

  • 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-18T11:51:40+00:00Added an answer on June 18, 2026 at 11:51 am

    Since it’s impossible go back and change lines already printed afterwards, you need to compute the wind-chills at the same time you print out each row of the table. Rather than repeat the longish expression for each of the temperature and wind speed combinations that appear in each row, it’s better to create a separate function which calculates the value from them and then call it by (its much shorter) name repeatedly.

    The built-in string method format() makes it relatively simple to display all the data being computed the desired way—so taking the time to learn how it works would be a very worthwhile endeavor.

    Here’s code which does this that also tries to follow the
    PEP 8 – Style Guide for Python Code.

    def wind_chill(temp, wind_speed):
        """ Compute wind chill given temperature and wind speed if the
            temperature is 50 degrees Fahrenheit or less and the wind speed is
            above 3 mph, otherwise return 'nan' (not-a-number) because it's an
            undefined quantity in those situations.
        """
        return (35.74 + (0.6215 * temp) - 35.75 * (wind_speed ** 0.16)
                + 0.4275 * temp * (wind_speed ** 0.16)
                    if temp <= 50 and wind_speed > 3 else
                float('nan'))
    
    def main():
        # print table header
        temps = xrange(-20, 70, 10)
        num_temps = len(temps)
        data = [" "] + [temp for temp in temps]
        print ("{:3s}" + num_temps * " {:5d}").format(*data)
        data = [" "] + num_temps * [5 * "-"]
        print ("{:3s}" + num_temps * " {:5s}").format(*data)
    
        # print table rows
        row_format_string = "{:3d}" + num_temps * " {:5.1F}"
        for wind_speed in xrange(0, 35, 5):
            data = [wind_speed] + [wind_chill(temp, wind_speed) for temp in temps]
            print row_format_string.format(*data)
    
    main()
    

    Output:

          -20   -10     0    10    20    30    40    50    60
        ----- ----- ----- ----- ----- ----- ----- ----- -----
      0   NAN   NAN   NAN   NAN   NAN   NAN   NAN   NAN   NAN
      5 -34.0 -22.3 -10.5   1.2  13.0  24.7  36.5  48.2   NAN
     10 -40.7 -28.3 -15.9  -3.5   8.9  21.2  33.6  46.0   NAN
     15 -45.0 -32.2 -19.4  -6.6   6.2  19.0  31.8  44.6   NAN
     20 -48.2 -35.1 -22.0  -8.9   4.2  17.4  30.5  43.6   NAN
     25 -50.8 -37.5 -24.1 -10.7   2.6  16.0  29.4  42.8   NAN
     30 -53.0 -39.4 -25.9 -12.3   1.3  14.9  28.5  42.0   NAN
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I know there's a lot of other questions out there that deal with this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;

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.