# Python questions help

Joshua Landau joshua.landau.ws at gmail.com
Thu Nov 15 21:12:56 CET 2012

```On 15 November 2012 01:47, su29090 <129km09 at gmail.com> wrote:

> I brought a python book and i'm a beginner and I read and tried to do the
> questions and I still get it wrong.
>
> How to create a program that reads an uspecified number of integers, that
> determines how many positive and negative values have been read, and
> computes the total and average of the input values(not counting zeroes). My
> program have to end with the input 0 and have to display the average as a
> floating-point number.
>

Think about the requirements.
For example, you need here:
* Some sort of loop to take in an unlimited number of integers
* Some way to take in integers
* Some way of stopping when a 0 is entered
* Some way of finding the total and averages
* Some way of putting it all together

If you can solve some of these sub-tasks and just need help with others,
tell us what you've done and we'll help you work out the rest.

Use nested loops that display the following patterns in separate programs:
>
> 1
> 12
> 123
> 1234
> 12345
> 123456
>

What are the patterns here?
1st: 1 -> 2 -> 3 -> 4 -> ...
2nd: 1 -> 12 -> 123 -> 1234 -> ...

How would you do these? How would you combine them?

> 123456
> 12345
> 1234
> 123
> 12
> 1
>

How would you change the above to do this instead?

>      1
>     21
>    321
>   4321
>  54321
> 654321
>

How would you change it to do this?

> Write a program that computes the following summation:
>
> 1/ 1+square root of 2 + 1/ 1+square root of 2 + square root of 3 + 1/
> 1+square root of 3 + square root of 4...+ 1/ 1+square root of 624 + square
> root of 625
>

You've probably written this wrong. You've got:
(1/ 1) + (square root of 2) +  (1/ 1) + (square root of 2) + (square root
of 3) + (1/ 1) + (square root of 3) + (square root of 4)... +  (1/ 1) +
(square root of 624) + (square root of 625)

Which you can write as: 1 + root(2) + 1 + root(2) + root(3) + 1 + root(3) +
root(4) + ... + 1 + root(624) + root(625)
As (1/1) is 1. You probably need brackets somewhere. I've never seen any
equation like this, so I can't guess at what you really wanted.

Do you know how to find the square root? Just search "square root python"
if you do not.
Then put it in a loop.

> How to  a program to draw a chessboard using range?
>

I imagine you want to use "loops", where a range is what you loop over.

O X O X O X O X
X O X O X O X O
O X O X O X O X
X O X O X O X O
O X O X O X O X
X O X O X O X O
O X O X O X O X
X O X O X O X O

It's 8 by 8, so you want to loop 8 times for one dimension and 8 times for
the other. How would you use range to do this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20121115/c6338b60/attachment.html>
```

More information about the Python-list mailing list