I need help creating a symmetric histogram. The program should ask the user to enter the number of bars to print and the character to use to draw the bars. The count of characters in the bar needs to be displayed on the right-side of each bar. You must use a nested loop to display the output.

I Need Help Creating A Symmetric Histogram. The Program Should Ask The User To Enter The Number Of Bars

Answers

Answer 1

Answer:

The program in Python is as follows:

import math

bars = int(input("Bars: "))

symbol = input("Character: ")

current = 1

while current < bars * 2:

   if current <= bars:

       num = current

       for i in range(num):

           print(symbol,end="")

       print(current)

   else:

       num = abs(bars * 2 - current);

       for i in range(num):

           print(symbol,end="")

       print(i+1)

   current+=1

   

Explanation:

This imports the math module

import math

This gets input for the number of bars

bars = int(input("Bars: "))

This gets input for the number of characters

symbol = input("Character: ")

This sets the current element to 1

current = 1

The following iteration is repeated until printing ends

while current < bars * 2:

The following checks for printing in ascending order

   if current <= bars:

       num = current

The following loop prints the characters in ascending order

       for i in range(num):

           print(symbol,end="")

This prints the number of characters

       print(current)

The following checks for printing in descending order

   else:

Calculate the number of iteration left

       num = abs(bars * 2 - current);

The following loop prints the characters in descending order

       for i in range(num):

           print(symbol,end="")

This prints the number of characters

       print(i+1)

   current+=1

 


Related Questions

How is Ms word more suitable and easier for document designing?

Answers

Answer:

MS Word is a word processing application, that built with an excellent array of features that permit the editing of text documents, with fonts, margins, borders, and page layout properties. Tables, charts, word art, shapes and pictures can be easily added to enhance the appearance and professional look of documents, as well as being able to publish documents in Portable Document Format, PDF and other file formats

Using MS Word, users an create write contract documents, resume, write-ups, fliers, invitation cards, projects, and reports from several customizable templates available in the Online Templates option of creating New Documents

The application provides support and upgrade to users that enable them make the most use of their time by having the required text document creation features in one application

Explanation:

