admin 发表于 2023-7-25 15:12:28

7月25日上课内容

st="Hello world"
ea=" china"
print(st)
print(len((st)))#获取字符串长度
print(max(st))   #求出最大ASCii码
print(min(st))
print(st+ea)# Hello world china
st2 = sorted(st)# 转化成字符列表,并进行排序
print(st2)
print(st.index('or'))#查找字符串或者字符出现的位置    7
print(st.count('l'))   #统计字符的个数   3

#新p1的第四五六章

a=18
name="小明"
pi=3.14159
#格式化输出
print('%s今年%4d岁'%(name,a))
print("保留2位小数%.2f"%pi)
print(f"{name}今年{a}岁")

st = "7 8 9"
a, b, c = st.split()# 字符串连续赋值
print(a, b, c)
d, e, f = map(int, st.split())# 整数连续赋值
y_list = list(map(int, st.split()))# 整数列表
print(y_list)


#元组
tuple1=()
print(type(tuple1))
list1=
tuple2=tuple(list1)
print(tuple2)
print(tuple2[-1])

tuple3 = ('a','1','4', 'b', 'c', 'd', 'b', 'c', 'd')

print(tuple3.index('d'))
print(tuple3.count('c'))
tuple4 = sorted(tuple3)
print(tuple4)

#p3第四第五章tuple

num = {'one': 1, 'two': 2, 'three': 3}# 键值对   键:值
print(num)
num["你好"]=8
print(num)
del num['one']#删除内容

num.clear()#清空字典
student1 = {'姓名': '卢旭', '年龄': 11, '语文': 98}# 键值对   键:值
print(student1['姓名'])





admin 发表于 2023-7-25 15:24:56

#p3第四第五章tuple

num = {'one': 1, 'two': 2, 'three': 3}# 键值对   键:值
print(num)
num["你好"]=8
print(num)
del num['one']#删除内容

num.clear()#清空字典
student1 = {'姓名': '卢旭', '年龄': 11, '语文': 98}# 键值对   键:值
print(student1['姓名'])

周星宇 发表于 2023-7-25 15:40:01

st='Hello world'
ea=' china'
print(st)
print(len(st)) #获取字符串长度
print(max(st)) #求出ASCII码统计最高值
print(min(st)) #求出ASCII码统计最低值
print(st+ea) #字符串相加
st2=sorted(st) #转换成字符串列表,并进行排序
print(st2)
print(st.index('or')) #查找字符串或字符出现的位置
print(st.count('l')) #统计字符个数
#新p1的第四五六章
a=18
name="小明"
pi=3.14159265354
#格式化输出
print('%s今年%4d岁' %(name,a))
print(f"{name}今年{a}岁")
print("保留2位小数%.2f" %pi)

st="7 8 9"
a,b,c=st.split()
print(a,b,c)
d,e,f=map(int,st.split5())#整数连续赋值
y_list=list(map(int,st.split()))#整数列表
print(y_list)
#p3第四五章
num = {'one':1,'two':2,'three':3}#键值对 键:值
print(num)
num["你好"]=8
print(num)
del num['one']#删除内容
num.clear()
student1={'姓名':'小明','年龄':'92','身高':180}
print(student1['姓名'])

卢旭 发表于 2023-7-25 15:44:15

st='Hello world'
ea=' china'
print(st)
print(len((st)))#获取字符串长度
print(max(st))   #求出最大ASCii码
print(min(st))
print(st+ea)# Hello world china
st2 = sorted(st)# 转化成字符列表,并进行排序
print(st2)
print(st.index('or'))#查找字符串或者字符出现的位置    7
print(st.count('l'))   #统计字符的个数   3
a = 18
name = '小明'
pi = 3.14159
#格式化输出
print('%s今年%4d岁'%(name,a))
print('保留2位小数%.2f'%pi)
print(f'{name}今年{a}岁')
st = '7 8 9'
a, b, c = st.split()# 字符串连续赋值
print(a, b, c)
d, e, f = map(int, st.split())# 整数连续赋值
y_list = list(map(int, st.split()))# 整数列表
print(y_list)

