LoginSignup
2
5

More than 5 years have passed since last update.

言語処理100本ノック00

Last updated at Posted at 2018-01-09

はじめに

 今後使うであろうpythonを一からやるため言語処理100本ノック2015を理解したい。途中からわけのわからない内容が書いてるので、あきらめそうだけどできるところまで頑張りたい!
 プログラミング初心者のため、ほかの人の記事や色々なものを参考にしながらとりあえず動かすことを目指します

ひとまず参考になるサイトを見つけました~
素人の言語処理100本ノック:まとめ @segavvy

@segavvyさんの書いたことを理解したい!

言語処理100本ノックの元サイトのリンク
http://www.cl.ecei.tohoku.ac.jp/nlp100/#data

環境

windows10(version:1709) 2017/01/09
python3.6.2

開始!

00.文字列の逆順

 文字列"stressed"の文字を逆に並べた文字列を得よ

00knock.py
s="stressed"
print(s[::-1])

すぐにわからないものが出てきました[スライス]
こういう時はいろいろ書いてみるもの

00knock.py
s="stressed"
print(s[::-1])
print(s[2::-1])
print(s[::-2])
print(s[3:2:-2])
print(s[4:1:-2])
print(s[5:1:-2])

出力結果

00knock.py
desserts
rts
dset
e
sr
se

やっとわかってきました。print(::)はprint(はじまり:終了:増分)を表していて始まりは0から!終了の番号の文字は出力されないってことみたいです

2
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
5