| | |
Help with Pascal Triangle Program Please
![]() |
•
•
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: 149
Reputation:
Solved Threads: 38
0
#2 28 Days Ago
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
| Thread Tools | Search this Thread |
accessdenied apache application approximation argv array beginner book builtin calculator change converter countpasswordentry curved dan08 dictionary dynamic edit enter examples file float format function gui homework import inches input java keyboard lapse launcher library line lines linux list lists loop microphone mouse movingimageswithpygame mysql mysqlquery newb number numbers numeric output parameters parsing path phonebook plugin port prime programming projects py2exe pygame pyopengl pysimplewizard python random recursion redirect remote reverse scrolledtext session simple smtp software sprite statictext string strings syntax table tennis terminal text textarea thread threading time tlapse trick tuple tutorial twoup ubuntu unicode unit urllib urllib2 variable wordgame wxpython





