I have something to share with you guys if you can help me out..

Here is an algorithm to print out a pyramid of numbers:

define totalRows to be how many rows
define columnWidth to be how many characters in each column
for currentRow in range 0 up to (but not including)
totalRows
for spaceCounter in range 1 up to (but not including)(totalRowscurrentRow)
print columnWidth spaces
for number in range 0 up to (but not including)
currentRow
print number using columnWidth characters
print currentRow using columnWidth characters
for number in range currentRow-1 down to (but not including) -1
print the number using columnWidth characters
print an end-of-line character

Here I have to Implement the algorithm in Python using ‘for’ loops and the range() builtin function.

Any help guys really appreciated !!!

Recommended Answers

All 4 Replies

Attack the task line by line in python command line.
Don't get confused with define, as python has not definition, you just pick up one small number from your head for the variable

After success in command line write the successfull lines to file and prove to run it and to get same results as interactively.

Just start it and don't be afraid!

Should the pyramid be counting down? Like this:

10
987
654321

Or just a pyramid shape be created from numbers/letters? This doesn't seem too hard either way, I'll try to cook something up, though I personally probably wouldn't use ranges.

Attack the task line by line in python command line.
Don't get confused with define, as python has not definition, you just pick up one small number from your head for the variable

After success in command line write the successfull lines to file and prove to run it and to get same results as interactively.

Just start it and don't be afraid!

Thanks but could you please elaborate abit more with some codes so that i can get it , It would be more than helpful ...

Thanks but could you please elaborate abit more with some codes so that i can get it , It would be more than helpful ...

Your description was already almost Python code, more than pseudocode for the solution.

Rest is your effort.

Tony

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.