Question

Parallelogram Program

Write a program that prints the following parallelogram pattern given the the following two inputs.

Example 1 This program will output a parallelogram. How long do you want each side to be? 5 Please enter the character you wa

Here are the rules:

  • Your program must work with any length greater than 1.
  • Your program must use the character the user inputs to draw the parallelogram.
  • Your program must not use global variables or global code other than a call to main().Full Screen 1- def print_parallelogram(long, char): # dont change this line 2 # put your solution here 3 4- def main(): 5 #
  • Your program output must match my out exactly. I have provided you with the strings you need for the output matching.
  • Hint: I recommend you think of this as a program to output two triangles, one above the other (the longest horizontal line is the border between the triangles).
0 0
Add a comment Improve this question Transcribed image text
Answer #1
def pring_parallelogram(long, char):
    print("Parallelogram:")
    for i in range(1, long+1):
        print(char*i)
    symbols = long - 1
    for i in range(1, long):
        print((" "*i) + char*symbols)
        symbols = symbols - 1
    
    
def main():
    print("This program will output a parallelogram.")
    l = int(input("How long do you want each side to be?\n"))
    c = input("Please enter the character you want it to be made of:\n")
    pring_parallelogram(l,c)

main()

please up vote

Add a comment
Know the answer?
Add Answer to:
Parallelogram Program Write a program that prints the following parallelogram pattern given the the following two...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Write a program that asks for a number and then prints as many lines as...

    C++ Write a program that asks for a number and then prints as many lines as the user inputs. Each line contains as many pairs of characters ("*#") as the number of this line. It should look like the right half of a pyramid. Your version of the program must print the same result as the expected output. To to this lab, you must use two do-while loops. Two exceptions: When the user inputs a number less than 1, then...

  • Using Python Please Question 1: Pine Tree Write a program that, prints a 'pine tree' consisting...

    Using Python Please Question 1: Pine Tree Write a program that, prints a 'pine tree' consisting of triangles of increasing sizes, filled with a character (' oror '$' etc). Your program should consist of three functions: 1. A function print_shifted_triangle (n, m, symbol). It prints an n-line triangle, filled with symbol characters, shifted m spaces from the left margin. For example, if we call print_shifted_triangle (3, 4, +"), the expected output is: +++ Left margin +++++ 4 spaces 2. A...

  • C++ Write A Program: //Please DONT use stdio.h or fancy things like classes Given the following...

    C++ Write A Program: //Please DONT use stdio.h or fancy things like classes Given the following header: vector<string> split(string target, string delimiter); implement the function split so that it returns a vector of the strings in target that are separated by the string delimiter. For example: split("10,20,30", ",") should return a vector with the strings "10", "20", and "30". Similarly, split("do re mi fa so la ti do", " ") should return a vector with the strings "do", "re", "mi",...

  • Write a Program that has a menu with a  layout below, that asks the user if they...

    Write a Program that has a menu with a  layout below, that asks the user if they want to: 1. Converts from feet and inches to meter and centimeters 2. Converts from meter and centimeters to feet and inches 3. Quit the program The program should continue as long as the user asks it to. The program will use a switch statement for the menu option selection. Either a do loo or a do-while loop can be used for the overall...

  • 5. (30 pts) Write a program that calculates the surface area of a cube (see the...

    5. (30 pts) Write a program that calculates the surface area of a cube (see the formula below). The user inputs the cube's side length and your program will then print out the surface area of that cube. Your code must follow the output in the sample run below. Your program must be complete and correct, but you do not need to include comments. Here is the formula to calculate surface area given a cube's side length: surface area 6...

  • Using Python Write a program that reads an int N >= 0, then prints out each...

    Using Python Write a program that reads an int N >= 0, then prints out each of the following patterns of *. Here, you may use the * repetition operator, if you wish. Also, each pattern must be output via a single function call to the given named function with single parameter N. Examples for N==4 follow, with explanations of how the displayed diagram reflects this value of N: ) Square with number diagonals, with outer side length of N,...

  • Python program Use the provided shift function to create a caesar cipher program. Your program s...

    python program Use the provided shift function to create a caesar cipher program. Your program should have a menu to offer the following options: Read a file as current message Save current message Type in a new message Display current message "Encrypt" message Change the shift value For more details, see the comments in the provided code. NO GLOBAL VARIABLES! Complete the program found in assignment.py. You may not change any provided code. You may only complete the sections labeled:#YOUR...

  • Can anyone please solve this for me in java. Thanks Complete the program below that prints...

    Can anyone please solve this for me in java. Thanks Complete the program below that prints a square. The program will read the size (an integer value) of the square and a character. It will then generate a square with a number of rows and columns that corresponds to size, and where the * character is used for the square border. The provided character will be used for the rest of the diagram. Use the message “Enter size:” and “Enter...

  • Program must be in Python 3. Write a program that prompts the user to enter two...

    Program must be in Python 3. Write a program that prompts the user to enter two strings and then displays a message indicating whether or not the first string starts with the second string. Your program must satisfy the following requirements. 1. Your program must include a function called myStartsWith that takes two string parameters. This function returns True if the rst string starts with the second string and returns False otherwise. 2. Your program must include a main function...

  • Write a C program that does the following: • Displays a menu (similar to what you...

    Write a C program that does the following: • Displays a menu (similar to what you see in a Bank ATM machine) that prompts the user to enter a single character S or D or Q and then prints a shape of Square, Diamond (with selected height and selected symbol), or Quits if user entered Q. Apart from these 2 other shapes, add a new shape of your choice for any related character. • Program then prompts the user to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT