Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson23-diy2
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4e9e96f4
authored
Dec 31, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
828ed1b1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
258 additions
and
5 deletions
1.py
2.py
3.py
4.py
cj.csv
my_csv.py
1.py
0 → 100644
View file @
4e9e96f4
# def a(x,y,z):
# print(x,y,z)
# a(2,3,4)#位置实参
# a(x=3,y=4,z=5)#关键字实参
# a(4,y=5,z=6)
# a(4,5,z=6)
# a(x=4,5,z=6)
# a(x=4,y=5,6)
# def a(y,x=1):
# print(x,y)
# a(3,2)
# my=lambda a,b=3: a*b
# print(my(4,3))
# def c(a,b):
# return a*b
# print(c(2,3))
# def a():
# print(1)
# a()
# def demo(n):
# return n*2
# print(demo(demo(demo(1))))
# x=1
# def demo():
# global x
# x=2
# print(x)
# demo()
# print(x)
# def f(s):
# t=0
# max=0
# for i in s:
# if i>='0' and i<='9':
# t+=1
# else:
# if t>max:
# max=t
# t=0
# print(max)
# list='2134abc47895cd6d'
# f(list)
# def a(n):
# if n==1:
# return 1
# s=a(n-1)+n
# return s
# print(a(100))
# a=[1,2,31,2,1]
# b=[]
# for i in a:
# b.insert(-1,i)
# print(b)
a
=
[
i
for
i
in
range
(
10
)]
print
(
a
)
\ No newline at end of file
2.py
0 → 100644
View file @
4e9e96f4
# def a(a,b,c):
# print('123'+str(a)+str(b)+str(c))
# a(3,2,1)#位置实参
# a(a=4,b=3,c=2)#关键字实参
# a(4,b=4,c=4)
# a(5,5,c=5)
#形参实参
# def a(x,y=2):
# print(x,y)
# a(1,7)
#速度 利用率 可读性 复杂度
# bbb=lambda a,b=2:a*b
# def a(a,b):
# print(a*b)
# a(2,2)
# def demo(n):
# return n*2
# print(demo(demo(demo(1))))
# a='123'
# def f():
# global a
# a='12'
# print(a)
# print(a)
# f()
# global nonlocal
# count=12
# def add():
# count=1
# def fun():
# nonlocal count
# print(count)
# count+=2
# return fun
# a=add()
# a()
# a()
def
f1
():
x
=
5
y
=
6
print
(
x
+
y
)
def
f2
():
y
=
1
print
(
x
+
y
)
f1
()
f2
()
# def a(n):
# if n==1:
# return 1
# else:
# return a(n-1)+n
# print(a(1000))
ans
=
0
def
fu
(
a
,
b
,
x
=
1
):
if
b
==
1
:
return
6
global
ans
ans
+=
fu
(
a
-
x
,
b
-
1
,
2
)
return
ans
print
(
fu
(
5
,
74
,
3
))
\ No newline at end of file
3.py
0 → 100644
View file @
4e9e96f4
# #如何将字符串倒叙输出
# a=input("请输入长度小于80的一个字符串")#用input函数获取一个字符串
# #字符串转化列表,列表转化为字符串
# list=[] #建立一个空的列表,
# for i in a:#循环遍历字符串a
# list.insert(0,i) #将a中的每个小字符添加到列表的第一个位置,返回一个倒叙的列表
# newa=''.join(list)#用join函数将列表抓换为字符串
# print(newa)#打印出新的字符串
# #2,
# a=input("请输入长度小于80的一个字符串")
# newa='' #创建一个空的字符串
# for i in a:#循环遍历a
# newa=i+newa
# print(newa)
# a=['beijing','shanghai','huzhou','acc']
# f=open("city.csv",'a')
# f.write(','.join(a))
# f.close()
# a=[
# ['张三','98','123','124'],
# ['李四','98','123','124'],
# ['王五','98','123','124']
# ]
# f=open('cj.csv','w')
# for i in a:
# f.write(",".join(i)+'\n')
# f.close()
# f=open('cj.csv','r')
# c=[]
# for i in f:
# c.append(i.strip("\n").split(','))
# f.close()
# print(c)
# with open('123.csv','w',newline='') as f:
# a=csv.writer(f)
# a.writerow(['color','red'])
# try:
# a=int("输入一个整数")
# b=int("输入一个整数")
# m=a/b
# print('商是:',m)
# except ValueError:
# print("输入的不是数字")
# except ZeroDivisionError:
# print('除数为0')
# except:
# print('其他错位')
# finally:
# print('程序结束')
# a=[1,3,2,5,8,7,6,0]
# for i in range(len(a)-1):
# for j in range(len(a)-1):
# if a[j]>a[j+1]:
# a[j],a[j+1]=a[j+1],a[j]
# print(a)
A
=
[
64
,
25
,
0
,
22
,
1
]
for
i
in
range
(
len
(
A
)):
#循环的次数
min_idx
=
i
#自定义最小的是哪个数据的索引
for
j
in
range
(
i
+
1
,
len
(
A
)):
#让其跟后面的数据进行比较
if
A
[
min_idx
]
>
A
[
j
]:
#如果最小的数不是min_idx,就改成j。
min_idx
=
j
A
[
i
],
A
[
min_idx
]
=
A
[
min_idx
],
A
[
i
]
print
(
A
)
\ No newline at end of file
4.py
0 → 100644
View file @
4e9e96f4
# # print(bin(1238))
# # print(eval('9.9'))
# # a=[4,1,34,2,412,41,24]
# # for i,j in enumerate(a):
# # print(i,j)
# all() 全是真就是真,否则假 all([]) all(())
# any() 全是假就是假,否则真 any([]) any(())
# a.split("")
# b=''.join(a)
# try 尝试执行这个代码
# except
# else:
# finally
# a=[23,235,1,5,4,23,5,1,0]
# for i in range(len(a)):
# for j in range(len(a)-1-i):
# if a[j]>a[j+1]:
# a[j],a[j+1]=a[j+1],a[j]
# print(a)
# print(hex(100))
\ No newline at end of file
cj.csv
0 → 100644
View file @
4e9e96f4
,98,123,124
,98,123,124
,98,123,124
my_csv.py
View file @
4e9e96f4
import
csv
int
(
'5'
)
str
(
5
)
print
(
5
)
a
=
input
(
"你是谁"
)
b
=
1
import
turtle
forward
(
100
)
pen
.
hideturtle
()
turtle
.
done
()
penup
()
pendown
()
pen
.
color
(
'red'
)
pen
.
fillcolor
(
'red'
)
pen
.
begin_fill
()
pen
.
end_fill
()
pen
.
shape
(
'turtle'
)
pen
.
circle
(
50
)
pen
.
dot
(
100
)
bgcolor
(
"yellow"
)
clear
()
data
=
[[
"姓名"
,
"语文"
,
"数学"
,
"英语"
],
[
"小贝"
,
98
,
99
,
92
],
[
"聪聪"
,
95
,
91
,
95
]]
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment