Python Forum
Using a range and for loop - temp converter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using a range and for loop - temp converter
#1
Hello,

     This is my first post and my first exposure to Python as a result of a college course I'm taking. My assignment asks to modify a program so that is computes and prints a table of celsius temperatures and the Fahrenheit equivalent every 10 degrees from 0C to 100C. The textbook is not very clear as to how I am supposed to work such a loop, and I've tried many different ways in the last hour but I can't quite figure out if I am defining my variables in the wrong spot or if I am not properly defining the loop. I keep getting a "SyntaxError: Missing parentheses in call to 'print'", so I hope I can get some direction here.

Thanks!

def main():
   print("This program computes and prints a table")
   print("of Celsius temperatures and the Fahrenheit equivalent")
   print("every 10 degrees from 0C to 100C")

   celsius = eval(input("Enter the number zero to begin "))

   for i in range (0, 101, 10):
       fahrenheit = 9/5 * celsius + 32
   
   print("The temperature is", fahrenheit, "degrees Fahrenheit.")

main()
I'm not getting an error per se, but rather this response:

This program computes and prints a table

of Celsius temperatures and the Fahrenheit equivalent
every 10 degrees from 0C to 100C
Enter the number zero to begin 0
The temperature is 32.0 degrees Fahrenheit.

Process finished with exit code 0

I need it to create a table from 0C to 100C, so I don't understand how to get the loop to continue on and create my table.
Reply


Messages In This Thread
Using a range and for loop - temp converter - by rattlerskin - Jan-20-2017, 05:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  My first temperature converter TheLowEndTheory 7 3,452 Oct-18-2020, 04:39 PM
Last Post: buran
  How can I run a function inside a loop every 24 values of the loop iteration range? mcva 1 2,137 Sep-18-2019, 04:50 PM
Last Post: buran
  Temperature converter Help (ASAP) Edison_Weng 1 2,820 Apr-16-2018, 01:55 PM
Last Post: stranac
  Debugging error, while loop out of range zenort 1 3,971 Feb-14-2018, 03:36 PM
Last Post: zenort
  Temp Converter with Kelvin vader33 7 12,181 Oct-02-2016, 05:16 AM
Last Post: vader33

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020