# A short tutorial on Python

So I did a little Fahrenheit to Celsius conversion program in Python.

x = int(input(“Enter Temp in F: “))
if (x>=212):
print (“It’s boiling out there, at 100C”)
elif (x<=32):
print (“It’s freezing out there, below 0C”)
print (“The temperature in C is:”)
print ((x-32)*(5/9))

So let’s take it line by line – I put in a couple things where if the Fahrenheit temp is at 212 or above or below 32 it’ll say it’s either boiling or freezing.

First line:
x = int(input(“Enter Temp in F: “))

It says set the variable X with the value of the input from keyboard.

This block uses If statements to test whether the variable x is <=32 (Less than or equal to) or x >= 212 (Greater than or equal to)
And print is obvious – boiling at 100C or Freezing at 0C.

The above is just fluff. The real meat is here

print ((x-32)*(5/9))

That says take the value of x minus 32 then multiply that result times (5 divided by 9). Then the print displays the temperature in Celsius.

You see all I ever did with python is modify scripts. But now I have a grasp of it beyond that.

This site uses Akismet to reduce spam. Learn how your comment data is processed.