| | |
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: 149
Reputation:
Solved Threads: 38
0
#2 30 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 advanced aliased argv beginner bits calling casino change command convert count csv cturtle cursor def dictionary digital dynamic dynamically enter event examples external file float format frange function google gui hints homework i/o iframe import info input jaunty java keyboard lapse line linux list lists loop microphone mouse multiple newb number numbers obexftp output parameters parsing path port prime programming projects py py2exe pygame pygtk pyopengl python random recursion return scrolledtext signal skinning sprite stderr string strings subprocess table tennis terminal text thread threading time tkinter tlapse tuple tutorial ubuntu unicode urllib urllib2 variable voip web-scrape whileloop windows wxpython





