#简单python操作函数
# del函数
'''
motorcycles =['honda','yamaha','suzuki']
print(motorcycles)
del motorcycles[0]
print(motorcycles)
#append函数
motorcycys=[]
motorcycys.append('honda')
motorcycys.append('yamaha')
motorcycys.append('yamaha')
print(motorcycys)
#insert 函数
motorcycles.insert(0,'ducati')
print(motorcycles)
# pop函数:删除列表末尾元素
motorcycles1 = ['honda','yamaha','suzuki','xiaoyu']
print(motorcycles1)
popped_motorcycles1 = motorcycles1.pop()
print(motorcycles1)
print(popped_motorcycles1)
# pop函数:删除列表任意元素(与del的区别在于删除的元素还要不要用)
motorcycles1 = ['honda','yamaha','suzuki','xiaoyu']
print(motorcycles1)
popped_motorcycles1 = motorcycles1.pop(1)
print(motorcycles1)
print(popped_motorcycles1)
#remove函数,从列表中删除某值但是不知道其索引,只删除第一个指定的值
motorcycles1 = ['honda','yamaha','suzuki','xiaoyu','suzuki']
print(motorcycles1)
motorcycles1.remove('suzuki')
print(motorcycles1)
#sort 函数,对列表进行永久排序(字符倒叙正序)
cars = ['bmw','audi','toyota','subaru']
print(cars)
cars.sort()
print(cars)
cars.sort(reverse=True)
print(cars)
'''
#sorted()对列表进行临时排序 len计数是从1开始
cars = ['bmw','audi','toyota','subaru']
print(cars)
print(sorted(cars))
print(cars)
cars.reverse()
print(cars)
print(len(cars))
>>> ablum =['black star,'zhou jian',25,True]
SyntaxError: invalid syntax
>>> ablum =['black star','zhou jian',25,True]
>>> ablum.append('new song')
>>> print(ablum[0],ablum[-1])
black star new song
>>> 'black star' in ablum
True
>>> the_end ='eddie'
>>> name ='eddie'
>>> the_end == name
True
>>> the_end is name
True
>>> bool(0)
False
>>> bool([])
False
>>> bool('')
False
>>> bool(False)
False
>>> bool(None)
False
>>> bool(20)
True
>>> a_thing =None
>>> print(a_string)
Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
print(a_string)
NameError: name 'a_string' is not defined
>>> print(a_thing)
None
>>> 1<3 and 2<5
True
>>> 2<3 or 3<1
True
>>>