Write a program that asks the user to enter the size of a triangle (an integer from 1 to 50). Display the triangle by writing lines of asterisks. The first line will have one asterisk, the next two, and so on, with each line having one more asterisk than the previous line, up to the number entered by the user. On the next line write one fewer asterisk and continue by decreasing the number of asterisks by 1 for each successive line until only one asterisk is displayed. (Hint: Use nested for loops; the outside loop controls the number of lines to write, and the inside loop controls the number of asterisks to display on a line.) For example, if the user enters 3, the output would be:_______.a. *b. **c. ***d. **e. *

Answers

Answer 1

Answer:

Implemented using Python

n = int(input("Sides: "))

if(n>=1 and n <=50):

    for i in range(1,n+1):

         for j in range(1,i+1):

              print('*',end='')

         print("")

       

    for i in range(n,0,-1):

         for j in range(i,1,-1):

              print('*',end='')

         print("")

else:

         print("Range must be within 1 and 50")

Explanation:

This line prompts user for number of sides

n = int(input("Sides: "))

The line validates user input for 1 to 50

if(n>=1 and n <=50):

The following iteration uses nested loop to print * in ascending order

   for i in range(1,n+1):

         for j in range(1,i+1):

              print('*',end='')

         print("")

The following iteration uses nested loop to print * in descending order        

    for i in range(n,0,-1):

         for j in range(i,1,-1):

              print('*',end='')

         print("")

The following is executed if user input is outside 1 and 50

else:

         print("Range must be within 1 and 50")


Related Questions

Xcode, Swift, and Appy Pie are all tools for doing what?

writing code in C#

creating smartphone apps

creating apps to run on a desktop or laptop

writing code in Java

Answers

Answer:

creating smartphone apps

Explanation:

Xcode, Swift, and Appy Pie are all tools for creating iOS applications.

These tools are used for app development in the iOS platform which is a rival to the Android platform.

They are used to build the apps from scratch, develop and test them,

Answer:

smart phone apps

Explanation:

1. Discuss data processing concepts and the representation of data in the computer


2. Explain how they work together to process data

Answers

Answer:

gkvjbdsvjnmfbhui jgbfdshjcxvabgsuciusgBFIULWGSfuRyt vqwyrgfgweVGYGTV7BWUIEGDWYUGDCYg

Explanation:

The European Union requires companies to:

a
erase user data when requested.
b
keep all data open source.
c
never sell data.
d
delete all personal customer data after two years.

Answers

Answer:

C is the correct

Explanation:

When viewing the Mail Merge Recipients dialog box, what kinds of actions can you perform? Check all that apply. find recipient filter recipients print recipients sort column headings select/deselect recipients

Answers

Answer:

a,b,d,e on edg 2020

Explanation:

Answer:

Everything is correct except option 3/letter C.

Explanation:

A, B, D, and E

Mrs Jones had p hens then she decided to buy p more hens. how many hens does she have in all?​

Answers

Answer:

2p

Explanation:

if she had p, then she got p again, she got two p amounts. p+p = p*2 = 2p

THIS IS PYTHON QUESTION
d = math.sqrt(math.pow(player.xcor() - goal.xcor(), 2) + math.pow(player.ycor()-goal.ycor(), 2))

here is the error message that I am getting when I run this using the math module in python: TypeError: type object argument after * must be an iterable, not int

Answers

Answer:

ok

Explanation:yes

what is the output? there are no answer options and I'm completely lost.

>>>answer = "five times"

>>>answer[2:7] ​

Answers

The string answer = "five times"

All strings start at index 0 and end at the length of the string minus 1

So, if we count appropriately, index 2 is v and index 7 is m

answer[2:7] goes from v to m including v but not m, therefore,

answer[2:7] = "ve ti"

1) An employer has decided to award a weekly pay raise to all employees by taking the square root of the difference between his weight and the employee’s weight. For instance, an employee who weighs 16 pounds less than the employer will get a $4 per week raise. The raise should be in whole dollars (an int). Write a class file that prompts the user for the employee and the employer weight. Please output the correct raise amount making sure that all inputs are included in the output statement.

Answers

Answer:

Written in C++

#include <iostream>

#include<cmath>

using namespace std;

int main(){

   int weight1, weight2, diff;

   cout<<"Employees Weight: ";

   cin>>weight1;

   cout<<"Employers Weight: ";

   cin>>weight2;

   diff = abs(weight1 - weight2);

   float pay = round(sqrt(diff));

   cout<<pay;

   return 0;

}

Explanation:

I've added the source file as an attachment where I used comments as explanation

Explain the following terms as used in word processin
(a)
Drop cap
(b) A superscript
An indent​

Answers

Answer:

A drop cap (dropped capital) is a large capital letter used as a decorative element at the beginning of a paragraph or section. The size of a drop cap is usually two or more lines.

a superscript is a character(s) half the height of a standard character and printed higher than the rest of the text.

In word processing, the word indent is used to describe the distance, or number of blank spaces used to separate a paragraph from the left or right margins.

Other Questions
What are your responsibilities as the owner of a vehicle? 12. The perimeter of a rectangle is 50 feet. The width is 5 less than thelength. What are the dimensions of the rectangle? (Write your answer asLength, Width) What is the rate of change of the following equation? 2y + x = -2 What definition can be formed about a word analogy?A) A word analogy can compare words that have similar relationships to each other.B) A word analogy can compare words that have unlike relationships to each other.C) A word analogy can compare words that have different relationships to each other.D) A word analogy can contrast words that have different relationships to each other. The cost of a DVD box set increased from $30 to $35. A student says that this represents a 5% increase in the price. Explain the students error. What is the actual percent increase? Literacy levels were highest in the Southern Colonies. TRue or False Find the value of x in the following ratio 3:15=x:30b) x :9 =4=36 what is the absolute of the integer of 6 How many 1/8's are in 1/2 inch?A.8.B6c4D3 Which of the following statements best explains a forests role in maintaining our atmosphere?A.Trees absorb oxygen from the atmosphere and release carbon dioxide.B.Trees soak up the moisture in the air, making the climate much drier.C.Trees reflect sunlight back into atmosphere, keeping temperatures from getting too hot.D.Trees absorb carbon dioxide from the atmosphere and give off oxygen. help please this is timed Para cuando .... necessita? Yo necessito para manana en l noche Question in the picture simplify.show work(39-3)-10thanks please show work Help with this history (HW) suppose y varies directly as x. If y = 30 when x = 8, find y when x = 4 You are starting a new homebuilding business and are responsible for choosing a location to go to your first subdivision. Do you want to choose a place for all different types of people will want to live in work. In which ecosystem would you choose to build? And why? HELP PLZ RN which of these schools are the best. 1) Moravian College in Bethlehem PA. 2) Calvin College. 3) School of Psychology at the University of Queensland in Australia? thx What is an equation of the line that passes through the points (4, -1) and(-8, 7)? Put your answer in fully reduced form.