output correction using print() function - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: output correction using print() function (/thread-28930.html) |
output correction using print() function - afefDXCTN - Aug-10-2020 HI everyone , can you help me to solve this task please specially the first question for others print(" *") print(" * *") print(" * *") print(" * *") print("*** ***") print(" * *") print(" * *") print(" *****") Try to: minimize the number of print() function invocations by inserting the \n sequence into the strings make the arrow twice as large (but keep the proportions) duplicate the arrow, placing both arrows side by side; note: a string may be multiplied by using the following trick: "string" * 2 will produce "stringstring" (we'll tell you more about it soon) remove any of the quotes, and look carefully at Python's response; pay attention to where Python sees an error - is this the place where the error really exists? do the same with some of the parentheses; change any of the print words into something else, differing only in case (e.g., Print) - what happens now? replace some of the quotes with apostrophes; watch what happens carefully. RE: output correction using print() function - DPaul - Aug-10-2020 As far as understand this, you would only need 1 print statement. Either concatenate everything into 1 string mixed with the '\n' , or make a list of the words, and print in a for loop. ? Paul RE: output correction using print() function - cvilao - Oct-13-2020 (Aug-10-2020, 09:39 AM)afefDXCTN Wrote: HI everyone , can you help me to solve this task please specially the first question for others Here are some of my answers, I am sure there are better ones, but they do the trick. #Original print(" *") print(" * *") print(" * *") print(" * *") print("*** ***") print(" * *") print(" * *") print(" *****") #Minimizing the number of print invocations print(" *\n * *\n * *\n * *\n*** ***\n * *\n * *\n *****") #Making the arrow twice as large (Keeping the proportions) print(" * ") #<-- Had to add spaces before to correct distortion print(" * * ") #<-- Had to add this line to correct distortion print(" *"," * ",sep=2*" ") #<-- Add as many spaces as necessary inside sep argument print(" * "," * ",sep=2*" ") print(" * "," * ",sep=2*" ") print("*** "," *** ",sep=2*" ") print(" * "," * ",sep=2*" ") print(" * "," * ",sep=2*" ") print(" **","*** ",sep=2*"*") #<-- Add as many "*" as necessary inside sep argument #Duplicating the arrow placing both side by side print(2*" * ") #<-- Add spaces after, otherwise the duplication will distort the arrow print(2*" * * ") print(2*" * * ") print(2*" * * ") print(2*"*** *** ") print(2*" * * ") print(2*" * * ") print(2*" ***** ")The final questions are for you to get familiar to Python's error and warning messages. RE: output correction using print() function - Sky_Mx - Sep-18-2021 To Make the arrow twice as large, you just need to convert every character of your string into a string, including the empty ones (spaces) print(" "," "," "," ","*") print(" "," "," ","*"," ","*") print(" "," ","*"," "," "," ","*") print(" ","*"," "," "," "," "," ","*") print("*","*","*"," "," "," ","*","*","*") print(" "," ","*"," "," "," ","*") print(" "," ","*"," "," "," ","*") print(" "," ","*","*","*","*","*") This will add a space between each character and make it twice as large, and you won't have distortion problem |