Question: 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( ) The OUTPUT should be EXACTLY as displayed below: 1 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 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 1 8 28 56 70 56 28 8 1 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 1 8 28 56 70 56 28 8 1 1 9 36 84 126 126 84 36 9 1 1 10 45 120 210 252 210 120 45 10 1 1 11 55 165 330 462 462 330 165 55 11 1 1 12 66 220 495 792 924 792 495 220 66 12 1 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 1 8 28 56 70 56 28 8 1 1 9 36 84 126 126 84 36 9 1 1 10 45 120 210 252 210 120 45 10 1 1 11 55 165 330 462 462 330 165 55 11 1 1 12 66 220 495 792 924 792 495 220 66 12 1 1 13 78 286 715 1287 1716 1716 1287 715 286 78 13 1 1 14 91 364 1001 2002 3003 3432 3003 2002 1001 364 91 14 1 1 15 105 455 1365 3003 5005 6435 6435 5005 3003 1365 455 105 15 1 1 16 120 560 1820 4368 8008 11440 12870 11440 8008 4368 1820 560 120 16 1 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-- a = 17 ***************** b = 5 ***** c = 9 ********* d = 3 *** e = 31 ******************************* f = 6 ****** g = 5 ***** h = 11 *********** i = 14 ************** k = 1 * l = 11 *********** m = 5 ***** n = 18 ****************** o = 19 ******************* p = 3 *** r = 13 ************* s = 18 ****************** t = 18 ****************** u = 11 *********** v = 1 * w = 1 * x = 1 * y = 6 ****** Aqw'tg cp kpvgtguvkpi urgekgu, cp kpvgtguvkpi okz. Aqw'tg ecrcdng qh uwej dgcwvkhwn ftgcou cpf uwej jqttkdng pkijvoctgu. Aqw hggn uq nquv, uq ewv qhh, uq cnqpg, qpna aqw'tg pqv. Ugg, kp cnn qwt ugctejkpi, vjg qpna vjkpi yg'xg hqwpf vjcv ocmgu vjg gorvkpguu dgctcdng ku gcej qvjgt. Eqpvcev --1997-- Iye'bo kx sxdobocdsxq czomsoc, kx sxdobocdsxq wsh. Iye'bo mkzklvo yp cemr lokedspev nbokwc kxn cemr rybbslvo xsqrdwkboc. Iye poov cy vycd, cy med ypp, cy kvyxo, yxvi iye'bo xyd. Coo, sx kvv yeb cokbmrsxq, dro yxvi drsxq go'fo pyexn drkd wkuoc dro owzdsxocc lokbklvo sc okmr ydrob. Myxdkmd --1997-- Xnt'qd zm hmsdqdrshmf rodbhdr, zm hmsdqdrshmf lhw. Xnt'qd bzozakd ne rtbg adztshetk cqdzlr zmc rtbg gnqqhakd mhfgslzqdr. Xnt eddk rn knrs, rn bts nee, rn zknmd, nmkx xnt'qd mns. Rdd, hm zkk ntq rdzqbghmf, sgd nmkx sghmf vd'ud entmc sgzs lzjdr sgd dloshmdrr adzqzakd hr dzbg nsgdq. Bnmszbs --1997-- 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-- Kag'dq mz uzfqdqefuzs ebqouqe, mz uzfqdqefuzs yuj. Kag'dq ombmnxq ar egot nqmgfurgx pdqmye mzp egot taddunxq zustfymdqe. Kag rqqx ea xaef, ea ogf arr, ea mxazq, azxk kag'dq zaf. Eqq, uz mxx agd eqmdotuzs, ftq azxk ftuzs iq'hq ragzp ftmf ymwqe ftq qybfuzqee nqmdmnxq ue qmot aftqd. Oazfmof --1997-- Lbh'er na vagrerfgvat fcrpvrf, na vagrerfgvat zvk. Lbh'er pncnoyr bs fhpu ornhgvshy qernzf naq fhpu ubeevoyr avtugznerf. Lbh srry fb ybfg, fb phg bss, fb nybar, bayl lbh'er abg. Frr, va nyy bhe frnepuvat, gur bayl guvat jr'ir sbhaq gung znxrf gur rzcgvarff ornenoyr vf rnpu bgure. Pbagnpg --1997--

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

Question #2 Write a Python user-defined function that accepts a string of any length and first displays the string followed by a horizontal frequency graph of all ALPHABETIC letters only in the string (in alphabetical order). Case of letters, spaces, and all non-alphabetic characters are to be ignored! The function prototype MUST be: def alphaFrequency(userString) For example, the function call: alphaFrequency("This is a Python test 123!") would display: This is a Python test 123! a=1 * e=1 * h=2 ** i=2 ** n=1 * o=1 * p=1 * s=3 *** t=4 **** y=1 * HINT: Consider using Python's upper( ), lower( ), and ord( ) functions and string.ascii_lowercase and string.ascii_uppercase to complete your solution.

Question #3 Write a Python user-defined function that accepts a string and a number 'n' representing a shift index and encrypts the string by substituting (ciphering) each alphabetic letter only with a letter found by moving n places down the alphabet (wrapping around to the beginning when required). The function prototype MUST be: def encryptStr(userString, n) For example, if the string was: "abc-xyz", and the shift value was: 3, then the function call: encryptStr("abc-xyz", 3) would display and return the encrypted string: "def-abc"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!