User Tools

Site Tools


script:example
building_blocks.py
"""
Author:  Tai Montgomery
 
Building blocks of a program
 
"""
# Building block: REUSE
def nt_count():
 
	"""
        Code illustrating several important
        building blocks of a program
        """
 
        # Building block: INPUT
	rna = input('Enter an RNA sequence: ')
 
	a = 0
	c = 0
	g = 0
	u = 0
 
	# Building block: REPEATED EXECUTION (looping)
	for nt in rna:
 
	# Building block: CONDITIONAL EXECUTION (conditional statements)
		if nt is 'A':
			a += 1
		elif nt is 'C':
			c += 1
		elif nt is 'G':
			g += 1
		elif nt is 'U':
			u += 1
 
	# Building block: OUTPUT
	print('A:', a, 'C:', c, 'G:', g, 'U:', u)
 
nt_count()
script/example.txt · Last modified: 2018/09/17 14:02 by dokuroot