A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 4 years ago
I want to write a program in Python which computes and
prints a table of Celsius temperatures and the Fahrenheit equivalents every
10 degrees from OC to lOOC. I spent a lot of time on it and prepared the following code:
def main():
for i in range(0,11):
celsius = i * 10
fehrenheit = ((9.0/5.0)*(celsius)) + 32
print celsius,"C is equal to", fehrenheit,"F"
and it works. But I think I should have given a range of 0100 instead right? I mean i manually found "every
10 degrees from OC to lOOC" but I should have let the program find it right? Please help..Its my first day with programming!
anonymous
 4 years ago
I want to write a program in Python which computes and prints a table of Celsius temperatures and the Fahrenheit equivalents every 10 degrees from OC to lOOC. I spent a lot of time on it and prepared the following code: def main(): for i in range(0,11): celsius = i * 10 fehrenheit = ((9.0/5.0)*(celsius)) + 32 print celsius,"C is equal to", fehrenheit,"F" and it works. But I think I should have given a range of 0100 instead right? I mean i manually found "every 10 degrees from OC to lOOC" but I should have let the program find it right? Please help..Its my first day with programming!

This Question is Open

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0Not sure what you are wanting but what you have is fine. It goes from 0 Celsius to 100 Celsius every 10 degrees. The program is figuring it out. It is figuring it out through fahrenheit = ((9.0/5.0)*(celsius)) + 32. This section is doing the calculations/figuring it out for you. To go from 0 to 100 you should not give it a range of 100. Give it a range of 100 and see what happens. The way you have it is fine. It goes from 0c to 100c every 10 degrees.

heisenberg
 4 years ago
Best ResponseYou've already chosen the best response.1Your program is not wrong, as MathDoodler said. But if you want to do it one less step, the range function allows you to give it a step, which tells it how much it goes up by each time. def main(): for celsius in range(0,101,10): fahrenheit = ((9.0/5.0)*(celsius)) + 32 print celsius,"C is equal to", fahrenheit,"F" If you wanted to go in increments of 4, you would just change the range function to: range(0,101,4)
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.