2 Star 0 Fork 0

zhuzihanniubi/zhuzihannb

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
任务一.py 6.12 KB
一键复制 编辑 原始数据 按行查看 历史
zhuzihannb 提交于 2023-12-18 15:57 . 1
Python 3.11.5 (v3.11.5:cce6ba91b3, Aug 24 2023, 10:50:31) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license()" for more information.
Python 3.11.5 (v3.11.5:cce6ba91b3, Aug 24 2023, 10:50:31) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license()" for more information.
num=123445
print(num)
123445
num=-12345
print(num)
-12345
num=1.23
print(num)
1.23
num=-1.23
print(num)
-1.23
str='this string \n belongs to python'
print(str)
this string
belongs to python
print("thsi is the python")
thsi is the python
list =['this','is',123,'a','number']
print(list)
['this', 'is', 123, 'a', 'number']
print(list[0])
this
print(list[-1])
number
print(list[1:3])
['is', 123]
list[2]=567
print(list)
['this', 'is', 567, 'a', 'number']
list.append('here')
print(list)
['this', 'is', 567, 'a', 'number', 'here']
list.insert(0,''now)
SyntaxError: invalid syntax. Perhaps you forgot a comma?
list.insert(0,'now')
print(list)
['now', 'this', 'is', 567, 'a', 'number', 'here']
list.remove('now')
list
['this', 'is', 567, 'a', 'number', 'here']
list.remove('is')
list
['this', 567, 'a', 'number', 'here']
name=['jam','lic','tom']
name.reverse()
name
['tom', 'lic', 'jam']
#反向
name=[1,2,3,5,4]
name.sort()
name
[1, 2, 3, 4, 5]
list=['this','is',123,'a','number']
list.index('a')
3
num=[12,12,21,21,1,1,1]
num.count(12)
2
num.pop
<built-in method pop of list object at 0x1055c7700>
num.pop()
1
num
[12, 12, 21, 21, 1, 1]
num={1,2,3,4,1,2,3,}
print(num)
{1, 2, 3, 4}
#集合
num={11,22,44,33,55}
num.reomve(55)
Traceback (most recent call last):
File "<pyshell#52>", line 1, in <module>
num.reomve(55)
AttributeError: 'set' object has no attribute 'reomve'. Did you mean: 'remove'?
num.reomve(22)
Traceback (most recent call last):
File "<pyshell#53>", line 1, in <module>
num.reomve(22)
AttributeError: 'set' object has no attribute 'reomve'. Did you mean: 'remove'?
num={11,22,44,33,55}
num.remove(11)
print(num)
{33, 22, 55, 44}
nun.pop
Traceback (most recent call last):
File "<pyshell#58>", line 1, in <module>
nun.pop
NameError: name 'nun' is not defined. Did you mean: 'num'?
num.pop()
33
num={11,22,33,55,44}
len(num)
5
num
{33, 22, 55, 11, 44}
num.clear()
num
set()
num
set()
num={11,33,22,44,55}
num.add(66)
num
{33, 66, 22, 55, 11, 44}
num
{33, 66, 22, 55, 11, 44}
number={99,88,77}
number.union(num)
{33, 66, 99, 11, 44, 77, 22, 55, 88}
dic={'name':'sim','age':12}
dic
{'name': 'sim', 'age': 12}
dic[name]
Traceback (most recent call last):
File "<pyshell#78>", line 1, in <module>
dic[name]
TypeError: unhashable type: 'list'
dic['name']
'sim'
dic['age']
12
dic
{'name': 'sim', 'age': 12}
len(dic)
2
#字典
dic
{'name': 'sim', 'age': 12}
dic.clear()
dic
{}
dic={'name':'sim','age':12}
dic
{'name': 'sim', 'age': 12}
dic_new=dic.copy()
dic_new
{'name': 'sim', 'age': 12}
dic
{'name': 'sim', 'age': 12}
dic_new
{'name': 'sim', 'age': 12}
value=dic.get('name')
print(value)
sim
value
'sim'
print(dic.get('geadasfs'))
None
dic
{'name': 'sim', 'age': 12}
]
list=dic.kleys()
Traceback (most recent call last):
File "<pyshell#103>", line 1, in <module>
list=dic.kleys()
AttributeError: 'dict' object has no attribute 'kleys'. Did you mean: 'keys'?
list=dic.keys()
print(list)
dict_keys(['name', 'age'])
dic
{'name': 'sim', 'age': 12}
list=dic.values()
print(list)
dict_values(['sim', 12])
#元组
tup=(12,34,56)
print(tup)
(12, 34, 56)
print(typ[1])
Traceback (most recent call last):
File "<pyshell#115>", line 1, in <module>
print(typ[1])
NameError: name 'typ' is not defined. Did you mean: 'tup'?
print(tup[1])
34
print(tup[0])
12
\
tup
(12, 34, 56)
len.tup
Traceback (most recent call last):
File "<pyshell#119>", line 1, in <module>
len.tup
AttributeError: 'builtin_function_or_method' object has no attribute 'tup'
len.tup()
Traceback (most recent call last):
File "<pyshell#120>", line 1, in <module>
len.tup()
AttributeError: 'builtin_function_or_method' object has no attribute 'tup'
len.(tup)
SyntaxError: invalid syntax
len(tup)
3
max(tup)
56
min(tup)
12
list
dict_values(['sim', 12])
list=['this','is',123,'a','number']
tuple(list)
('this', 'is', 123, 'a', 'number')
#判断
num=10
if num==10:
print('hello')
hello
num=12
if num==10:
print('hellw')
elif num<10:
SyntaxError: invalid syntax
]if num==10:
print('hellw')
elif num<10:
SyntaxError: unmatched ']'
num
12
if num ==10:
print('hellow')
elif num<10:
print('less than ')
else:
print('great than num')
great than num
num =10
name='sim'
if num ==10 and name=='sim':
print(''hello)
SyntaxError: invalid syntax. Perhaps you forgot a comma?
if num ==10 and name=='sim':
print('hello')
hello
list=['hi','my','name','is','sim']
for str in list:
print(str)
... hi
... my
... name
... is
... sim
...
...
... set={1,2,3,4,5,6,}
... for num in set:
... print(num)
...
...
... 1
... 2
... 3
... 4
... 5
... 6
...
...
... dic={'color':'red','name':'tom']
... SyntaxError: closing parenthesis ']' does not match opening parenthesis '{'
... dic={'color':'red','name':'tom'}
... for str in dic
... SyntaxError: incomplete input
... for str in dic:
... print(str)
...
...
... color
... name
...
... num= 1
... while number<10:
... print(num)
... num=num+1
...
...
... Traceback (most recent call last):
... File "<pyshell#183>", line 1, in <module>
while number<10:
TypeError: '<' not supported between instances of 'set' and 'int'
num=1
while num<10:
print(num)
num=num+1
1
2
3
4
5
6
7
8
9
>>>
>>>
>>>
>>> def fuc1():
... print('this is a fuc woithout pap')
...
...
>>> def fuc2(name='sim'):
... print('this is a fuc with a pap')
...
...
>>> fuc1()
this is a fuc woithout pap
>>> fuc2()
this is a fuc with a pap
>>>
>>>
>>> fuc1()
this is a fuc woithout pap
>>>
>>>
>>> def fuc1():
... print('this is a fuc without return')
...
...
>>> def fuc2(name='sim'):
... print('this is a fuc with a return')
... return name
...
>>> fuc1
<function fuc1 at 0x1055b6520>
>>> fuc1()
this is a fuc without return
>>> fuc2()
this is a fuc with a return
'sim'
SyntaxError: unmatched ']'
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhuzihanniubi/zhuzihannb.git
git@gitee.com:zhuzihanniubi/zhuzihannb.git
zhuzihanniubi
zhuzihannb
zhuzihannb
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385