Question

In: Computer Science

17.18 LAB 8A: Input and formatted output: Left-facing arrow You will be working on generating a...

17.18 LAB 8A: Input and formatted output: Left-facing arrow

You will be working on generating a formatted output using characters such as *, #, -, +.

You need to prompt the user for a character for the arrowhead, and a character for the arrow body, and then print a left-facing arrow. Your prompts should be exactly "Enter a character for the arrowhead:" and "Enter a character for the arrow body:", as shown below.

Ex: If the user inputs a * after the first prompt, and a # after the second prompt,

Enter a character for the arrowhead:#
Enter a character for the arrow body:*

Then the output is:

  #
 ##*****
###*****
 ##*****
  #

can you help me with writing this code in Python?

Solutions

Expert Solution

Code and output

Code for copying

a=str(input("Enter a character for the arrowhead:"))
b=str(input("Enter a character for the arrowbody:"))

print(" {}".format(a))
print(" {}{}".format(a*2,b*5))
print("{}{}".format(a*3,b*5))
print(" {}{}".format(a*2,b*5))
print(" {}".format(a))

Code snippet

a=str(input("Enter a character for the arrowhead:"))
b=str(input("Enter a character for the arrowbody:"))

print("  {}".format(a))
print(" {}{}".format(a*2,b*5))
print("{}{}".format(a*3,b*5))
print(" {}{}".format(a*2,b*5))
print("  {}".format(a))


Related Solutions

4.24 LAB*: Program: Drawing a half arrow This program outputs a downwards facing arrow composed of...
4.24 LAB*: Program: Drawing a half arrow This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by user specified arrow base height, arrow base width, and arrow head width. (1) Modify the given program to use a loop to output an arrow base of height arrowBaseHeight. (1 pt) (2) Modify the given program to use a loop to output an arrow base of width arrowBaseWidth. Use a nested loop...
Summary In this lab, you add the input and output statements to a partially completed Java...
Summary In this lab, you add the input and output statements to a partially completed Java program. When completed, the user should be able to enter a year, a month, and a day to determine if the date is valid. Valid years are those that are greater than 0, valid months include the values 1 through 12, and valid days include the values 1 through 31. Instructions Notice that variables have been declared for you. Write the simulated housekeeping() method...
Writing a Modular Program in Java In this lab, you add the input and output statements...
Writing a Modular Program in Java In this lab, you add the input and output statements to a partially completed Java program. When completed, the user should be able to enter a year, a month, and a day to determine if the date is valid. Valid years are those that are greater than 0, valid months include the values 1 through 12, and valid days include the values 1 through 31. Instructions Notice that variables have been declared for you....
Writing a Modular Program in Python In this lab, you add the input and output statements...
Writing a Modular Program in Python In this lab, you add the input and output statements to a partially completed Python program. When completed, the user should be able to enter a year, a month, and a day. The program then determines if the date is valid. Valid years are those that are greater than 0, valid months include the values 1 through 12, and valid days include the values 1 through 31. Instructions Notice that variables have been declared...
Objectives: Write a program which reads User Input using Scanner Print formatted output using printf or...
Objectives: Write a program which reads User Input using Scanner Print formatted output using printf or DecimalFormat Practice programming simple mathematical calculations Instructions: Samwise Gamgee has finally decided to submit his expense report for all of his adventures regarding his travels to Mordor. Part of those expenses are his stay at the Prancing Pony Inn located in Bree. You are to write a simple Java program which will generate an Invoice for his stay at the Inn. Your program should...
linux. If you are running UBUNTU: There may be an issue with the arrow keys working...
linux. If you are running UBUNTU: There may be an issue with the arrow keys working properly in vi on Ubuntu. When you use the arrow keys in insert mode the letters A, B, C, and D get printed instead. There are a few fixes to this problem but the main culprit is the version of vi installed on your system. Ubuntu ships with vi-light. Let’s upgrade to the full vi. Use apt to install the vim package (vim is...
6.25 LAB: Swapping variables Write a program whose input is two integers and whose output is...
6.25 LAB: Swapping variables Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 3 8 The output is: 8 3 Your program must define and call the following function. swap_values() returns the two values in swapped order. def swap_values(user_val1, user_val2) **in Python, please
I/O Lab Java Purpose To practice the input and output concepts discussed in this module. Specifically,...
I/O Lab Java Purpose To practice the input and output concepts discussed in this module. Specifically, reading from and writing to local files, and formatting output. Instructions Read in file input.csv and generate a cleanly formatted table in output.txt. See the samples below. input.csv name,ID,salary,years experience foo,1,13890,12 bar,2,2342,3 baz,3,99999,24 output.txt Name | ID | Salary | Years experience -----+----+--------+----------------- Foo | 1 | 13890 | 12 Bar | 2 | 2342 | 3 Baz | 3 | 99999 | 24
(1) Pre Lab Question: You are working in the lab and are told to create an...
(1) Pre Lab Question: You are working in the lab and are told to create an artificial membrane from phospholipids. You are then instructed to add certain solutes to the membrane to see if it works appropriately. Rank the permeability for the following across a phospholipid membrane for the following: lysine, urea, sodium ion, insulin, water, indole
IN JAVA!!! In this project, you will use radix.txt as the input file, and output the...
IN JAVA!!! In this project, you will use radix.txt as the input file, and output the integers SORTED USING RADIX SORT. You may assume all your input consists of integers <=9999. Your main program will input the integers and put them into a QUEUE. It will then pass this queue to a method called radixSort which will sort the numbers in the queue, passing the sorted queue back to main. The main program will then call another method to print...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT