[Tutor] can any one help

Grigor Kolev grigor.kolev at gmail.com
Sun Jan 31 00:21:15 CET 2010


В 22:49 +0000 на 30.01.2010 (сб), invincible patriot написа:

> ya definately, just give me the hint
> 
> i made a prog for the first one but it when ran, saying RESTART in
> active shell
> 
> 
> def fibn(n):
> a,b=15,2
> while a>n:
> print a,
> a,b=a,a+b
> fibn(-1)
> 
> 
> whatz rong in this prog that the error is saying no break point
> 
> 
> thanks
> 
> ______________________________________________________________________
> From: anand.shashwat at gmail.com
> Date: Sun, 31 Jan 2010 04:16:40 +0530
> Subject: Re: [Tutor] can any one help
> To: invincible_patriot at hotmail.com
> CC: tutor at python.org
> 
> I got the question. I just gave you hints, so as you can try yourself.
> Also please use 'Reply all'
> 
> 
> On Sun, Jan 31, 2010 at 4:08 AM, invincible patriot
> <invincible_patriot at hotmail.com> wrote:
> 
>         I want to use WHILE LOOP in the first one and in the second
>         question we need to take a string 'foobar' and then we should
>         make the prog to get the following out put
>         
>         let me tel u the exact question
>         
>         
>         Write a small Python program that generates the list of all
>         pairs of characters c and
>         its 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’)]
>         
>         
>         thatz the exact 2nd question
>         also let me know aboutthe first one
>         
>         
>         thanks allot
>         
>         
>         ______________________________________________________________
>         From: anand.shashwat at gmail.com
>         
>         
>         Date: Sun, 31 Jan 2010 04:05:09 +0530
>         
>         
>         Subject: Re: [Tutor] can any one help
>         To: invincible_patriot at hotmail.com
>         CC: tutor at python.org
>         
>         
>         
>         Tips:
>         
>         1.
>         range can be stepped down in reverse order
>         ex ->
>         >>> range(10, 1, -2)
>         [10, 8, 6, 4, 2]
>         
>         2.
>         you can directly get chars of string.
>         ex ->
>         >>> [i for i in 'foobar']
>         ['f', 'o', 'o', 'b', 'a', 'r']
>         also
>         >>> 2 * 'f'
>         'ff'
>         
>         
>         
>         On Sun, Jan 31, 2010 at 3:56 AM, Shashwat Anand
>         <anand.shashwat at gmail.com> wrote:
>         
>                 seems like homework ;)
>                 Can you paste your approach here ?
>                 
>                 
>                 
>                 On Sun, Jan 31, 2010 at 3:03 AM, invincible patriot
>                 <invincible_patriot at hotmail.com> wrote:
>                 
>                         
>                         
>                         hi
>                         
>                         i am stuck in few tasks can some one help me
>                         in that
>                         here are first few tasks
>                         
>                         
>                         1
>                         how can i print the following series, using a
>                         loop
>                         15
>                         13
>                         11
>                         ...
>                         3
>                         1
>                         -1
>                         ========
>                         2
>                         Write a small Python program that generates
>                         the list of all pairs of characters c and
>                         its 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’)]
>                         
>                         
>                         please help me out in these two tasks
>                         
>                         
>                         
>                         
>                         ______________________________________________
>                         Hotmail: Trusted email with powerful SPAM
>                         protection. Sign up now.
>                         
>                         
>                         
>                         
>                         _______________________________________________
>                         Tutor maillist  -  Tutor at python.org
>                         To unsubscribe or change subscription options:
>                         http://mail.python.org/mailman/listinfo/tutor
>                         
>                 
>                 
>         
>         
>         
>         
>         
>         
>         ______________________________________________________________
>         Hotmail: Trusted email with powerful SPAM protection. Sign up
>         now.
> 
> 
> 
> 
> 
> 
> ______________________________________________________________________
> Your E-mail and More On-the-Go. Get Windows Live Hotmail Free. Sign up
> now.
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor



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>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100131/720dd9d1/attachment-0001.htm>


More information about the Tutor mailing list