Hide
Know what you're getting – Unlike many sites, all our code is clearly licensed. Join Siafoo Now or Learn More

Simple Python Functions (will split into seperate types later) Atom Feed 0

In Brief Simple python list and math functions
# 's
 1####Lists functions ####
2x = [] #initialize a new list
3
4x.append(object) # append object to the end of list
5
6x.insert(object, position) #inserts an object to a list AFTER the position given
7
8x.remove(position) #removes an object in given position
9
10
11#### MATH #####
12
13#getting fractions
14
15 answer = numerator / float( denominator )
16
17
18#raise a number to a power
19
20pow(number,exponent)
21
22Alternately
23
24number ** exponent
25
26
27#square root a number
28import math
29
30math.sqrt(number)
31
32# exponential
33
34math.e #returns 2.7182818284590451
35
36#natural log
37math.log(input) #this computes the natural log for a number

Simple python list and math functions