卢旭 发表于 2023-7-25 15:45:17

num = {'one': 1,'two': 2,'three': 3}
print(num)
num['你好'] = 8
print(num)
del num['one']#删除内容
num.clear()
student = {'姓名': '卢旭','年龄': 11,'语文': 96,'数学': 99,'英语': 100}
print(student['姓名'])
print(student['年龄'])
print(student['语文'])
print(student['数学'])
print(student['英语'])

董培钰 发表于 2023-7-25 15:45:40

st = "Hello world"
ea = " china"
print(st)
print(len((st)))# 获取字符串长度
print(max(st))# 求出最大ASCii码
print(min(st))
print(st+ea)# Hello world china
st2 = sorted(st)# 转化成字符列表,并进行排序
print(st2)
print(st.index('or'))# 查找字符串或者字符出现的位置    7
print(st.count('l'))# 统计字符的个数   3

a = 18
name = "小明"
pi = 3.14159
#格式化输出
print('%s今年%4d岁' % (name, a))
print("保留2位小数%.2f" % pi)
print(f"{name}今年{a}岁")

st = "7 8 9"
a, b, c = st.split()# 字符串连续赋值
print(a, b, c)
d, e, f = map(int, st.split())# 整数连续赋值
y_list = list(map(int, st.split()))# 整数列表
print(y_list)

num = {'one': 1, 'two': 2, 'three': 3}# 键值对 键:值
print(num)
num["你好"] = 8
print(num)
del num['one'] # 删除内容

num.clear() # 清空字典
student1 = {'姓名': '卢旭', '年龄': 11, '语文': 98}# 键值对 键:值
print(student1['姓名'])

杨子轩 发表于 2023-7-25 15:45:43

st="hello word"
ea=" China"
print(st)
print(len(st)) #获取字符串长度
print(max(st)) #求出最大ASCii码
print(max(st))
print(st+ea)# hello word China
st2 = sorted(st) #转化成字符列表,并且进行排序
print(st2)
print(st.index('or')) #查找字符串或者字符出现的位置   7
print(st2.count('1'))#统计字符的个数    3



a=18
name="小明"
pi=3.14159
#格式化输出
print('%s今年4d岁'%(name,a))
print("保留2位小数%。2f"%pi)
print(f"{name}今年{a}岁")


st = "7 8 9"
a, b, c = st.split()# 字符串连续赋值
print(a, b, c)
d, e, f = map(int, st.split())#整数连续赋值
y_list = list(map(int, st.split()))#整数列表
print(y_list)

杨子轩 发表于 2023-7-25 15:46:14

#P3第4第5
num={'one':1,'two':2'three':3} #键值对    键:值
print(num)
num["你好"]=8
print(num)
del num['one'] #删除内容

num.clear() #清空字典
student1 = {'姓名':'杨子轩','年龄':11,'语文':100} #键值对      键:值
print(student1['姓名'])

杜王睿 发表于 2023-7-25 15:48:29

st="hello world"
ea="china"
print(st)
print(len((st)))
print(max((st)))
print(min((st)))
print(st+ea)
st2=sorted(st)
print(st2)
print(st.index('or'))
print(st.count('1'))

a=18
name='小明'
pi=3.14159
print('%s今年%4d岁'%(name,a))
print("保留2位小数%2f"%pi)
print(f"{name}今年{a}岁")

杜王睿 发表于 2023-7-25 15:49:09

#p3 第四第五tuple
num={'one':1,'two':2,'three:'3}
print(num)
num["你好"]=8
print(num)
del num['one']#删除内容
num.clear()#清空字典
student={student1 = {'姓名': '杜王睿', '年龄': 13, '语文':'你猜'}# 键值对   键:值
print(student1['姓名'])}
页: [1] 2
查看完整版本: 7月25日上课内容