Why Python
by admin
Why Python? If it’s not 10 times better than other languages (except for the running speed), I won’t bother it.
Let me give you an example to show Python’s awesomeness and attractiveness.
Refer to this page for the problem. We are asked to compute the first ten digits of the sum of one-hundred 50-digit numbers:
37107287533902102798797998220837590246510135740250
46376937677490009712648124896970078050417018260538
74324986199524741059474233309513058123726617309629
…
Suppose you are using C/C++, you probably need to use array to handle each digit of these long numbers, since these languages don’t support such long integers. If you are using Python, things will be very easy.
Just copy/paste these numbers into a file. Edit it with Vim. Use Vim command:
:%s/$/,/g
to add a comma to the end of each line. Remove the last comma. Then insert “array = [” to the beginning of the first line and add a “]” to the end of the last line.
Add the following to another line:
print sum(array)
Save this file and run it with Python and here we are done.
Here you can see that Python can handle arbitrary large number, as long as you memory can hold it. This is just a tip of the iceberg of Python’s advantage. Use it and you will get more and more.
Comments
用matlab也可以阿
matlab没法动态meta programming吧
The unbeatable design of these happens to be tends to make every girl need for doing this. In addition to, the actual custom shape of these kind of happens to be bring about lots of different layout possibilities. The particular halo pattern the spot that the core rock is presented together with small diamond jewelry towards total the top engagement ring is high on type engagement ring presently. Facet gemstone patterns to be able to several stone diamond ring designs to be able to basic vintage designs; the chances involving style tend to be limitless.
Hello, i believe that i noticed you visited my weblog so i came to “go back the favor”.I’m attempting to to find things to enhance my web site!I assume its ok to make use of a few of your ideas!!
Thanks for sharing superb informations. Your web-site is very cool. I’m impressed by the details that you’ve on this site. It reveals how nicely you perceive this subject. Bookmarked this website page, will come back for more articles. You, my friend, ROCK! I found simply the information I already searched everywhere and simply couldn’t come across. What a great web-site.