Installing Moodle

Installing Moodle is easy. First of all make sure that you have Apache, MySQL (or PostgreSQL), and PHP installed and configured on your system. On Ubuntu, you would type the following to install these applications:

$ sudo install apache2
$ sudo install mysql-server
$ sudo install php5
$ sudo install php5-mysql

php5-mysql is required enable connectivity between PHP5 and MySQL. Create a MySQL root password for your database. Then install Moodle.

$ sudo install moodle



Moodle

A Learning Management System (LMS) is a software application which permits administration, documentation, tracking, development, reporting, of online e-learning content. LMS needs to provide enormous flexibility and fine-grained level of control for administrator, trainers, course developers, and students alike. The needs for each course and each institute are different and LMS much fulfill all their requirements. The best-known LMS are blackboard (formerly Web-CT) and Moodle. Blackboard is a licensed software while Moodle is open source.



Python Dictionaries

Dictionaries are called hashes or associative arrays in PHP and Perl. They are unordered set of key-value pairs. Lists have numerical indices. In a dictionary, the index is called a key and the key is always a string.

version = {'Python': 3, 'Perl': 6}

# add a key-value pair to the dictionary
version['PHP'] = 5
print version
# {'Python': 3, 'PHP': 5, 'Perl': 6}

# remove a key-value pair
del version['Perl']
# {'Python': 3, 'PHP': 5}

# print all the keys
print version.keys()
# ['Python', 'PHP']

# print all values
print version.values()
# [3, 5]

  


Python Sets

A set is an unordered collection which does not allow duplicate elements.

a = [1,2,3,3,4,'yes','no']
print a
# [1, 2, 3, 3, 4, 'yes', 'no']
print set(a)
# set([1, 2, 3, 4, 'yes', 'no'])

The number 3 appeared only once in the set. Searching for items in set is also easy:

a = [1,2,3,3,4,'yes','no']
print set(a)
print 'yes' in a	# true
print 'n' in a		# false
print 2 in a		# true

Set Arithmetic

a = set('python')
b = set('php')
print b			# unique letters
# set(['p', 'h'])
  


Applying functions on a lists using filter, map, reduce

filter(function,sequence)
Applies a function to every element in the sequence. Returns only when the item returns true.

def even_numbers(x):
	return x % 2 == 0

print "Even Numbers"
print filter(even_numbers, range(10,20))

output

Even Numbers
[10, 12, 14, 16, 18]

map(function, sequence)
Applies a function to every element in the sequence and returns the results of the function for each element.

def circumference(r):
	a = 2 * 3.14 * r
	return int(a)

  


Working with Biological Sequences

Opening a FASTA file

fp = file('a.fasta')
a = fp.readlines()
fp.close()
print a

output

['>gi|88853329|emb|AJ628425.1| Fasciola gigantica ITS1, isolate FgGZB2\n',
 'ACCTGAAAATCTACTCTTACACAAGCGATACACGTGTGACCGTCATGTCATGCGATAAAAATTTGCGGAC\n',
 'GGCTATGCCTGGCTCATTGAGGTCACAGCATATCCGATCACTGATGGGGTGCCTACCTGTATGATACTCC\n',
 'GATGGTATGCTTGCGTCTCTCGGGGCGCTTGTCCAAGCCAGGAGAACGGGTTGTACTGCCATGATTGGTA\n',
 'GTGCTAGGCTTAAAGAGGAGATTTGGGCTACGGCCCTGCTCCCGCCCTATGAACTGTTTCATTACTACAA\n',
  


Python Stacks and Queues

In Python, lists can be used as stacks and queues. Stacks are like a box of pringles; the last chip to be placed inside the box is the first one to be taken out. This is called Last In First Out (LIFO). A queue is like the line up at the bus stop. The first person to get in the line is the first person to get on the bus. This is called First In First Out (FIFO).

Python Stacks

# list a is the stack
a = [1,2,3]
a.append(4)
print a
print a.pop()		# 4
print a.pop()		# 3

Python Queues

  


Defining Functions in Python

  • def keyword is used to define a function
  • all variables in a function are local unless defined as global with the keyword global
  • return statement returns the value form the function
  • default values can be defined in function parameters

Defining Python Functions Example 1

# return the maximum value
def maxx(m,n):
    if m > n:
        return m
    else: 
        return n

print maxx(12,45)

Defining Python Functions Example 2

# compute circumference
def circumference(r, pi = 3.14):
  


Python Iteration Statements

  • for is ideal for lists
  • break breaks out of the smallest block
  • continue jumps to the next iteration

Python Iteration Statements Example 1

for i in range(10):
	print i

Python Conditional Statements Example 2

for i in [0,1,2,3,4,5,6,7,8,9]:
	print i

Python Conditional Statements Example 3

a = ['think', 'try']
for x in a:
	print x + 'ing'
# prints thinking and trying



Python Conditional Statements

  • indentation replace curly braces used in C/C++, Java
  • elif is short for else if
  • you can use < (less than), > (greater than), == (equal to), <= (less than or equal to), >= (greater than or equal to) and != (not equal to) in your conditions

Python Conditional Statements Example 1

x = 1
if x > 0:
	print 'positive'

Python Conditional Statements Example 2

x = 1
if x < 0:
	print 'negative'
else:
	print 'positive'

Syndicate content