Question

# function:  

horizontal_line

# input:

a width value (integer)

# processing:

prints a single horizontal line of the desired size

# output:

does not return anything

# function:  

vertical_line

# input:

a shift value and a height value (both integers)

# processing:

generates a single vertical line of the desired height. The line is offset from the left side of the screen using the shift value

# output:

does not return anything

# function:  

two_vertical_lines

# input:

a width value and a height value (both integers)

# processing:

generates two vertical lines. the first line is along the left side of the screen. the second line is offset using the "width" value supplied

# output:

does not return anything

How would I write a Python Code for the three functions above? I am getting stuck after the first function. My current code is listed below. Thanks!

a def horizontal_line (width): print(Horizontal line, width=, width, :) print(* * width) def vertical_line (shift, heig

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

PLEASE NOTE : FEEL FREE TO ASK ANY DOUBTS by COMMENTING

  • You did not provide printing statement for function two_vertical_lines. change it for your comfort.
  • If you want me to add/change anything, Please let me know by commenting.
  • I used comments for better understanding. Comments starts with ' # '
  • Please refer to the screenshot of the code to understand the indentation of the code

Language : Python

IDE : Python IDLE

:::::::::::::::::::::::::::::::::::::::::::: CODE ::::::::::::::::::::::::::::::::::::::::

def horizontal_line(width):
print("Horizontal line, width=",width,":")
print("*"*width)

def vertical_line(shift, height):
print("Vertical Line, shift=",shift,"; height=",height,":")

# creating string for row, spaces for shift times and "*" at end
row = " "*shift+"*"

# printing row for height times
for i in range(height):
print(row)

def two_vertical_lines(width,height):

print("Two Vertical Lines, width=",width,"; height=",height,":")

# creating string for row, starting with left "*" and
# spaces for offset of width and "*" at end
row = "*"+" "*(width-2)+"*"

# printing row for height times
for i in range(height):
print(row)


# Testing code
horizontal_line(5)
vertical_line(5,5)
two_vertical_lines(5,5)

:::::::::::::::::::::::::::::::::::::::::::: OUTPUT ::::::::::::::::::::::::::::::::::::::::

>>> ==== RESTART: E:/Lines.py Horizontal line, width= 5 : ***** Vertical Line, shift= 5; height= 5 : Two Vertical Lines, widt

:::::::::::::::::::::::::::::::::::::: CODE in EDITOR ::::::::::::::::::::::::::::::::::

Lè Lines.py - E:/Lines.py (3.8.4) Eile Edit Format Run Options Window Help def horizontal_line (width): print (Horizontal li

_________________________________________________________________

Dear Friend, Feel Free to Ask Any Doubts by Commenting. ASAP i'll respond when i'm available.

I'm on a critical Situation. Please Do Not Forget To Give A Thumbs UP +1. It will Helps me A Lot.

Thank YOU :-)

Add a comment
Know the answer?
Add Answer to:
# function:   horizontal_line # input: a width value (integer) # processing: prints a single horizontal line...
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
  • python Write a function that takes as input a single integer parametern and computes the nth...

    python Write a function that takes as input a single integer parametern and computes the nth Fibonacci Sequence number The Fibonacci sequence first two terms are 1 and 1(so, if n - 2 your function should return 1). From there, the previous two values are summed to come up with the next result in the sequence 1.1,2,3,5,8,13, 21, 34, 55, etc.) For example, if the input is 7 then your function should return 13 26561.1615880 1 def Fibonacci(n): # your...

  • Write a C program that accepts a single integer N. Your code must then calculate the...

    Write a C program that accepts a single integer N. Your code must then calculate the average of all positive integers less than N that are divisible by either 5 or 7, but not both. When you print your average, truncate the result to three decimal places. Do not print anything else to the screen. Example input: 19 Example output: 10.200

  • Inspect the code below. The function subtract_five should take one integer as input and return that...

    Inspect the code below. The function subtract_five should take one integer as input and return that integer minus 5. Running the function will cause Python to throw an error. Change the function so the program correctly prints the value in y. This is the answer. but, see #. def subtract_five(inp):     print(int(inp-5))     return(int(inp-5)) y = subtract_five(18) - 5 print("This is the value in y = ", y)          # I don't understand this part? Why can I just use, print(y)??

  • C++ Write a function parseScores which takes a single input argument, a file name, as a string. Your function should read each line from the given filename, parse and process the data, and print the r...

    C++ Write a function parseScores which takes a single input argument, a file name, as a string. Your function should read each line from the given filename, parse and process the data, and print the required information. Your function should return the number of student entries read from the file. Empty lines do not count as entries, and should be ignored. If the input file cannot be opened, return -1 and do not print anything.     Your function should be named...

  • Python program Use the provided shift function to create a caesar cipher program. Your program s...

    python program Use the provided shift function to create a caesar cipher program. Your program should have a menu to offer the following options: Read a file as current message Save current message Type in a new message Display current message "Encrypt" message Change the shift value For more details, see the comments in the provided code. NO GLOBAL VARIABLES! Complete the program found in assignment.py. You may not change any provided code. You may only complete the sections labeled:#YOUR...

  • pick two answers 12 points). The function swap() should swap two integers and main() should print...

    pick two answers 12 points). The function swap() should swap two integers and main() should print those two swapped integers. What (if anything is wrong with this code? Select all that apply. oooo. No ure W..Ni def main(): X = 10 y = 2 x, y = swap(x,y). print(x,y) def swap(a,b): a = b temp = a b = temp main N on line 9, it is illegal syntax to introduce a new variable named temp. Instead, temp should be...

  • PYTHON:please display code in python Part 1: Determining the Values for a Sine Function Write a...

    PYTHON:please display code in python Part 1: Determining the Values for a Sine Function Write a Python program that displays and describes the equation for plotting the sine function, then prompts the user for the values A, B, C and D to be used in the calculation. Your program should then compute and display the values for Amplitude, Range, Frequency, Phase and Offset. Example input/output for part 1: Part 2: Displaying a Vertical Plot Header A vertical plot of the...

  • Write a function draw_T in functions.py, which receives three parameters: width, height and symbol. The first...

    Write a function draw_T in functions.py, which receives three parameters: width, height and symbol. The first two parameters are assumed to be integers and the third is a single character string. You don’t need to validate the type of the given parameters. The function returns no values. The function uses the given parameters to draw a T shape, such that the parameter width controls the upper bar, and height controls the middle vertical bar. The parameter symbol, controls which symbol...

  • #Practical Quiz 3 #Add a comment above each line of code describing what it does. #Be...

    #Practical Quiz 3 #Add a comment above each line of code describing what it does. #Be specific. Use multiple comment lines if you need to #OR write code below the comments requesting code. #Make sure your file runs and generates the correct results. def main(): #define variable str1 with string "Hello" str1 = "Hello" #print out the 2nd letter print(str1[1]) #START QUIZ HERE print(str1[-2]) print(str1[:3]) print(str1[2:len(str1)-1]) str2 = "World" print(str1+str2) #write code below to iterate over the str1 and print...

  • IN PYTHON ''' Helper func 3: checksum_ISBN Input: a list with 9 single digit number in...

    IN PYTHON ''' Helper func 3: checksum_ISBN Input: a list with 9 single digit number in it (first 9 digit in ISBN) Output: print out: "The correct checksum digit is:__. Now we have a legit ISBN: _____" Hint: just loop through 0-9, test every one with helper func1 to find out the one checksum that forms a legit ISBN with the correct ISBN in lis (10 numbers), call helper func2 to format it correctly. Then print the final result. '''...

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