The following curriculum has been added to freeCodeCamp. (See this article)
It's a big deal, so I decided to take this opportunity to study. In this article, I will introduce what I did with * Scientific Computing with Python *.
This field was broadly divided into the following two.
In * Python for Everbody *, I was able to learn basic syntax, networks, databases, etc. from the part of what is Python by using video + selection questions. All the videos are in English, so I managed to decipher them using subtitles and translations.
In * Scientific Computing with Python Projects *, problems are actually raised and you can learn by writing and submitting code. Even if you don't have a local execution environment, you can rest assured that an environment called repel.it
that runs on the browser is provided. (I copied and wrote the source locally)
In addition, a test code is also available and can be submitted if all tests are passed.
In the next few articles, I will introduce the problems raised by * Scientific Computing with Python Projects * and my personal points.
The final thing I want is the ʻarithmetic_arranger` method, and the behavior is as follows
arithmeric_arranger(["32 + 698", "3801 - 2", "45 + 43", "123 + 49"])
Output:
32 3801 45 123
+ 698 - 2 + 43 + 49
----- ------ ---- -----
In addition, a bool type value can be specified in the second argument, and when True
, the calculation result must also be output.
Upper parts ( 32 3801 45 123
),
Medium parts (+ 698 --2 + 43 + 49
),
Divide into lower parts (----- ------ ---- -----
) and connect them with \ n
at the end.
I don't want to post my implementation because I want everyone to try it ...
This problem requires the top, middle, and bottom parts to be aligned to the right, as shown below.
○○○32
+○698
-----
○:Blank
So the string method rjust ()
was used. (Center justified: center ()
, Left justified: ljust ()
)
Also, if you want to right-justify the numerical value, use it after converting it to a character string once with str ()
.
I right-justified as follows.
"""
top_num=32, mid_num=698
top_num_len=2, mid_num_len=3
op='+' or '-'
"""
row_len = max(top_num_len, mid_num_len) + 2 # +And one space
top = top_num.rjust(row_len)
mid = op + mid_num.rjust(row_len - 1)
As you can see, when you solve a problem, you often find things that you don't use often (in this case, the method of character alignment), so it's a lot of fun.
The next issue is * Time Calculator *.
Recommended Posts