numbers = list(range(1,10))
print(numbers)
num = []
for number in numbers:
if number == 1:
num.append(str(number) + 'st')
elif number == 2:
num.append(str(number) + 'nd')
elif number == 3:
num.append(str(number) + 'rd')
else:
num.append(str(number) + 'th')
......................
阅读全部 | 2021年7月10日 16:45
numbers = list(range(1,10))
print(numbers)
for number in numbers:
if number == 1:
print(str(number) + 'st')
elif number == 2:
print(str(number) + 'nd')
elif number == 3:
print(str(number) + 'th')
print("\n")
阅读全部 | 2021年7月10日 16:45
current_users = ['ergou','Tiezhu','Shitou','admin','erya']
new_users = ['Ergou','xiaofeng','shitou','shuanzi','dongzi']
linshi = [] #临时储存全部小写current_users里的元素
#小写的current_users里的元素
for name in current_users:
linshi.append(name.lower())
for name in new_users:
if name.lower() in linshi:
print(name + "已被使用,请输入别的用户名!!")
else:
print(name + "该用户名未被使用!!")
......................
阅读全部 | 2021年7月10日 16:37
names = []
if names:
for name in names:
if name == 'admin':
print("Hello " + name + ',would you like to see to a status resport?')
else:
print("Hello " + name + ",thank you for logging in again.")
else:
print("We need to find some users!!")
print("\n")
阅读全部 | 2021年7月10日 16:28
names = ['ergou','tiezhu','shitou','admin','erya']
for name in names:
if name == 'admin':
print("Hello " + name + ",would you like to see a status report?")
else:
print("Hello " + name + ",thank you for logging in again.")
阅读全部 | 2021年7月10日 16:20
alien_color = ['green']
if 'green' in alien_color:
print("恭喜你获得了5个点!!")
elif 'yellow' in alien_color:
print("恭喜你获得10个点!!")
else:
print("恭喜你获得15个点!!")
print("\n")
print("版本2")
alien_color = ['red']
if 'green' in alien_color:
print("恭喜你获得了5个点!!")
......................
阅读全部 | 2021年7月10日 16:14
age = int(input("Please input your age:\n"))
if age < 2:
print("原来你是个婴儿!!")
elif age < 4:
print("原来你是蹒跚学步!!")
elif age < 20:
print("原来你是青少年!!")
elif age < 65:
print("原来你是成年人!!")
else:
print("原来你是老年人!!")
阅读全部 | 2021年7月10日 15:59
def make_car(manufacturer,model,**type_info):
"""创建一个字典,其中包含我们知道的有关用户的一切"""
profile = {}
profile['manufacturer'] = manufacturer
profile['model'] = model
for key,value in type_info.items():
profile[key] = value
return profile
car = make_car('subaru','outback',color = 'blue',tow_package = True)
print(car)
阅读全部 | 2021年7月6日 21:35
def make_car(manufacturer,model,**type_info):
"""创建一个字典,其中包含我们知道的有关用户的一切"""
profile = {}
profile['manufacturer'] = manufacturer
profile['model'] = model
for key,value in type_info.items():
profile[key] = value
return profile
car = make_car('subaru','outback',color = 'blue',tow_package = True)
print(car)
阅读全部 | 2021年7月6日 21:35
magicians = ['ergou','qiqi','shitou']
great_magicians = []
def make_great(magicians,great_magicians):
while magicians:
magician = magicians.pop()
great_magician = 'the Great' + magician
great_magicians.append(great_magician)
def show_magicianslis(great_magicians):
for name in great_magicians:
print(name)
......................
阅读全部 | 2021年7月6日 21:33