有用的連結:
少兒Python第一課
少兒python第二課
http://pythontutor.com/visualize.html#mode=edit
這周的筆記來了。
上周的內容有點多,作業也有點難度。
對小朋友來說不是件直接的事,所以家長受累。
小朋友家長發來反饋,這是在檢驗我的python水平嗎?
我也被檢驗了。
上周的作業,一直在被大娃各種問。
於是,我決定節奏調慢一點,難度調低一點。
畢竟本意是幫小朋友找點事做,不是幫家長找點事做。
所以本周在上課前,先給小朋友們講了下上周的作業。
主要有兩點,第一,坐標系;第二,怎麼用range,如何用range的概念來調整顏色。
本周內容
Builtin Constants (python內置的常量)
print("Some builtin constants:")print(True)print(False)print(None)
print("And some more constants in the math module:")import mathprint(math.pi)print(math.e)The Modulus or Remainder Operator (%) (取餘)
print(" 6%3 =", ( 6%3))print(" 5%3 =", ( 5%3))print(" 2%3 =", ( 2%3))print(" 0%3 =", ( 0%3))If Statement (當條件滿足時,執行相應的命令。能登陸youtube可看Kosbie親自講解:https://www.youtube.com/watch?v=a8P-RhWAm9c )
def f(x): print("A", end="") if (x == 0): print("B", end="") print("C", end="") print("D")
f(0)f(1)If else Statement (條件滿足時,執行A,否則,執行B)
def f(x): print("A", end="") if (x == 0): print("B", end="") print("C", end="") else: print("D", end="") if (x == 1): print("E", end="") else: print("F", end="") print("G")
f(0)f(1)f(2)if-elif-else statement
def f(x): print("A", end="") if (x == 0): print("B", end="") print("C", end="") elif (x == 1): print("D", end="") else: print("E", end="") if (x == 2): print("F", end="") else: print("G", end="") print("H")
f(0)f(1)f(2)f(3)
接下來是今天的作業了。
1. isEvenPositiveInt(x) Write the function isEvenPositiveInt(x) that takes an arbitrary value x, return True if it is an integer, and it is positive, and it is even (all 3 must be True), or False otherwise.
2. numberOfPoolBalls(rows)Pool balls are arranged in rows where the first row contains 1 pool ball and each row contains 1 more pool ball than the previous row. Thus, if there are 3 rows, then we'd have 6 total pool balls (1+2+3). Write a function that takes an int value, the number of rows, and returns another int value, the number of pool balls in that number of rows. For example, numberOfPoolBalls(3)returns 6.
3. drawGridWrite the function drawGrid that takes 5 values – a canvas, a left, top, right, and bottom – describing a rectangular region of the canvas, and fills this region with a drawing of a rectangular grid. For large areas (>200 pixels wide), the grid should have 8 columns, with cells alternating in the shades of grey and white in the image below (or fairly close to them in any case). For smaller areas, the grid should have 4 columns, and the cells should alternate green and purple. Also, each cell will be labeled with a number (note that you can provide a number as the text value in create_text). For large areas, the numbers start in the left cell and proceed rightwards. For small areas, the numbers start with 2 in the right cell and proceed leftwards. Here is a screenshot to help
獨樂樂不如與眾樂