1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Vedmedyk [2.9K]
3 years ago
10

3.17 (LAB) Ch 5 Warm up: Drawing a right triangle (Python 3) This program will output a right triangle based on user specified h

eight 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 % % % % % % % % % % % % % % %
Computers and Technology
1 answer:
andre [41]3 years ago
3 0

Answer:

Find answers below

Explanation:

triangle_char = input('Enter a character: ')

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

print('')

for j in range (triangle_height):

   print((triangle_char) * (j + 1))

#below are sample output that can be gotten with predefined values

$ ./triangles.py  

Enter characters: jk

Enter height: 8

j

jj

jjj

jjjj

jjjjj

jjjjjj

jjjjjjj

jjjjjjjj

k

kk

kkk

kkkk

kkkkk

kkkkkk

kkkkkkk

kkkkkkkk

You might be interested in
Shelly recorded an audio composition for her presentation. Arrange the following steps that Shelly followed in the proper order.
Dimas [21]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

Shelly recorded an audio composition for her presentation. She needs to follow the following proper orders to get composition done for her presentation.

  1. She connected her microphone to her computer.
  2. She selected the record option in her DAW.
  3. She added effects to her audio composition.
  4. She saved the audio composition in an appropriate file format.
  5. She saved her audio composition on an optical drive.
3 0
3 years ago
Write a new method in the Rectangle class to test if a Point falls within the rectangle. For this exercise, assume that a rectan
algol [13]

Answer:

Explanation:

The Rectangle and Point class is not provided in this question but was found online. Using that code as guidance I created the following method named contains. This method takes in a Point object and checks to see if the x-axis point is inside the parameters of the Rectangle class and then checks the same for the y-axis. If it is inside the Rectangle then the method returns true otherwise it returns false.

def contains(self, point):

       return self.width > point.x >= self.corner.x and self.height > point.y >= self.corner.y

7 0
3 years ago
Write a Python program to replace at most 2 occurrences of space, comma, or dot with a colon. Hint: use re.sub(regex, "newtext",
charle [14.2K]

Explanation:

The "re" module in python provides various functions to perform complex string operations easily.

For example, you can check whether a specific word exists in a given string or to replace it with some other word.  

Some of the functions in the re module are:

re.findall

re.search

re.sub()

We are particularly interested in the re.sub() function, we can use this function to replace the occurrences of space, coma or dot with semicolon.  

Syntax:

re.sub(pattern, replace, target_string, n).  

Where pattern = space, coma or dot  

replace = semicolon  

target_string = any string containing spaces, coma and dots

n = number of times you want the replacement to be done  

Code:

import re  

target_string = "Hello world,code,code."  

replace = ":"

pattern = "[ ,.]"

print(target_string)

print(re.sub(pattern, replace, target_string, 2) )

Output:

Hello world,code,code.

Hello:world:code,code.

It replaced the first white space and coma with semicolon, if we increase the n to 4 then the output is

Hello:world:code:code:

As expected, it replaced all of the space, coma, and dots with semicolons.

7 0
4 years ago
The scientific process is most similar to what
Papessa [141]

Answer:

A dyagram

Explanation:

Have a nice day.

-London

8 0
3 years ago
What do the blocks in the looks category do?
mart [117]

Answer:

if u have a question can I see it

Explanation:

so I can know the answer choose

6 0
3 years ago
Other questions:
  • A(n application system is the master controller for all the activities that take place within a computer system. _______________
    15·1 answer
  • 7.12 LAB: Contains the character
    12·2 answers
  • (6 pts) Write a bash shell script called 08-numMajors that will do the following: i. Read data from a class enrollment file that
    10·1 answer
  • what will allow you to immediately exit the program without rebooting the computer, when you realize your browser is not respond
    7·1 answer
  • Reports produced by the United Nations are considered
    11·2 answers
  • 1. Assuming you are downloading a 100MB (800Mb) file on a Network that can download data at 54Mbps.
    15·1 answer
  • What do macOS and Windows use to prevent us from accidentally deleting files?
    15·1 answer
  • Consider rolling a 6-sided die. The outcome of interest is the number of dots that appears on the topside when the die stops rol
    7·1 answer
  • What is the purpose of linking text boxes?
    5·1 answer
  • What statement is accurate in regards to
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!