| | |
Help with Pascal Triangle Program Please
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2009
Posts: 2
Reputation:
Solved Threads: 0
I need to write a program that uses the following function
I need to write another function pascrow(n) where n is a row number in the triangle and returns what that row is in a list. I need pascrow(n) to use the pascnext function though to find it. Any suggestions or help is appreciated!
Python Syntax (Toggle Plain Text)
def pascnext( L ): currentrow = [] if len( L ) == 0: return [1] if len( L ) == 1 and L[ 0 ] == 1: return [ 1, 1 ] else: currentrow += [ 1 ] for i in range( 0, len( L ) - 1 ): currentrow += [ L[ i ] + L[ i + 1 ] ] currentrow += [ 1 ] return currentrow
I need to write another function pascrow(n) where n is a row number in the triangle and returns what that row is in a list. I need pascrow(n) to use the pascnext function though to find it. Any suggestions or help is appreciated!
•
•
Join Date: Oct 2007
Posts: 150
Reputation:
Solved Threads: 39
0
#2 Nov 4th, 2009
Read the last post of masterofpuppets to your other thread (http://www.daniweb.com/forums/thread235765.html) and you'll nearly have the answer...
Put his code in a function (pascrow), change the for loop condition and the print statement and you've got it
Put his code in a function (pascrow), change the for loop condition and the print statement and you've got it
![]() |
Similar Threads
- Pascal's Triangle in C (C)
- Help With Pascal's Triangle in C++ (C++)
- Pascal's Triangle (Legacy and Other Languages)
- pascal triangle program (C++)
- Need Help With Printing Pascal's Triangle In C (C)
- Pascal Triangle (C++)
Other Threads in the Python Forum
- Previous Thread: I don't know what is causing this error...please help
- Next Thread: Help with string formatting
Views: 220 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Python
accessdenied alarm aliased basic beginner casino character code corners cursor definedlines development dictionary digital dynamic editing error events examples excel exe file filename float format ftp function graphics gui handling homework ideas iframe import input java line linux list lists logging loop matching mouse newb number numbers numeric output parameters parsing path port prime program programming progressbar projects py py2exe pygame pygtk pyqt pysimplewizard python random recursion recursive return reverse schedule scrolledtext searchingfile shebang skinning ssh statistics stdout string strings table tails terminal text thread threading time tkinter tlapse tricks tuple tutorial ubuntu unicode urllib urllib2 variable voip windows wxpython





