Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import math import random import string import collections import datetime import re import time import copy def drawPascalsTriangle(n) : your code here... # end def

import math import random import string import collections import datetime import re import time import copy  def drawPascalsTriangle(n) : your code here... # end def def alphaFrequency(userString) : your code here... # end def def encryptStr(userString, n) : your code here... # end def  def main( ) : myStr = """ You're an interesting species, an interesting mix. You're capable of such beautiful dreams and such horrible nightmares. You feel so lost, so cut off, so alone, only you're not. See, in all our searching, the only thing we've found that makes the emptiness bearable is each other. Contact --1997--""" for i in range(1, 20, 4) : drawPascalsTriangle(i) alphaFrequency(myStr) for i in list([2, 10, 25, 26, 1000, 13]) : encryptStr(myStr, i) # end main( ) if __name__ == "__main__" : main( ) 

Question #1 Using Python's string capabilities, loops, and built-in functions ONLY, write the code for a Python user-defined function that displays 'n' rows of a Pascal's Triangle! NOTE: You may NOT use lists, tuples, or any other Python data structures. Only solutions using strings will be accepted. The function prototype MUST be: def drawPascalsTriangle(n) Each row of a Pascal's Triangle begins with the number 1 and each row contains exactly m numbers (where m is the row number). So that, when m is 1, there is 1 number, when m is 5, there are 5 numbers, etc. After the first number in each row, each subsequent number is derived from the sum of the 2 numbers immediately above it and to the left. After the first number in each row, when determining the value of each subsequent number, if 2 numbers are not available when computing the sum, assume the missing number is 0 and stop processing numbers for that row. So, for example, a Pascal's Triangle with 4 rows would be: 1 1 1 1 2 1 1 3 3 1 So, for example, a Pascal's Triangle with 8 rows would be: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1 1 7 21 35 35 21 7 1 For more information about Pascal's Triangle, visit: https://medium.com/i-math/top-10-secrets-of-pascals-triangle-6012ba9c5e23

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions