no message

This commit is contained in:
陈银军
2025-12-04 13:46:06 +08:00
parent cc93dce428
commit 39444d26c8
58 changed files with 1 additions and 1 deletions
+3
View File
@@ -0,0 +1,3 @@
# pass 表示空语句,。没有实际作用
for i in 'chenxuan':
pass
+4
View File
@@ -0,0 +1,4 @@
for i in range(1,100):
print(i)
if i==80:
break
+4
View File
@@ -0,0 +1,4 @@
for i in range(1,10):
if i==6:
continue
print(i, end=' ')
+2
View File
@@ -0,0 +1,2 @@
for i in "chenxuan":
print(i)
+3
View File
@@ -0,0 +1,3 @@
for i in range(1,13):
if i%2==0:
print(i,"是偶数")
+4
View File
@@ -0,0 +1,4 @@
s=0
for i in range(1,101):
s+=i
print(s)
+6
View File
@@ -0,0 +1,6 @@
s=0
for i in range(1,11):
s+=i
else:
print(s)
# for 正常执行完后执行else语句
@@ -0,0 +1,5 @@
number=eval(input("请输入幸运数字:"))
if number==1:
print("小孩")
else:
print("大孩子")
@@ -0,0 +1,2 @@
num=eval(input("请输入幸运数字:"))
print('输入了幸运数字1') if num==1 else print('输入了其他幸运数字')
@@ -0,0 +1,2 @@
number=eval(input("请输入幸运数字:"))
print("您中奖了!" if number==1 else "hehe")
@@ -0,0 +1,15 @@
scope=eval(input("亲输入您的成绩"))
if scope<0 or scope>120:
print("您的成绩输入有误")
elif 0<=scope<60:
print("未及格")
elif 60<=scope<80:
print("还可以,继续努力")
elif 80<=scope<90:
print("优秀")
elif 90<=scope<100:
print("非常优秀")
elif scope==100:
print("满分")
else:
print("hehe")
@@ -0,0 +1,6 @@
a=eval(input("请输入您的年龄:"))
if a>=18:
print("您是大人")
if a<18:
print("你是小孩子!")
@@ -0,0 +1,5 @@
n=eval(input("请输入数值"))
if n%2==0:
print("偶数")
if not n%2==0:
print("奇数")
+3
View File
@@ -0,0 +1,3 @@
a = [1,2,3,'1',True,2.1]
# 通过下标取值
print(a[2])
+4
View File
@@ -0,0 +1,4 @@
a = [1,2,3,'1',True,2.1]
# 安下标修改list的值
a[1] = a[4]
print(a)
+7
View File
@@ -0,0 +1,7 @@
l = [1,2,3]
h = l.copy()
l.append(12)
# 浅拷贝
print(h)
print('---------')
print(l)
+3
View File
@@ -0,0 +1,3 @@
l = [1,2,3,1,1,1,1,1,1]
# count 返回指定对象在list中出现的次数
print(l.count(1))
+3
View File
@@ -0,0 +1,3 @@
l = [1,2,3,1,1,1,1,1,1]
# 返回元素第一次出现的下标 index(value,start,end)
print(l.index(1,4))
+3
View File
@@ -0,0 +1,3 @@
l = [1,2,3,1,1,1,1,1,1]
# len 返回list长度
print(len(l))
@@ -0,0 +1,4 @@
l = [1,2,3]
# 反转list
l.reverse()
print(l)
@@ -0,0 +1,13 @@
c = [1,2,3,'1',True,2.1]
# 变量[起始下标:结束下标]
# 如果下标从0开始可以省略不写,例如 n = l[:4]
# 如果结束下标取的是最后一个元素,可以省略不写,例如 n = l[3:]
# 如果列表中的元素都要,开始和结束下标都可以省略,例如 n = l[:]
# n = l[:-1] 表示从0开始 - 到数二个元素
print(c[0:4])
print(c[:4])
print('-------------------------')
print(c[0:])
print('-------------------------')
print(c[:7])
print(c[:10])
@@ -0,0 +1,9 @@
l = [1,2,3,4,5,6,7,8,9]
# list[start:stop:step]
print(l[::2])
print('-------------')
print(l[::3])
print('-------------')
print(l[::4])
print('-------------')
@@ -0,0 +1,9 @@
l = [1, 2,3,4,5,6,7,8,9]
# list[start:stop:step]
print(l[::-2])
print('-------------')
print(l[::-3])
print('-------------')
print(l[::-4])
print('-------------')
@@ -0,0 +1,3 @@
b2 = [1,2,3]
b1 = [4,5,6]
print(b1+b2)
@@ -0,0 +1,3 @@
c = [1,2,3,'1',True,2.1]
c.clear()
print(c)
@@ -0,0 +1,3 @@
n = [1, 2, 3, 4, 5,9988]
del n[3]
print(n)
@@ -0,0 +1,8 @@
a = [1,2,3,'1',True,2.1]
# 删除指定下标 不传入下标时默认删除最后一个元素
# pop() 可以返回删除的值
# a.pop()
a.pop(1)
print(a)
print('-------------')
print(a.pop(1))
@@ -0,0 +1,4 @@
l = [1, 2, 3, 4, 5,9988]
# 删除指定的数据
l.remove(9988)
print(l)
@@ -0,0 +1,3 @@
d1 = [6,5,4,3,2,1]
print(6 in d1)
print(8 not in d1)
@@ -0,0 +1,4 @@
a1 = [1,2,34]
a2 = [1,2,4]
# 列表之间进行比较,以相同下标进行比较,从小到大进行比较,如果值相同则比较下一组元素,如果不同直接出结果
print(a1>a2)
@@ -0,0 +1,5 @@
c = [1,2,3,'1',True,2.1]
# 向列表中加入对象
c.append('henchman')
c.append('henchman1')
print(c)
@@ -0,0 +1,4 @@
b = [1,2,3,'1',True,2.1]
# 向列表中加入可枚举对象
b.extend([123])
print(b)
@@ -0,0 +1,4 @@
m = [1,2,3,4,5,6,7,8,9,10]
# 向指定位置插入对象
m.insert(1,123456789)
print(m)
@@ -0,0 +1,2 @@
c1 = [4,5,6]
print(c1*10)
@@ -0,0 +1,10 @@
scope=input("请输入成绩等级")
match scope:
case 'A':
print("一级")
case 'B':
print("二级")
case "C":
print("三级")
case "D":
print("四级")
+8
View File
@@ -0,0 +1,8 @@
s=0
i=1 #初始值
while i<=100: #条件
s+=i #语句块
i+=1
print(s)
print("-----")
print(i)
+5
View File
@@ -0,0 +1,5 @@
a=0
while a<10:
if a<1:
print('xxx')
continue