# Stones pile 100, and two individuals take turns randomly from block 1-5, the last one who can take who win, programming Import Random Stones = 100 COUNT = 0 the while Stones> 0: C = the random.randint (. 1, . 5 ) IF C> stones: C = stones IF COUNT% 2 == 0: Print ( " second person took stones% s " % C) the else : Print ( " first to take all the stones% s " % c) Stones - = c COUNT= 1 + # implement a method for determining whether a positive integer power of two, such as 2 to the power 4 is 16, returns True; 18 is not a power of 2, return False. # Performance requirements as high as possible. DEF Check (n-): COUNT = 0 the while True: IF 2 ** COUNT == n-: return True elif 2 ** COUNT> n-: return False the else : COUNT + =. 1 Print (Check (18 is )) Print (Check ( . 8 )) Print (Check (2 )) # Lista = [ 'a', 'ABC', 'D', 'ABC', 'FGI', 'ABF'], to find the most frequently appear in the list the first letter , # 出现了几次 lista = ['a','abc','d','abc','fgi','abf'] lista_str = ''.join(lista) max_code = lista_str[0] max_number = lista.count(max_code) for letter in lista_str: if lista_str.count(letter) > max_number: max_code = letter MAX_NUMBER= Lista_str.count (Letter) Print (max_code, MAX_NUMBER) # equilibrium point, an array, a figure on the left of all numbers add up the sum of this number equal to the sum of the right of all numbers, the number and the coordinates output please array_list = [4 , 3,2,8,7,2 ] for index in Range (len (array_list)): IF SUM (array_list [: index]) == SUM (array_list [index +. 1 :]): Print ( " balance point number is: coordinate% s, equilibrium is:% S " % (array_list [index], index)) BREAK the else : Print ( " non-equilibrium " ) # input an array, and the first maximum switching element, minimum exchange with the last element, the array output ] = array_list [4,3,2,8,7,2 MAX_VALUE = max (array_list) max_value_index = array_list.index (MAX_VALUE) MIN_VALUE = min (array_list) min_value_index = array_list.index (MIN_VALUE) array_list [max_value_index], array_list [0 ] = array_list [0], array_list [max_value_index] array_list [min_value_index], array_list [ -1] = array_list [-1 ], array_list [min_value_index] Print (array_list) # given an array sum by two to obtain the array number and equal to a given number, and returns the coordinates DEF findIndex (the nums, target): Result = {} for index in Range (len (the nums)): second_num = target - nums[index] if nums[index] in result: print(result) return result[nums[index]],index else: result[second_num] = index print(findIndex([4,3,2,8,7,2],10))