【python】第三次课作业

3-1~3-3

names = ['Karry', 'Roy', 'Jackson']
print(names)
print(names[0]+", nice to meet you!")
print(names[1]+", nice to meet you!")
print(names[2]+", nice to meet you!")

3-4~3-7

names = ['Karry', 'Roy', 'Jackson']
print(names[0]+", "+names[1]+", "+names[2])
print("Would you like to have dinner with me?")
print("Sorry! Jackson can't.")
names[2] = 'Mary'
print(names[0]+", "+names[1]+", "+names[2])
print("Would you like to have dinner with me?")
print("I found a bigger dining-table.")
names.insert(0, 'leo')
names.insert(1, 'nemo')
names.append('lucky')
for name in names:
	print(name)
print("Would you like to have dinner with me?")
print("I'm afraid i can only invite two friends for dinner.")
print(names.pop(0)+", sorry!")
print(names.pop(0)+", sorry!")
print(names.pop(0)+", sorry!")
print(names.pop(0)+", sorry!")
print(names[0]+", would you like to have dinner with me?")
print(names[1]+", would you like to have dinner with me?")
print("I totally invited ")
print(len(names))
print("friedns for my dinner.")
del names[0]
del names[0]
print("The list has become empty.")
print(names)

3-8~3-9

places = ['asd', 'fer', 'rtvd', 'czxds', 'jytyy', 'bfde']
print(places)
print(sorted(places))
print(places)
print(sorted(places, reverse = True))
print(places)
places.reverse()
print(places)
places.reverse()
print(places)
places.sort()
print(places)
places.sort(reverse = True)
print(places)


猜你喜欢

转载自blog.csdn.net/karroyzgj/article/details/79561629
今日推荐