Main.Celsius2fahrenheit History

Hide minor edits - Show changes to markup

January 29, 2013, at 02:43 PM MST by 129.82.44.223 -
Changed lines 3-10 from:

"""converting degrees celsius to fahrenheit"""

def celsius2fahrenheit(celsius) :

    """A function for converting degrees celsius to fahrenheit"""

    fahrenheit = float(celsius) * 9 / 5 + 32

    print celsius, "degrees celsius equals", fahrenheit, "degrees fahrenheit"
to:

"""A program for converting degrees celsius to fahrenheit"""

  1. get degrees celsius from the user

celsius = input("enter degrees in celsius: ")

  1. convert to fahrenheit

fahrenheit = float(celsius) * 9 / 5 + 32

print celsius, "degrees celsius equals", fahrenheit, "degrees fahrenheit"

January 26, 2010, at 12:46 PM MST by 129.82.44.241 -
Changed lines 3-55 from:

"""Using some of python's built in functions, the math module, and our celsius to fahrenheit conversion function """

  1. Most functions have arguments that provide the function data on
  2. which to work
  3. Example: the absolute value function:

print "the absolute value of 5 is", abs(5) print "the absolute value of -5 is", abs(-5)

  1. notice that this function RETURNS a value.
  2. you can reassign that value to a variable:

a = abs(-5)

  1. some functions take more than one argument:

print pow(2, 3)

  1. pow is a more flexible version of the exponentiation operator
  2. the max function returns the maximum number among its arguments

print max(1, 10)

  1. it can take as many arguments as you want

print max(1, 10, 3)

  1. let's use the celsius2fahrenheit function we wrote
  2. to do that we first need to IMPORT the module in which it exists:

import celsius2fahrenheit

  1. now we can access the function using dot notation

celsius2fahrenheit.celsius2fahrenheit(21)

import math

  1. the math module is described at
  2. http://docs.python.org/library/math.html
  3. it provides all kinds of mathematical functions for example:
  4. sqrt

print math.sqrt(9) print math.log10(1000)

  1. it also includes constants like e and pi

print math.pi print math.e

  1. the sys module is a module that provides system specific functions
  2. and constants. see http://docs.python.org/library/sys.html

import sys

  1. sys.path is the set of directories where the interpreter
  2. looks for modules

print sys.path

to:

"""converting degrees celsius to fahrenheit"""

def celsius2fahrenheit(celsius) :

    """A function for converting degrees celsius to fahrenheit"""

    fahrenheit = float(celsius) * 9 / 5 + 32

    print celsius, "degrees celsius equals", fahrenheit, "degrees fahrenheit"
January 26, 2010, at 12:46 PM MST by 129.82.44.241 -
Added lines 1-57:

(:source lang=python:)

"""Using some of python's built in functions, the math module, and our celsius to fahrenheit conversion function """

  1. Most functions have arguments that provide the function data on
  2. which to work
  3. Example: the absolute value function:

print "the absolute value of 5 is", abs(5) print "the absolute value of -5 is", abs(-5)

  1. notice that this function RETURNS a value.
  2. you can reassign that value to a variable:

a = abs(-5)

  1. some functions take more than one argument:

print pow(2, 3)

  1. pow is a more flexible version of the exponentiation operator
  2. the max function returns the maximum number among its arguments

print max(1, 10)

  1. it can take as many arguments as you want

print max(1, 10, 3)

  1. let's use the celsius2fahrenheit function we wrote
  2. to do that we first need to IMPORT the module in which it exists:

import celsius2fahrenheit

  1. now we can access the function using dot notation

celsius2fahrenheit.celsius2fahrenheit(21)

import math

  1. the math module is described at
  2. http://docs.python.org/library/math.html
  3. it provides all kinds of mathematical functions for example:
  4. sqrt

print math.sqrt(9) print math.log10(1000)

  1. it also includes constants like e and pi

print math.pi print math.e

  1. the sys module is a module that provides system specific functions
  2. and constants. see http://docs.python.org/library/sys.html

import sys

  1. sys.path is the set of directories where the interpreter
  2. looks for modules

print sys.path

(:sourceend:)