Created
June 11, 2017 05:21
python log1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# リストについて | |
foods = ["apple","banana","orange"] #insert list | |
foods[0]; # return apple, the first list | |
foods.append("pizza") #最終行に挿入 | |
# for statement | |
foods = ["apple","banana","orange"] #insert list | |
for food in foods: #:をいれると条件分岐になる | |
print[food] | |
#while 文 | |
i = 0 #変数に値を指定 | |
while i <= 100: | |
if i % 2 != 0: | |
print(i) | |
if i == 50: | |
break; #break文が | |
i += 1 #i++は使えないみたい | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
0 | |
1 | |
2 | |
3 | |
4 | |
5 | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
#関数 | |
def sayHello(name, message ="おはよう"): #default値を指定することができる | |
print(message + name + "さん") | |
sayHello("DAI","こんにちは") #name自体は関数ないでしか利用できない。スコープ外ということになる | |
#module, library | |
import utils #utils.pyファイルを取り込むことができる | |
import library #importで、ほかのファイルを呼び出せる。ほかのファイルからも、libraryからも呼び出せ宇 | |
if utils.sayHello() #module.functionで呼び出せる | |
return true | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment