for loops

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

for loops

Josip-2
I have problem with this question.
Can someone show me the code and than explain it?
 
>>Write a Python program to print out the following  shape. You are expected to use two for loops (these must be nested) to solve this problem.
 
output:
* * * * *
*          *
*          *
* * * * *
 
Thanks


Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries for just 2ยข/min with Yahoo! Messenger with Voice.
_______________________________________________
Tutor maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: for loops

David Rock
* josip <[hidden email]> [2006-04-11 09:13]:

>   I have problem with this question.
>   Can someone show me the code and than explain it?
>    
>   >>Write a Python program to print out the following  shape. You are expected to use two for loops (these must be nested) to solve this problem.
>    
>   output:
>   * * * * *
>   *          *
>   *          *
>   * * * * *

That looks a lot like homework.  If you have a specific question about a
_part_ of code _you_ have written, we'll be glad to help out explaining
those specifics.  

We generally try to stay away from doing the work for you :-)

--
David Rock
[hidden email]
_______________________________________________
Tutor maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/tutor
Reply | Threaded
Open this post in threaded view
|

Re: for loops

Alan Gauld-4
>>   >>Write a Python program to print out the following  shape.
>>   >>You are expected to use two for loops (these must be nested) to solve
>> this problem.
>>
>>   output:
>>   * * * * *
>>   *          *
>>   *          *
>>   * * * * *
>
> That looks a lot like homework.

I agree and very poor homework too.
I certainly wouldn't expect to use two for loops, I'd only use one.
(And that assumes the more general problem of drawing an
arbitrary sized square, for the specific case I'd use a single print
statement and triple quoted string!)

Any homework which implies that only one design is acceptable
is a bad assignment in my book!

> We generally try to stay away from doing the work for you :-)

But the advice stays good. Tell us how far you got and what's
sticking you and we will try to help...

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld


_______________________________________________
Tutor maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/tutor