yuji96 / garakuta Goto Github PK
View Code? Open in Web Editor NEWプチ個人開発のたまり場。
プチ個人開発のたまり場。
それぞれの英単語のアルファベットの数を数えて並べると円周率になる。
例)
英文 : May I have a large container of coffee
円周率: 3.1415926
quiz/circle_digits.txt
を読み込んで語呂合わせの文字列を取得し、
この文字列を用いて円周率を402桁まで求めよ。
以下、入力方法と出力方法の規則。
.
は無視する。:,—!="()
が独立して存在している位置は0
とする。
" 3 "
は記号が独立しているから010
だが、"3"
は記号が文字と隣接しているので3
というふうに語呂を数字に変換する。float
型は402桁も扱えないので、str
型で出力する。ユーザーは開発者の想定通りに入力してくれない。例えば電話番号だと人によって0120-aaa-aaa
や0120(aaa)aaa
だったりする。
これはwebアプリの入力フォームだけの問題ではなく、どの分野のエンジニアも対応できるようになる必要がある。
ちなみに正規表現を使うとトリッキーな文字列操作ができたりする。
p
を求めよ。6/p の平方根
を求めよ。いわゆるシミュレーションをする問題。標準ライブラリは何を使ってもOK。
数学-basicではなくあくまでpython-basicなので、a, bが互いに素
とはa, bの最大公約数が1
ということは書いておく。最大公約数の求める関数は標準ライブラリのmathに入ってる。同じく乱数も標準ライブラリで生成できる。ヒントはここまで。
Pythonの「善い」の定義
>>> import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
↑ここは別に読まなくてもいいけど
pip install hacking
flake8 quiz05.py
とターミナルに入力した時に表示されたコーディング違反を全て直せ。
PythonにはPEP8などのコーディング規約、つまりコードを書く時の約束事がある。この共通した約束事を守ると、コードの可読性が上がり、開発チームのメンバーからレビューをもらいやすくなるなど利点は大きい。
しかし、規約をいちいち確認するのは面倒だし、日本語のドキュメントは少ない。ここでflake8というライブラリをインストールして実行すると自動でコードチェックをしてくれる。(hackingが付属したflake8はさらに厳しくコードチェックをする。)
これを実装した覚えがない
今後も直す予定はないけど
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.