100 Days of Code - Python Functions and Karel (Day6)

Function

1
2
3
4
# Defining Function
# 使用 def 關鍵字定義一個 function
def my_function():
# write some code

Indentation in python

  • python 文件建議使用 四個 space 做縮排
  • tab 跟 space 在同一個文件中不能混用

While Loops

1
2
3
4
5
6
7
8
9
10
# for loops
for item in list_of_items:
# Do Something to each item

for number in range(a,b):
print(number)

# while loops
while some_thing_isTure:
# Do Something repeatedly