Commit e6e7e362 by BellCodeEditor

auto save

parent adaf6f8a
Showing with 23 additions and 8 deletions
import random # a=12.3456191
# print('%.4f' % a)#%格式化输出,.4代表小数 %对谁格式化
# # a1=round(a,3)
# # print(a1)
# # #切片法
alist = [] # price = 52
for i in range(1, 101): # # txt = "The price is {} dollars"
alist.append(i) # txt = "The price is {:.2f} dollars"
num = random.choice(alist) # print(txt.format(price))
# 请完善二分查找函数binary_search(),查找出num在列表alist里面的索引位置
def binary_search(alist,num): for i in range(2,101):
\ No newline at end of file for j in range (2,i):
if i%j == 0:
break
else:
print(i)
for i in range(2,101):
a=1
for j in range (2,i):
if i%j == 0:
a=0
if a==1:
print(i)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment