Commit 660f2b8e by BellCodeEditor

save project

parent 56e1a307
No preview for this file type
# 创建列表
list1 = [23,31,18,10,25,40,21]
# 将列表反转
list1.reverse()
# 将列表输出
print(list1)
\ No newline at end of file
# 创建列表
list1 = [31,18,10,25,40,21,23,31,18,10,25,40,21]
# 获取列表第3位元素并输出
print(list1[3])
# 获取列表第5位元素并输出
print(list1[5])
# 获取列表第7位元素并输出
print(list1[7])
# 获取列表第9位元素并输出
print(list1[9])
\ No newline at end of file
# 创建集合
set1 = {12,31,45,13,24}
# 在集合里添加元素20
set1.add(20)
# 输出集合
print(set1)
\ No newline at end of file
# 将变量sum初始化
sum = 0
# 使用for循环,将变量i在0到99取值
for i in range(100):
# 每次循环一次,i加1
i+=1
# 每循环一次,sum加i
sum = sum+i
# 输出求和结果
print(sum)
\ No newline at end of file
# 创建空集合
set1=set([])
# 设置常量
a=2
# 在101到201之间循环
for i in range(101,201):
# 判断是否有余数
if i%a==0:
# 能除尽就继续
continue
# 除不尽就添加到集合
else:
set1.add(i)
# 输出集合
print(set1)
\ No newline at end of file
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