Answered step by step
Verified Expert Solution
Question
1 Approved Answer
SPECIFICATIONS: Q1. Write a Python function with the following prototype: def drawPyramid(rows) This function accepts a number from 1 to 26 inclusive and draws a
SPECIFICATIONS: Q1. Write a Python function with the following prototype: def drawPyramid(rows) This function accepts a number from 1 to 26 inclusive and draws a letter pyramid with the first row starting with the character 'a'. Subsequent rows contain 2 more characters than the previous row such that the middle character in each row increases by 1. Also, each row begins with the letter 'a' and increases by 1 for each column until the middle character is reached at which point, the characters decrease until they end with the character 'a'. Also, each row displays spaces so that the pyramid appears as an isoscelles triangle. The first row will contain row - 1 spaces, the second row will contain row - 2 spaces, etc. \# For example, when rows =3 the pyramid looks like: a aba abcba \# For example, when rows =10 the pyramid looks like: a aba abcba abcdcba abcdedcba abcdefedcba abcdefgfedcba abcdefghgfedcba abcdefghihgfedcba abcdefghijihgfedcba NOTE: Consider using string.ascii_lowercase, string slices [ : ], string repetition operator *, and the join( ) function to accomplish your solution. Q2. Write a Python function with the following prototype: def threeNumberCombinations(num) This function generates and displays a list of all 3 number combinations from 1 to num in numerical order. For example, if num ==3 ', then this function would display 111 112 113 121 122 123 131 132 133 211 212 213 221 222 223 231 232 233 311 312 313 321 322 323 331 332 333 Q3. Write a Python function with the following prototype: def allNarcissisticNumbers(limit) This function displays all numbers from 1 to limit inclusive that are narcissistic numbers! A number is a narcissistic number if the sum of each of its individual digits raised to the exponent of the total number of digits in the number equals the value of the number itself, but excludes single digit numbers 0 to 9 . For each number that is determined to be a narcissistic number, it is display as output followed by a new line. So, for example, the number 153 is a narcissistic number because 13+53+33=153 For example, the number 1634 is a narcissistic number because 14+64+34+44=1634 HINT : Consider using python's exponent ** operator, the // operator and the len( ) function. import math import random import string import collections import datetime import re import time import copy def drawPyramid(rows): \# your code here... def threeNumberCombinations(num): \# your code here... \#end def \# allNarcissisticNumbers(1imit) : \# your code here... def main( ) : drawPyramid(5) drawPyramid( 3 ) threeNumberCombinations(3) drawPyramid(10) drawPyramid(26) threeNumberCombinations(2) allNarcissisticNumbers(100000) \# there should be 10 narcissistic numbers main( ) \# The OUTPUT should be EXACTLY as displayed below: a aba abcba abcdcba abcdedcba a aba abcba 111 112 113 121 122 123 131 132 133 211 212 213 221 222 223 231 232 233 311 312 313 321 322 323 331 332 333
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started