Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson16-diy1
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
b3e72836
authored
Apr 08, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
a8b508cb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
62 deletions
binary_search.py
binary_search.py
View file @
b3e72836
# 元组,列表,字典,
#元组
# a=(1,12,3,4,5,1,2,2,3,1)#有序不可更改
# b=(12,23,34)
# print(a[-1::-3])
# print(len(a))
# print(a[1])
# a=(1)
# b=(2,)
# print(type(a))
# print(type(b))
# a=list(a)
# a[1]=2
# a=tuple(a)
# print(a)
# c=a*2
# print(c)
#count() index()
# print(a.count(1))
# print(a.index(3))
#
#
元组,列表,字典,
#
#
元组
#
#
a=(1,12,3,4,5,1,2,2,3,1)#有序不可更改
#
#
b=(12,23,34)
#
#
print(a[-1::-3])
#
#
print(len(a))
#
#
print(a[1])
#
#
a=(1)
#
#
b=(2,)
#
#
print(type(a))
#
#
print(type(b))
#
#
a=list(a)
#
#
a[1]=2
#
#
a=tuple(a)
#
#
print(a)
#
#
c=a*2
#
#
print(c)
#
#
count() index()
#
#
print(a.count(1))
#
#
print(a.index(3))
a
=
[
'83'
,
'ad'
,
'b5'
,
'c712'
,
'6'
,
'12'
,
'3'
,
'554'
]
# a.insert(1,90) a.append(1212)
# a.pop(索引) a.remove(元素) del clear()
# a.clear()
# del a
# print(a)
# b=a.copy()
# c=list(a)
# d=a
# print(b,c,d,a)
#
a=['83','ad','b5','c712','6','12','3','554']
#
#
a.insert(1,90) a.append(1212)
#
#
a.pop(索引) a.remove(元素) del clear()
#
#
a.clear()
#
#
del a
#
#
print(a)
#
#
b=a.copy()
#
#
c=list(a)
#
#
d=a
#
#
print(b,c,d,a)
# b=['1','2']
# # c=a+b
# a.extend(b)
# print(a)
#
#
b=['1','2']
# #
#
c=a+b
#
#
a.extend(b)
#
#
print(a)
# count() extend() index() reverese() sort()
# a.sort(reverse=False,key=func())#默认是false,True
# print(a)
#
#
count() extend() index() reverese() sort()
#
#
a.sort(reverse=False,key=func())#默认是false,True
#
#
print(a)
# cars=[
# {'car':'bmw','year':1661},
# {'car':'benz','year':1990},
# {'car':'volvo','year':1668},
# {'car':'rr','year':161}
# ]
# def func(a):
# return a['year']
#
#
cars=[
#
#
{'car':'bmw','year':1661},
#
#
{'car':'benz','year':1990},
#
#
{'car':'volvo','year':1668},
#
#
{'car':'rr','year':161}
#
#
]
#
#
def func(a):
#
#
return a['year']
# cars.sort(reverse=True,key=func)
# print(cars)
#
#
cars.sort(reverse=True,key=func)
#
#
print(cars)
a
=
{
'a'
:
1
,
'b'
:
2
}
b
=
{
1
,
2
,
4
,
2
,
1
,
2
,
3
,
1
,
1
,
1
,
1
,
1
}
#
a={'a':1,'b':2}
#
b={1,2,4,2,1,2,3,1,1,1,1,1}
# c={2,1,3,4}
# if b==c:
# print(1)
# for i in b:
# print(i)
# for i in range(len(b)):
# print(b[i])
# c=[1,2,3]
# d=(1,2,3)
#
#
c={2,1,3,4}
#
#
if b==c:
#
#
print(1)
#
#
for i in b:
#
#
print(i)
#
#
for i in range(len(b)):
#
#
print(b[i])
#
#
c=[1,2,3]
#
#
d=(1,2,3)
# add() updata() remove() del clear() union()
字典,
1
key
1
value
2
items
()
\ No newline at end of file
# # add() updata() remove() del clear() union()
# 字典,
# 1key 1value 2 items()
list
=
[]
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