Question

Use Python and only while loops For this part of the homework you will write code...

Use Python and only while loops

For this part of the homework you will write code to draw an isosceles right triangle. (A right triangle in which the height and base are the same size.)

Your program should prompt the user for these inputs, in exactly this order: 1. The height of their triangle
2. The symbol the triangle will be outlined in
3. The symbol the triangle will be filled with

For these inputs, you can assume the following:

 The height will be a positive integer (greater than zero)

 The symbols will be a single character each

Use the first symbol to draw an isosceles right triangle of the height chosen by the user. The triangle should be filled in with the second symbol, in the cases in which there is interior space to fill.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

height = int(input("Enter the height of the triangle:"))
outsymbol = input("Enter the symbol for outlining the triangle:")
fillsymbol = input("Enter the symbol for filling the triangle:")
count = 0
while count < height:
   count1 = 0
   str1 = ""
   while count1 <= count:
       if count1 == 0:
          str1 = str1 + outsymbol
       elif count1 == count:
          str1 = str1 + outsymbol
       elif count1 > 0 and count1 < count and count < height - 1:
          str1 = str1 + fillsymbol
       elif count1 > 0 and count1 < count and count == height - 1:
          str1 = str1 + outsymbol
       count1 = count1 + 1
   print(str1)
   count = count + 1  

Add a comment
Know the answer?
Add Answer to:
Use Python and only while loops For this part of the homework you will write code...
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
  • For this interactive assignment, you will continue to utilize loops and functions and write a Python...

    For this interactive assignment, you will continue to utilize loops and functions and write a Python program that asks the user for an integer (number) greater than 1. Once the user enters an integer, it should then allow the user to CHOOSE between the following two options: If 1 is entered, a countdown from that number to zero is printed. If 2 is entered, the factorial of the number is printed. If the user inputs a number less than 1,...

  • Hi. Please help me solve this in python using only while loops, if statements. Can't use...

    Hi. Please help me solve this in python using only while loops, if statements. Can't use for loops and lists. In this programming assignment, you will be writing a program that prints out several shapes via text. In this PA, you will be required to use functions and parameters. This is both to reduce redundancy and to make your code clean and well-structured. Name your program shaper.py Your program should have the capability to print out three different shapes: An...

  • 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...

  • Write a Python function make_triangle(trianglechar, triangleheight) that will return a string with an isosceles right triangle...

    Write a Python function make_triangle(trianglechar, triangleheight) that will return a string with an isosceles right triangle based on the two formal parameters triangle_height giving the triangle height and triangle_char that gives the symbol to be printed. Important notes: This program returns (not prints!) a string. For this function and the other part of this lab you are required to put in a docstring. That will be checked by a TA/grader reading the program. Every one of the occurrences of triangle_char...

  • Write a single program in java using only do/while loops for counters(do not use array pls)...

    Write a single program in java using only do/while loops for counters(do not use array pls) for the majority of the program and that asks a user to enter a integer and also asks if you have any more input (yes or no) after each input if yes cycle again, if not the program must do all the following 4 things at the end of the program once the user is finished inputting all inputs... a.The smallest and largest of...

  • Study guide Intro to PYTHON questions: 25) Write the code that will generate this output using...

    Study guide Intro to PYTHON questions: 25) Write the code that will generate this output using only while loops and if statements (no string multiplication). ###AAAAAAAA### ###BBBBBBBB### ###CCCCCCCC### ###AAAAAAAA### ###BBBBBBBB### ###CCCCCCCC### 26) Write code that asks the user for a size and prints a triangle of stars of that size that increases by two at each level. You can only use one while loop and any number of variables and counters you want, but you are limited to these tools....

  • For this lab you will write a small program that prints a few "shapes" using asterisks....

    For this lab you will write a small program that prints a few "shapes" using asterisks. Your program will prompt the user to select a shape by entering a number (square or triangle for B grade, add the zig- zag for the A grade). It will then prompt for the size, and then if a square or triangle is selected it will prompt for "not filled" or "filled", and if azig-zag is selected it will prompt for the number of...

  • Python 2.7.14 Programming Assignment Shape Drawing With Notepad++(PLEASE READ AND FOLLOW THESE INSTRUCTIONS THOROUGLY AS THIS...

    Python 2.7.14 Programming Assignment Shape Drawing With Notepad++(PLEASE READ AND FOLLOW THESE INSTRUCTIONS THOROUGLY AS THIS ASSIGNMENT IS FOR PYTHON 2.7.14. ONLY AND I REALLY NEED THIS TO WORK!!! ALSO PLEASE HAVE THE CODE PROPERLY INDENTED, WITH WHATEVER VARIABLES DEFINED, WHATEVER IT TAKES TO WORK FOR PYTHON 2.7.14. I feel like nothing I do is working and I'm trying everything I can think of. ): In this assignment, the student will create a Python script that implements a series of...

  • Hello! we are using Python to write this program. we are supposed to use loops in...

    Hello! we are using Python to write this program. we are supposed to use loops in this assignment. I would greatly appreciate the help! Thank you! Write a program that allows the user to play a guessing game. The game will choose a "secret number", a positive integer less than 10000. The user has 10 tries to guess the number. Requirements: we would have the program select a random number as the "secret number". However, for the purpose of testing...

  • In Python Exercise – For & While Loops Create a new file called loops.py and use...

    In Python Exercise – For & While Loops Create a new file called loops.py and use it for all parts of this exercise. Remember the difference between input and raw input? Be sure to test your code for each part before moving on to the next part. Write a program using a for loop that calculates exponentials. Your program should ask the user for a base base and an exponent exp, and calculate baseexp. Write a program using a while...

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