| welcome to social.hackers | posts are made by Clocwork and Shadowdrifter | added some new hack diaries + podcasts |

Sunday, June 5, 2011

Programming Lesson Number Two ( Math.py )

                Today’s lesson will be covering use of the Python Math module, and Python’s built-in math functions. The Math module is a module specifically designed to expand on Python’s mathematical functionality by adding things such as square roots, sin, cos , tan. Now if you have ever tried to make a program to solve certain math problems, and have found yourself lacking in certain functions; you will be lacking no longer! The built-in math functions for python are addition, subtraction, multiplication, and division. I will be once more adding code that uses Math.py, and each of the built-in math functions.

import math
print 5+5
print 5*5
print 5/5
print 5-5
print math.sqrt(25)
raw_input()

     Import math is importing the math.py module, which allows you to use the math.sqrt function. Now you may have not seen raw_input() before, but it is a simpler way to pause the program until the user wishes to continue.

No comments:

Post a Comment