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
#6
You could use the "print" format to pretty much do what you you'd like.  For instance you could have this:

for celsius in range(0, 101, 10):
    print("The temperature is {} degrees Fahrenheit.".format(9/5 * celsius + 32))
Notice the use of the double "{}", this corresponds to the first (and currently only) argument in the .format()
That should give you a clue as to how to additionally add content to your print function
For a complete description, refer here: https://docs.python.org/3/tutorial/inputoutput.html
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply


Messages In This Thread
RE: Using a range and for loop - temp converter - by sparkz_alot - Jan-20-2017, 09:15 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  My first temperature converter TheLowEndTheory 7 3,632 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,184 Sep-18-2019, 04:50 PM
Last Post: buran
  Temperature converter Help (ASAP) Edison_Weng 1 2,889 Apr-16-2018, 01:55 PM
Last Post: stranac
  Debugging error, while loop out of range zenort 1 4,023 Feb-14-2018, 03:36 PM
Last Post: zenort
  Temp Converter with Kelvin vader33 7 12,388 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