Question

Pascals Triangle Pascals Triangle is a number pattern with many interesting and useful properties. For example: Each numberExample 3: ş python pascal.py 5 10 Too many arguments. Example 4: python pascal.py spam Invalid argument. Reference: http://w

how to write this code in python?

please don't print the space for each row last number.

Pascal's Triangle Pascal's Triangle is a number pattern with many interesting and useful properties. For example: Each number in the triangle is the sum of the two numbers above it. The number at row n and column k is equal to the binomial coefficient () "n choose k." 1 21 133 1 1 4 6 4 1 Write a program that prints Pascal's Triangle up to and including row n. The number n will be given as a command line argument. Example 1: python pascal.py 5 1 1 2 1 1 33 1 1 4641 1 5 10 10 51 Example 2: $ python pascal.py Not enough arguments.
Example 3: ş python pascal.py 5 10 Too many arguments. Example 4: python pascal.py spam Invalid argument. Reference: http://www.mathsisfun.com/pascals-triangle.html
0 0
Add a comment Improve this question Transcribed image text
Answer #1

def pascaltriangle(n):
    for line in range(1,n+1):
        c=1
        for i in range(1,line+1):
            print(c,end= ' ')
            c = int(c*(line-i)/i)
        print()

def main():
    n =int(input('Enter row number: '))
    pascaltriangle(n+1)

main()

===================================================================================

def pascaltriangle (n) for ïïne in range (1,n+1) for i in range (1, line+1): print (c, end) c- int (c+ (line-i)/i) print() de

Add a comment
Know the answer?
Add Answer to:
How to write this code in python? please don't print the space for each row last number.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT