Hey guys! I have a serious problem. I missed class for computer science because I had two grandparents die in 2 weeks. My teacher has a no exception policy for turning in homework late.

Tonight has been my only free night to do homework but I am stuck and not sure what to do.

I have two problems to do for computer science and I have no idea how to do them. Can someone PLEASE HELP! I would be so gracious!

1. The national weather service computes the wind chill index using the following forumla.

Windchill (ºF) = 35.74 + 0.6215T - 35.75(V^0.16) + 0.4275T(V^0.16)

Where T is the temperature in degrees Fahrenheit and V is the windspeed in miles per hour. Write a program that prints a nicely formatted table of wind chill values. Rows should represent wind speed for 0-50 in 5 mph increments and the columns represent temperatures from -20 to 60 in 10 degree increments.

That is the first problem. I just don't know how to make a table.
Here is a link to the thing it should look like.
http://www.nws.noaa.gov/om/windchill/index.shtml

2. A positive whole number n > 2 is primed if no number between 2 and the square root of n (inclusive) evenly divides n. Write a program that accepts a value of n as input and determines if the value is prime. If n is not prime, your program should quit as soon as it finds a value that evenly divides n.

i have the basics written for this one.

def main():
n = input(Please enter your number:")

main()

Otherwise I am not sure what to do. Any help would be awesome!!!!! PLEASEEEEEEEEEEEEEEE!!!!!

Whatever excuse you can give but no one will do your homework for you.

I can give you some pointers for your first task.

The formula you described can be defined as a function.

def windspeed(t, v):
     # compute the formula you got in the assignment

Then you create two lists with the values in windspeeds and temperatures. To do this you can use the range-function in a list-comprehension. This function takes three values: start, stop and step. The range function is non-inclusive, so you have to give it a stop value that's one step higher than what you want.

windspeeds = [x for x in range(0, 55, 5)

This code computes 0, 5, 10 ... 45, 50
Do the same for temperatures.

Now, the "tricky" part that you don't know how to do: printing the table. This is all about string formatting. You can read up on it here: http://docs.python.org/library/stdtypes.html#string-formatting-operations

This code-bit will print out the table that the assignment asks you for:

print("    ", end="")                        # Pad the table
for x in windspeeds:                         # Print out the windspeed header
    print("%3d " % x, end="")                # no newlines
print()                                      # do a newline
for t in temperatures:                          # for each temperature
    print("%3d " % t, end="")                   # print the temperature
    for v in windspeeds:                        # for each windspeeds
        print("%3d " % windspeed(t, v), end="") # compute the windspeed and print it, no newline
    print()

The above code is written in python 3 and will not work in python 2.x Read up on print formatting and you'll understand how to do it in python 2.x. (Actually the above way isn't the way to do it in python 3, but it works. If you're supposed to deliver python 3 code, you have to use the .format method for the string) The trick is to delay the printing of newlines until you have printed all your values on each line.

No go forth and do your assignment! Post back with the code you have if you have more trouble. Try to create some code for task 2 and post it, and I'll take a look at it.

Oh, and by the way - don't create multiple threads with the same topic. It doesn't matter if you haven't got any answers yet, multiple threads are a no-go.

commented: good point +1

Oh, and by the way - don't create multiple threads with the same topic. It doesn't matter if you haven't got any answers yet, multiple threads are a no-go.

The problem is that he did get a response and still posts multiple times (and probably on other forums) looking for someone to do it for him rather than for help.

commented: Yep, I don't buy it for one minute. +6
commented: i do this sometimes aswell because i cant think of the answer after days of thinking about it, although i can see your point +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.