Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q1. Write a Python function with the following prototype: def drawTriangle(rows) This function accepts a number from 1 to 10 inclusive and draws a number
Q1. Write a Python function with the following prototype: def drawTriangle(rows) This function accepts a number from 1 to 10 inclusive and draws a number pyramid with the first row starting at . Subsequent rows contain 2 more numbers than the previous row such that the middle number in each row increases by 1. Also, each row begins with @ and increases by 1 for each column until the middle number is reached at which point, the numbers decrease until they end with e. 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: 010 01210 # For example, when rows = 10 the pyramid looks like: 0 010 01210 0123210 012343210 01234543210 0123456543210 012345676543210 01234567876543210 0123456789876543210 NOTE: Consider using string.digits, string slices [:], string repetition operator *, and the join() function to accomplish your solution. Q2. Write a Python function with the following prototype: def threeLetterCombinations (letter) This function generates and displays a list of all 3 lowercase letter combinations in the alphabet from 'a' to letter. For example, if letter == 'b', then this function would display aaa aab aba abb baa bab bba bbb HINT: Consider using a triple nested loop and the ord() and chr() functions. 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 to 9. For each number that is determined to be a narcissistic number, it is displayed as output followed by a new line. So, for example, the number 153 is an narcissistic number because 1^3 + 5^3 + 3^3 = 153 For example, the number 1634 is a narcissistic number because 1^4 + 6^4 + 3^4 + 4^4 = 1634 HINT: Consider using python's exponent the len() function. operator, the // operator and
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