Scientific Computing with Python Projects - Arithmetic Formatter

I did the exercise above, but I’m not able to place one next to the other, please could you help me, follow the link below:

How would you do that by hand on piece of paper? You can try imagining you are able to write only at a single line at a time, and when line is written you cannot add anything more to it.

To place them next to each other, they need to be on the same line. Think of it as one long line of characters, including spaces.

Hi! You may use str.format or formatted string literals .

one possibility do this would

  Think about two strings you concatenate in some way, so that
  the second appears beneath the other when printed.

 Everything which is in the first string will be in one line next to one 
 another and everything in the second string will be in one line next to 
 one another.

What should be in the first string?
What should be in the second string?

What do you need to put in between both strings (during concatenation)
in order that the second string appears beneath the first?

Write the code which generates the appropriate string from the data
given in the arguments.

But if you use a for loop instead like in your code to iteratively print one problem next to the other horizontally you will need to specify this in the print command because by default print always continues in a new line after each iteration of you want print to stay on the same line you could do this

  • Example
    for item in things:
    print(item, end=’ '*k)

    where k is the number of spaces you want to have in between the 
                 item1     item2     item3  and so on...  , with k spaces in between

for item in things:

   prints by default
                                      and so on...

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.