[Tutor] can any one help

invincible patriot invincible_patriot at hotmail.com
Sun Jan 31 11:03:29 CET 2010

please check the questions below.
1 1.1 Write a Python program with a loop that prints out a sequence of numbers as follows:151311...31-1

1.2 Write a small Python program that generates the list of all pairs of characters c andits doubling 2  c, where c moves through all the letters of the string "foobar" and prints it out.The result will look like:[(’f’, ’ff’), (’o’, ’oo’), (’o’, ’oo’), (’b’, ’bb’), (’a’, ’aa’), (’r’, ’rr’)]Hint: use list comprehensions.
1.3 Write a small Python program that
1. prints out the length of the string’taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronukupokaiwhenuakitanatahu’
2. prints out how many different characters this string contains
3. replaces all the non-’t’ characters in above string with dots ’.’. So, if the word were’tattoo’, it would print ’t.tt..’.Hints:
(a) use a function to t-ify the string
(b) there are various ways to construct the string, either using the join method or by runninga loop accumulating substrings.
(c) check also out what happens if you apply the conversion list(s) to a string s.
2 2.1 Write a function count char(s, c) that takes a string s, and a character c and returnshow often the character c appears in the string.For example count_char("tattoo", "t") should return 3.

2.2 Write a Python function char_freqency(s)that returns a dictionary which, for eachcharacter of s as a key, stores as value how often this character appears.For example, char_frequency("tattoo") could return {’a’: 1, ’t’: 3, ’o’: 2} (the order ofkey:value pairs does not matter here).
Hint: Consider using the function count_char defined in 2.1.
2.3 Write a program that translates a given string (of arbitrary length) of DNA bases intothe RNA strand that it will produce. For this, research which DNA bases correspond to RNA basesand create a translation table (not an if...else clause!) in the Python program. [4 marks]

3.1 consider the following list of base sequences:ACGTACCTTACTTACCATATCGTACCTCTTACTCATThe task consists of writing a Python program that performs a simple alignment algorithm onthese two strings and prints out this alignment in a suitable readable form. Give a brief commentexplaining the output format.Hints:1. Matching means the following: for a given sequence to be matched, your program should denotewhich bases correspond to bases in the reference sequence and which do not; in addition, markgaps where the reference sequence contains bases which are not present in the sample sequence.For a given sample sequence, your matching algorithm will attempt to match as many basesas possible to those of the reference sequence.2. This is a difficult assignment. Do not attempt it before you have solved the others.3. For this purpose, you are allowed to research and implement publicly documented versions ofthe Needleman-Wunsch algorithm or similar algorithms (however, make sure that you refer-ence them properly!). Also make sure that your program prints out the matches/mismatchesbetween the sequences. You should demonstrate at least two different alignments by usingdifferent gap penalties.Instead of following this hint, you can develop an alternative solution to the matching problem,e.g. based on the Levenshtein distance.

please help me

From: rabidpoobear at gmail.com
Date: Sat, 30 Jan 2010 19:36:30 -0600
Subject: Re: [Tutor] can any one help
To: grigor.kolev at gmail.com
CC: invincible_patriot at hotmail.com; tutor at python.org

On Sat, Jan 30, 2010 at 5:40 PM, Grigor Kolev <grigor.kolev at gmail.com> wrote:

Excuse me but I have question too.

Why when i write this function in python shell not work says

SyntaxError: invalid syntax

but when I use IDLE make endless loop
Your tabbing is probably messed up or something.

You guys both need to be a lot more clear with your questions.
If it doesn't seem like you put in the effort for a proper post then you're unlikely to get a proper reply.


Sorry I also teach Python.

> def fibn(n):

> a,b=15,2

> while a>n:

> print a,     # it is same like         print a, a, b = a, a+b

> You can not print this. SyntaxError: invalid syntax

> a,b=a,a+b

> fibn(-1)


Grigor Kolev <grigor.kolev at gmail.com>


Tutor maillist  -  Tutor at python.org

To unsubscribe or change subscription options:


Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100131/930e969d/attachment-0001.htm>

More information about the Tutor mailing list