LAB: Warm up: Drawing a right triangle This program will output a right triangle based on user specified height triangle_height and symbol triangle_char. (1) The given program outputs a fixed-height triangle using a character. Modify the given program to output a right triangle that instead uses the user-specified triangle_char character. (1 pt) (2) Modify the program to use a loop to output a right triangle of height triangle_height. The first line will have one user-specified character, such as % or* Each subsequent line will have one additional user-specified character until the number in the triangle's base reaches triangle_height. Output a space after each user-specified character, including a line's last user-specified character. (2 pts) Example output for triangle_char = % and triangle_height = 5: Enter a character: Enter triangle height: 5 273334.1408726 LAB ACTIVITY 16.6.1: LAB: Warm up: Drawing a right triangle 0/3 main.py Load default template... 1 triangle_char - input('Enter a character:\n') 2 triangle_height = int(input('Enter triangle height:\n')) 3 print('') 4 5 print ('*') 6 print ("**') 7 print ("***') 8

Answers

Answer 1

Answer:

The modified program in Python is as follows:

triangle_char = input('Enter a character:\n')

triangle_height = int(input('Enter triangle height:\n'))  

for i in range(triangle_height):

   print(triangle_char * (i+1))

Explanation:

This gets the character from the user

triangle_char = input('Enter a character:\n')

This gets the height of the triangle from the user

triangle_height = int(input('Enter triangle height:\n'))  

This iterates through the height

for i in range(triangle_height):

This prints extra characters up to the height of the triangle

   print(triangle_char * (i+1))

Answer 2

Here's the modified program that incorporates the requested changes:

python

Copy code

triangle_char = input('Enter a character:\n')

triangle_height = int(input('Enter triangle height:\n'))

print('')

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

   line = triangle_char * i + ' ' * (triangle_height - i)

   print(line)

This program uses a loop to iterate from 1 to triangle_height. In each iteration, it creates a line by concatenating triangle_char repeated i times with spaces (' ') repeated (triangle_height - i) times. The resulting line is then printed.

For example, if the user enters % as the character and 5 as the height, the output will be to make sure to maintain the indentation properly in your code for it to work correctly.

Learn more about python on:

https://brainly.com/question/30391554

#SPJ6


Related Questions

what are the different steps while solving a problem using computer? explain​

Answers

Explanation:

The following six steps must be followed to solve a problem using computer.

Problem Analysis.

Program Design - Algorithm, Flowchart and Pseudocode.

Coding.

Compilation and Execution.

Debugging and Testing.

Program Documentation.

The following method is intended to return true if and only if the parameter val is a multiple of 4 but is not a multiple of 100 unless it is also a multiple of 400. The method does not always work correctly public boolean isLeapYear(int val) if ((val 4) == 0) return true; else return (val & 400) == 0; Which of the following method calls will return an incorrect response?
A .isLeapYear (1900)
B. isLeapYear (1984)
C. isLeapYear (2000)
D. isLeapYear (2001)
E. isLeapYear (2010)

Answers

Answer:

.isLeapYear (1900) will return an incorrect response

Explanation:

Given

The above method

Required

Which method call will give an incorrect response

(a) will return an incorrect response because 1900 is not a leap year.

When a year is divisible by 4, there are further checks to do before such year can be confirmed to be a leap year or not.

Since the method only checks for divisibility of 4, then it will return an incorrect response for years (e.g. 1900) that will pass the first check but will eventually fail further checks.

Hence, (a) answers the question;

(CO 4 and 5) Create a program that will read in a list of test scores from the user and add them to a list. Ask the user in between each score if they want to continue (y/n). Display all of the scores entered and the total score at the end. Using the code below, put the code in the proper order Sample output: Welcome to the Test Score Program Add score: 88.45 Do you want to continue

Answers

Answer and Explanation:

Using Javascript:

function AddScores(){

Window.alert("Welcome to the Test Score Program");

var ScoreList= new Array();

ScoreList.push(Prompt("Add Score"));

var WhatNext= Confirm("do you want to continue?");

If(WhatNext===true) {

do{

ScoreList.push(Prompt("Add Score"));

}

While(

Confirm("do you want to continue?")===true;);

}

Alert(ScoreList);

Alert(ScoreList.reduce(function(a,b){return a +b};,0);)

}

AddScores();

From the above code in javascript programming language, we have created a list ScoreList and added elements to it using push method of the array object and a do...while loop that checks the condition and then adds the user's input to the array. We then alerted the array to the screen and then summed up the array elements and also alerted to the screen.

Which XXX declares a student's name. public class Student { XXX private double myGPA; private int myID; public int getID() { return myID; } } Group of answer choices String myName; public String myName; private myName; private String myName;

Answers

Question:

Which XXX declares a student's name.

public class Student {

   XXX

   private double myGPA;  

   private int myID;

   public int getID() {

        return myID;

   }

}

Group of answer choices

a. String myName;

b. public String myName;

c. private myName;

d. private String myName;

Answer:

private String myName;

Explanation:

To declare a student's name, the following should be noted.

i. The name of the student is of type String

ii. Since all of the instance variables (myGPA and myID) have a private access modifier, then myName (which is the variable name used to declare the student's name) should be no exception. In other words, the student's name should also have a private access.

Therefore, XXX which declares a student's name should be written as

private String myName;

Option (a) would have been a correct option if it had the private keyword

Option (b) is not the correct option because it has a public access rather than a private access.

Option (c) is not a valid syntax since, although it has a private access, the data type of the variable myName is not specified.

Option (d) is the correct option.

You would like to upgrade the processor in your system to a 64-bit processor. Which of the components will you most likely need to upgrade as well to take full advantage of the new processor

Answers

Answer: Operating system

Explanation:

The components that will be required to upgrade as well to take full advantage of the new processor is the Operating system.

The operating system manages the software resources and the computer hardware, through the provision of common services for the computer programs. It simply supports the basic function of the computer like task scheduling

Other Questions
roatate triangle p 90* clockwise about the point (2,-1) Diferencias entre lo ocurrido el 16 de junio de 1955 con el Proceso de reorganizacin Nacional de 1976-1983 Here are selected 2017 transactions of Akron Corporation.Jan. 1 Retired a piece of machinery that was purchased on January 1, 2007. The machine cost $62,000 and had a useful life of 10 years with no salvage valueJune 30 Sold a computer that was purchased on January 1, 2015. The computer cost $36,000 and had a useful life of 3 years with no salvage value. The computer was sold for $5,000 cashDec. 31 Sold a delivery truck for $9,000 cash. The truck cost $25,000 when it was purchased on January 1, 2014, and was depreciated based on a 5-year useful life with a $4,000 salvage value.Required:Journalize all entries required on the above dates, including entries to update depreciation on assets disposed of, where applicable. Akron Corporation uses straight-line depreciation. Which of the following best describes who, according to Roosevelt, is entitled to these four things?Every family in AmericaEvery taxpayerEveryone in AmericaEveryone in the world A hockey puck is sliding across the ice with an initial velocity of 25 m/s. If the coefficient of friction between the hockey puck and the ice is 0.08, how much time (in seconds) will it take before the hockey puck slides to a stop What are the CONS of cultural preservation on the regional development of a country One major effect of the Hundred Years War was If students would like to be part of the class play, How do you do this ? Which relationship has a zero slope? Change into nagativeMohan does his homework What are lacteals? a. Gastric secretory cells b. Products of milk digestion c. Intestinal lymphatic vessels d. Products of colonic fermentation How to Cancel prescription MATH HELP PLEASE HELP By what percent will a fraction change if its numerator is decreased by 60% and its denominator is decreased by 20%? THANK YOU SO MUCH TO WHOEVER ANSWERS IT I HAVE VERY LITTLE TIME! What stage of photosynthesis usescarbon dioxide to make glucose?A. Light reactionsB. Calvin CycleC. ATP synthesisD Cellular respiration Deforestation occurs when large Amounts of trees are cut down and not replaced which of the following would result from deforestation A. Decrease carbon in the atmosphere B. Increased carbon in the atmosphere resumen del cuento "el rey hombre" Will give brainlist!! the equation of a circle C is (x+2)^2+(y-7)^2=36. What is its crnter (h,k)?