CouchDB has several features that help it stand out from the other databases in this rapidly growing field. Incremental map/reduce, peer to peer replication, mobile device synchronization, a realtime update feed, and the ability to host an application in the database itself (also known as a Couchapp) are just a few. See how companies such as the BBC, Radical Dynamic, Signal, and Incandescent Software are using CouchDB to solve their real world challenges.
1. The diagram shows angles MBC and ABC measuring 25 degrees each.
2. Angle MBC and ABC are equal since they are vertical angles.
3. Therefore, the measure of angle CBD is also 25 degrees by angle substitution.
CouchDB has several features that help it stand out from the other databases in this rapidly growing field. Incremental map/reduce, peer to peer replication, mobile device synchronization, a realtime update feed, and the ability to host an application in the database itself (also known as a Couchapp) are just a few. See how companies such as the BBC, Radical Dynamic, Signal, and Incandescent Software are using CouchDB to solve their real world challenges.
1. The diagram shows angles MBC and ABC measuring 25 degrees each.
2. Angle MBC and ABC are equal since they are vertical angles.
3. Therefore, the measure of angle CBD is also 25 degrees by angle substitution.
The document discusses various micro:bit accelerometer applications including:
- Reading acceleration values from the 3-axis accelerometer and controlling it.
- Examples like a electronic dice, movement indicator, tilt control game, and earthquake detector.
- Code snippets are provided for building applications like tracking dice rolls on shakes, showing direction arrows based on movement, and controlling a light sprite in a balancing game.
The document discusses functions in C language. It explains that functions can be divided into built-in functions and user-defined functions. Built-in functions are provided by the compiler as a "black box" that can be called, while user-defined functions are created by the user according to needs. User-defined functions have benefits like reusability, modularity and readability. It also talks about function prototypes, definitions, parameters, arguments, scope, and call by value and call by address.
The document discusses loops in programming. It covers for, while, and do/while loops as well as nested loops. It provides examples of calculating sums and finding narcissistic numbers using loops. Continues and breaks are also mentioned as ways to alter a loop's execution flow.
The document discusses various types of operators and expressions in C language, including: arithmetic operators, assignment operators, unary operators, binary operators, comparison operators, logical operators, and conditional statements like if and if/else. It provides examples of using these operators and statements to perform calculations and make comparisons. The key concepts covered are operators, expressions, arithmetic operations, assignment, increment/decrement, comparison, logical operations, and if/else conditional statements.
The document discusses variables and basic data types in C language. It covers topics such as variable and memory, basic data types, variable declaration and usage, truncation and overflow, address operator (&), constants and symbolic constants. The key points are:
1) A variable is a container that stores data in memory and its content may change as the program executes.
2) Basic data types include char, integer, float, etc. Each data type occupies a different size of memory and has a specific range of values.
3) Variables must be declared before use, specifying the data type and name. The variable name is a reference to the memory location where the data is stored.
14. 以下運算子可作用在串列資料
n in list1
檢查指定資料 n 是否存在於 list1 串列中
n not in list 1
檢查指定資料 n 是否不存在於 list1 串列中
x = list1
使變數 x 參用到 list1,x 與 list1 會共用同⼀串列資料
list1 + list2
將 list2 內容串接在 list1內容之後,產生新串列
list1 * n
將 list1 內容重複串接 n 次,產生新串列
串列運算子 1/2
14
27. 梭哈牌型
應用實例:撲克牌梭哈遊戲 2/9
27
牌型名稱 說明 實例
同花順
Straight Flush
五張牌同樣花色,而且牌值連續 紅心A、紅心2、紅心3、紅心4、紅心5
鐵支
Four of a Kind
五張牌中有四張同樣數字的牌 紅心A、黑桃A、方塊A、梅花A、梅花2
胡蘆
Full house
五張牌有三張同樣牌值,且另兩張也同樣牌值 紅心A、黑桃A、方塊A、梅花2、梅花2
同花
Flush
五張牌為同樣花色 紅心A、紅心8、紅心9、紅心3、紅心Q
順子
Straight
五張牌的牌值為連續 紅心A、黑桃2、紅心3、紅心4、梅花5
三條
Three of a Kind
五張牌中有三張同樣牌值的牌 紅心A、方塊A、梅花A、紅心3、紅心4
兩對
Two Pairs
五張牌中有兩組兩張同樣牌值的牌 紅心A、黑桃A、方塊K、黑桃K、紅心2
一對
One Pair
五張牌中有二張同樣牌值的牌 方塊A、黑桃A、紅心3、梅花4、紅心5
散牌
High card
五張牌花色沒有全部相同,牌值皆不相同,且
牌值不連續
方塊A、黑桃8、紅心9、梅花J、紅心10
28. import random
suits = ['黑桃', '紅心', '方塊', '梅花'] #撲克牌花色名稱串列
#建立撲克牌串列,0~12表⽰黑桃,13~25表⽰紅心,26~38表⽰方塊,39~51表⽰梅花
deck = [i for i in range(52)]
#show_card()副程式,顯⽰card值對應的撲克牌,card值0~51,0顯⽰紅心A,51顯⽰梅花K
def show_card(card):
suit = card // 13
print(' %s' %(suits[suit]), end = '') #顯⽰花色名稱
number = card % 13
if (number == 0): #顯⽰牌值
print('A', end = '')
elif(number == 10):
print('J', end = '')
elif(number == 11):
print('Q', end = '')
elif(number == 12):
print('K', end = '')
else:
print(number + 1, end='')
應用實例:撲克牌梭哈遊戲 3/9
28
29. #show_hand()副程式,顯⽰玩家手牌的梭哈牌型,player_id為玩家為編號
def show_hand(player_id):
if(flush[player_id] and straight[player_id]):
print('同花順n')
return
if(count[player_id][4] == 1):
print('鐵支n')
return
if(count[player_id][3] == 1 and count[player_id][2] == 1):
print('葫蘆n')
return
if(flush[player_id]):
print('同花n')
return
if (straight[player_id]):
print('順子n')
return
if (count[player_id][3] == 1): print('三條n')
if (count[player_id][2] == 2): print('兩對n')
if (count[player_id][2] == 1): print('⼀對n')
if (count[player_id][1] == 5): print('散牌n')
應用實例:撲克牌梭哈遊戲 4/9
29
30. player = int(input('輸入玩家人數:')) #輸入玩家入數
random.shuffle(deck) #洗牌
#發牌
card = [[] for i in range(player)] #玩家手牌串列
k = 0
for i in range(5): #每位玩家發5張牌
for j in range(player): #依玩家順序張牌
card[j].append(deck[k])
k += 1
#card=[[0,1,2,3,4]] #單⼀玩家測試用資料
應用實例:撲克牌梭哈遊戲 5/9
30
player
card[[]] int int int int int
int int int int int
int int int int int
31. #建立rank二維串列,用來統計玩家各牌值撲克牌之張數,ACE牌可算1或14
rank = [[0 for i in range(14)] for j in range(player)]
for i in range(player):
for j in range(5):
rank[i][card[i][j] % 13] += 1
rank[i][13] = rank[i][0] #ACE牌也可當14點
應用實例:撲克牌梭哈遊戲 6/9
31
player
rank[[]] int int ... int
int int ... int
int int ... int
14
32. #建立flush串列,用來記錄玩家的撲克牌是否為同花
flush = [False for i in range(player)]
for i in range(player): #檢查玩家5張牌是否相同花色
flush[i] = (card[i][0]//13 == card[i][1]//13 == card[i][2]//13 ==
card[i][3]//13 == card[i][4]//13)
應用實例:撲克牌梭哈遊戲 7/9
32
bool bool ... bool
player
flush[]
33. #建立straight串列,用來記錄玩家的撲克牌是否為順子
straight = [False for i in range(player)]
#檢查玩家5張牌是否連續
for i in range(player):
for j in range(10):
if (rank[i][j] == 0): continue
for k in range(1, 5): #繼續檢查後面4張
if (rank[i][j + k] == 0): break
if (k == 4):
straight[i] = True
應用實例:撲克牌梭哈遊戲 8/9
33
bool bool ... bool
player
straight[]
34. '''
建立count二維串列用來統計玩家撲克牌中之同點數牌情形
count[][2]==1 對子;count[][2]==2 兩對;count[][3]==1 三條;count[][4]==1 鐵支
'''
count = [[0 for i in range(5)] for j in range(player)]
for i in range(player):
for j in range(13):
count[i][rank[i][j]] += 1
#顯⽰每位玩家之手牌及梭哈牌型
for i in range(player):
print('第%d位玩家:' %(i + 1))
for j in range(5): #顯⽰玩家手牌內容
show_card(card[i][j])
print('n 梭哈牌型:', end = '')
show_hand(i) #顯⽰玩家手牌之梭哈牌型
應用實例:撲克牌梭哈遊戲 9/9
34
38. A為可儲存n筆整數的串列
A = [...,...,...,......]
p = A[0]
q = A[0]
for i in range(n):
if A[i] > p:
p = A[i]
if A[i] < q:
q = A[i]
程式碼運算後,下列何者錯誤
A. p是A串列資料中的最大值
B. q是A串列資料中的最小值
C. q < p
D. A[0] <= p
自我評量 4/7
38
39. 下列程式執行後,輸出為何?
arr = [y for y in range(10)]
sum = 0
for i in range(1, 9):
sum = sum – arr[i-1] + arr[i] + arr[i+1]
print(sum)
A. 44
B. 52
C. 54
D. 63
自我評量 5/7
39
40. 執行下列程式,若依序輸入整數0,1,2,3,4,5,6,7,8,9
arr = [0 for x in range(10)]
for i in range(10):
arr[(i + 2) % 10] = eval(input())
則arr串列內容為何
A. [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
B. [2, 0, 2, 0, 2, 0, 2, 0, 2, 0]
C. [9, 0, 1, 2, 3, 4, 5, 6, 7, 8]
D. [8, 9, 0, 1, 2, 3, 4, 5, 6, 7]
自我評量 6/7
40
41. 執行下列程式,輸出為何?
for i in range(1, 5):
A[i] = 2 + i * 4
B[i] = i * 5
C = 0
for i in range(1, 5):
if B[i] > A[i]:
C = C + (B[i] % A[i])
else:
C = 1
print(C)
A. 1
B. 4
C. 3
D. 333
自我評量 7/7
41