- Simple Function Functions:
- Procedures do not typically return results and functions do :
def square(x) :
return x*x
-
- Call to an OS command :
import os
import re
get = os.popen("netstat -nr")
for user in get.readlines():
print user,
- Ranges Loops:
number = input("Please Enter a Number : ")
for x in range (1,3):
number = number + input("Please Enter a Number : ")
- Lists :
results=[john,mary,joe] (List)
results.append(jack) (Add to a list)
del results[0] (removes the first element in thr array)a
results.index("joe") (search a list_
- A Tuple is an immutable list.
- Dictionaries :(like hases in Perl) defines a 1 to 1 relationship between keys and values.
>>>d={"server":"pwls1"m "database":"master"}
>>>d["server"]
pwls1
>>d["uid"] = "sa" (add a new item to the dictionary)