Other Questions
a. In which age people started to live permanently and concept of society was developed? Choose the correct correspondence A rocket travels vertically at a speed of 1200 km/h. The rocket is tracked through a telescope by an observer located 16km from the launching pad. Find the rate at which the angle between the telescope and the ground is increasing 3 min after lift-off. Round your answer to the nearest hundredth rad/hr What is system software?No SpamAnswer quickly Choose the correct statements about the ROC curve.A. By plotting the true-positive rate against the false-positive rate for different threshold values, the ROC curve can be used to select the optimal model.B. ROC stands for Receiver Operating Characteristic curve, which was originally developed to detect enemy aircrafts on radar.C. The ROC curve is a useful diagnostic tool for determining the optimal classification model.D. The ROC curve was originally developed to optimize healthcare and detect congestive heart failure readmission rate. Lena is asked to write an explicit formula for the graphed geometric sequence.On a coordinate plane, 3 points are plotted. The points are (1, 1), (2, 2.5), (3, 6.25).What value, written as a decimal, should Lena use as the common ratio A student was given a 2.850-g sample of a mixture of potassium nitrate and potassium bromide and was asked to find the percentage of each compound in the mixture. She dissolved the sample and added a solution that contained an excess of silver nitrate, AgNO3. The silver ion precipitated all of the bromide ion in the mixture as AgBr. It was filtered, dried, and weighed. Its mass was 1.740 g. What was the percentage of each compound in the mixture A silo is built in the shape of a cylinder with a cone for a roof. If the height of thecylinder is 5 m, the radius is 2.8 m and the slant height of the cone is 6,6 m,determine the amount of material needed to create the rounded sides and conicalroof, Round to the nearest tenth of a cubic m. Define population educstion. State any four purpose of including it in school education. 1000 randomly selected Americans were asked if they believed the minimumwage should be raised. 600 said "yes." What is the 99% confidence intervalfor the proportion of Americans who believe that the minimum wage shouldbe raised? Read the scenario.What type of method was used by the traffickers torecruit the girl?A young girl from Ukraine reads an advertisement in alocal newspaper about modeling jobs in Hollywood. Shecalls the number and they tell her that many of theirmodels have gone on to work in movies and TV shows inthe United States. When she arrives at the airport, theypick her up and take her to an apartment. There, they takeher passport and tell her that she must sell sex servicesand give them the money to pay back the cost of herairplane ticket.O offer of educationO payment for smugglingO offer of workfalse love interest Hillyard Company, an office supplies specialty store, prepares its master budget on a quarterly basis. The following data have been assembled to assist in preparing the master budget for the first quarter:a. As of December 31 (the end of the prior quarter), the company's general ledger showed the following account balances:Cash 42,000 Accounts receivable 201,600 Inventory 58,050 Buildings and equipment (net) 352,000 Accounts payable 85,725Common stock 500,000Retained earnings 67,925 653,650 653,650b. Actual sales for December and budgeted sales for the next four months are as follows:December (actual) 252,000January 387,000February 584,000March 298,000April 195,000c. Sales are 20% for cash and 80% on credit. All payments on credit sales are collected in the month following sale. The accounts receivable at December 31 are a result of December credit sales. d. The company's gross margin is 40% of sales. (In other words, cost of goods sold is 60% of sales.)e. Monthly expenses are budgeted as follows: salaries and wages, $17,000 per month; advertising, $57,000 per month; shipping, 5% of sales; other expenses, 3% of sales. Depreciation, including depreciation on new assets acquired during the quarter, will be $42,420 for the quarter.f. Each month's ending inventory should equal 25% of the following month's cost of goods sold.g. One-half of a month's inventory purchases is paid for in the month of purchase; the other half is paid in the following month.h. During February, the company will purchase a new copy machine for $1,200 cash. During March, other equipment will be purchased for cash at a cost of $71,000.i. During January, the company will declare and pay $45,000 in cash dividends.j. Management wants to maintain a minimum cash balance of $30,000. The company has an agreement with a local bank that allows the company to borrow in increments of $1,000 at the beginning of each month. The interest rate on these loans is 1% per month and for simplicity we will assume that interest is not compounded. The company would, as far as it is able, repay the loan plus accumulated interest at the end of the quarter.RequiredUsing the data above, complete the following statements and schedules for the first quarter:1. Schedule of expeted cash collections:Hillyard Company Schedule of Expected Cash Collections January February March QuarterCash sales 77,400 77,400Credit sales 201,600 201,600Total collections 279,000 279,0002-a. Merchandise purchases budget:Hillyard Company Merchandise Purchases Budget January February March QuarterBudgeted cost of goods sold 232,200* 350,400 Add desired ending inventory 87,600 Total needs 319,800 350,400 Less beginning inventory 58,050 Required purchases 261,750 *$387,000 sales x 60% cost ratio = $232,200.$350,400 25% = $87,600.2-b. Schedule of expected cash disbursements for merchandise purchases:Hillyard Company Schedule of Expected Cash Disbursements for Merchandise Purchases January February March QuarterDecember purchases 85,725 January purchases 130,875 130,875 February purchases March purchases Total cash disbursements for purchases 3. Cash budget. (Cash deficiency, repayments and interest should be indicated by a minus sign.)Hillyard Company Cash Budget January February March Quarter Beginning cash balance 42,000 Add cash collections 279,000 Total cash available 321,000 Less cash disbursements: Purchases of inventory 216,600 Selling and administrative expenses 104,960 Purchases of equipment Cash dividends 45,000 Total cash disbursements 366,560 Excess (deficiency) of cash (45,560) Financing: Borrowings Repayments Interest Total financing Ending cash balance 4. Prepare an absorption costing income statement for the quarter ending March 31.Hillyard Company Income Statement For the Quarter Ended March 31Cost of goods sold Selling and administrative expenses: 5. Prepare a balance sheet as of March 31.Hillyard Company Balance Sheet March 31Assets Current assets: Total current assets Total assets Liabilities and Stocholders' Equity Current liabilities Stockholders' equity Total liabilities and stockholders' equity In one of the examples he is working on, he knows that the two coordinates (0,6) and(8, 10) are on the function that he is deriving. Using the information from these twocoordinates, determine the slope and y-intercept of the function Mike is looking for, andthen write out the correct function. . A radio station transmitting at a frequency of 200KH, emits waves of wavelength 1.5 km.the velocity of the radio waves is Question down below thank you PLEASE SOMEONE ANSWER THIS ASAP!!!Given the geometric sequence with the first three terms shown below, answer the following questions.4,-8, 16,...Write the explicit formula for this sequence.What is the 12th term of the sequence?PLEASE ANSWER I HAVE AN IMAGE INCLUDED IF NEEDED !! Gomez argues that we need to increase the nation's output. Chang contends that our top priority should be a more equal distribution of income and output. It can be correctly stated that these two goals are:A. essentially unrelated.B. complementary because the realization of one will promote fulfillment of the other.C. at least partially competing because the redistribution of income might impair incentives to work and produce.D. complementary because a more equal distribution of income always promotes economic growth. What is one condition that must be met for a population to be in genetic equilibrium? What is the capacitive resistance of a 0.04 microfarad capacitor in a AC circuit that has a frequency of 1,000 hertz? A car travels initially at 24 m/s, until it enters the highway. If the car accelerates at 4 m/s^2 for a 96 meters, what is the car's new velocity?