Home » Python Programming » Python Programming – Week 6 – Mathematic Operators

Python Programming – Week 6 – Mathematic Operators

We have already been introduced to the input and print functions in Python, as well as the concept of the variable. Below is a simple greeter program. Notice I have included comments with the # sign. It is good practice to identify the program, and provide me a description, your name, and the date you created the program.

# Greeter Program
# Demonstrates print and input functions
# Matt Cole
# 9.18.16

name = “Matt”
print (name)
print (“Hi ” , name)

input(“\n\nPress the key to exit.”)

The above code would produce the following:


While nice, we would also like to add some additional math in our program. The video below covers some mathematical operators and expands on the greeter program, into an age difference program.


Here is an example for the formula Fahrenheit to Celsius.

# Demonstrates Fahrenheit to Celsius formula
# Matt Cole
# 9.18.16

F = 98.6
answer = (F – 32) * (5/9)

print (answer)

When ran, we get the answer 37.0.





Leave a comment

Your email address will not be published. Required fields are marked *