Question

In: Computer Science

#python #code #AP class #Tech write a function code script which will print out number pyramid...

#python #code #AP class #Tech

write a function code script which will print out number pyramid in the form of * so the output will be made up of **** resting on top of each other to form a pyramid shape. Bottom layer should be made of 5 multiplication signs like ***** then next 4 multiplication signs and so on. Top part should have only one *

Solutions

Expert Solution

Ans:-

Code:-

#Pyramid Function to draw the Pyramid pattern
def Pyramid(n):
    #Outer loop it will run for n times to handle all the rows
    for i in range(0,n):
        #inner loop it will run for than i+1 times in order to print * pattern
        #it will handle all the column basically
        for j in range(0,i+1):
            print("*",end="") #it will print * pattern
        print() #it will print new line at the end of each row
Pyramid(5) #call to the Function to draw pattern

Output:-

Screeshot:-


Related Solutions

Write a python code to Design and implement a function with no input parameter which reads...
Write a python code to Design and implement a function with no input parameter which reads a number from input (like 123). Only non-decimal numbers are valid (floating points are not valid). The number entered by the user should not be divisible by 10 and if the user enters a number that is divisible by 10 (like 560), it is considered invalid and the application should keep asking until the user enters a valid input. Once the user enters a...
Python create a function tryhard and print out the dictionary as a string form. For example...
Python create a function tryhard and print out the dictionary as a string form. For example def tryhard(d:dict): #Code here input: d = {'first': {}, 'second': {'1': {'move'}, '0': {'move', 'slow'}}, 'third': {'1': {'stop'}}} output = " first movie: [ ]\n third movie: [('1', ['stop'])]\n second movie: [('0', ['slow', 'move']), ('1', ['move'])]\n"
#python. Explain code script of each part using comments for the reader. The code script must...
#python. Explain code script of each part using comments for the reader. The code script must work without any errors or bugs. Ball moves in a 2D coordinate system beginning from the original point (0,0). The ball can move upwards, downwards, left and right using x and y coordinates. Code must ask the user for the destination (x2, y2) coordinate point by using the input x2 and y2 and the known current location, code can use the euclidean distance formula...
In Python Write a Fibonacci class to calculate next number in the 'Fibonacci' class by the...
In Python Write a Fibonacci class to calculate next number in the 'Fibonacci' class by the 'nxt' method. In this class, the 'val' member is a Fibonacci number. The 'nxt' method will return a 'Fibonacci' object whose value is the next number in Fibonacci series. class Fibonacci (): """A Fibonacci number. >>>a = Fibonacci(): >>>a 0 >>>a.nxt() 1 >>>a.nxt().nxt() 1 >>>a.nxt().nxt().nxt() 2 >>>a.nxt().nxt().nxt().nxt() 3 >>>a.nxt().nxt().nxt().nxt().nxt() 5 >>>a.nxt.nxt().nxt().nxt().nxt().nxt() 8 """ def __init__(self): self.val = 0 def nxt(self): """YOUR SOURCE CODE HERE"""...
Fill in the blanks of this code to print out the numbers 1 through 7. number...
Fill in the blanks of this code to print out the numbers 1 through 7. number = 1 while number ___ 7:     print(number, end=" ")     ___
Important: please use python. Using while loop, write python code to print the times table (from...
Important: please use python. Using while loop, write python code to print the times table (from 0 to 20, incremented by 2) for number 5. Add asterisks (****) so the output looks exactly as shown below.   Please send the code and the output of the program. ****************************************************************** This Program Shows Times Table for Number 5 (from 0 to 20) Incremented by 2 * ****************************************************************** 0 x 5 = 0 2 x 5 = 10 4 x 5 = 20 6...
write code in python and test Conversation with an AI ChatBot Learning Outcomes: Use the print()...
write code in python and test Conversation with an AI ChatBot Learning Outcomes: Use the print() function to output a variety of data Use the input() function to ask for multiple data types Use basic arithmetic operations in a program Use string methods and operations Use if/else if/else statements to determine the flow of the program Comment your code Debug your code Test your code Scenario A new marketing company is launching an Artificial Intelligence (AI) ChatBot for their website...
In this python script find any bugs and errors which would cause the code to crash....
In this python script find any bugs and errors which would cause the code to crash. The code must be re-written correctly. After debugging make a separate list of all the errors you found in the script. contacts_list=[] # global variable, list of contacts_list, one string per contact def pause()     """ pauses program e.g. to view data or message """     input("press enter to continue") def load():     """ populate list with data """          contacts_list.append(('Milo ', '063847489373'))...
Write a python script to solve the 4-queens problem using. The code should allow for random...
Write a python script to solve the 4-queens problem using. The code should allow for random starting, and for placed starting. "The 4-Queens Problem[1] consists in placing four queens on a 4 x 4 chessboard so that no two queens can capture each other. That is, no two queens are allowed to be placed on the same row, the same column or the same diagonal." Display the iterations until the final solution Hill Climbing (your choice of variant)
In python Write the code to ask a user to enter a number in the range...
In python Write the code to ask a user to enter a number in the range of 1-100. Have the code checked to make sure that it is in this range. If it is not, let the user re-enter the number. The user should be able to re-enter numbers until the number is within the correct range.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT