标签:ike ext 循环 black ack player 语句 really like
magicians = [‘alice‘, ‘david‘, ‘carolina‘]
for magician in magicians:
print(magician)
magicians = [‘alice‘, ‘david‘, ‘carolina‘]
for magician in magicians:
print(magician.title() + ", that was a great trick!")
magicians = [‘alice‘, ‘david‘, ‘carolina‘]
for magician in magicians:
print(magician.title() + ", that was a great trick!")
print("I can‘t wait to see your next trick, " + magician.title() + ".\n")
magicians = [‘alice‘, ‘david‘, ‘carolina‘]
for magician in magicians:
print(magician.title() + ", that was a great trick!")
print("I can‘t wait to see your next trick, " + magician.title() + ".\n")
print("Thank you, everyone. That was a great magic show!")
magicians = [‘alice‘, ‘david‘, ‘carolina‘]
for magician in magicians:
print(magician)
magicians = [‘alice‘, ‘david‘, ‘carolina‘]
for magician in magicians:
print(magician.title() + ", that was a great trick!")
print("I can‘t wait to see your next trick, " + magician.title() + ".\n") # 此处忘记缩进,最后导致只在最后一次循环输出打印这一行内容
message = "Hello Python world!"
print(message)
magicians = [‘alice‘, ‘david‘, ‘carolina‘]
for magician in magicians:
print(magician.title() + ", that was a great trick!")
print("I can‘t wait to see your next trick, " + magician.title() + ".\n")
print("Thank you, everyone. That was a great magic show!") # 此处不需要缩进,不然结果每次循环都会打印输出此行内容
magicians = [‘alice‘, ‘david‘, ‘carolina‘]
for magician in magicians:
print(magician)
pizzas = [‘pepperoni‘, ‘hawaiian‘, ‘veggie‘]
for pizza in pizzas:
print(pizza)
print("\n")
for pizza in pizzas:
print("I like " + pizza + "pizza.")
print("\nI really love pizza!")
animals = [‘dog‘, ‘cat‘, ‘pig‘]
for animal in animals:
print(animal)
print("A " + animal + " will make a great pet.")
print("\nAny of these animals would make a great pet!")
for value in range(1, 5):
print(value) # 打印1-4
for value in range(1, 6):
print(value) # 打印1-5
numbers = list(range(1, 6))
print(numbers)
numbers = list(range(2, 11, 2))
print(numbers)
squares = []
for value in range(1, 11):
square = value**2
squares.append(square)
print(squares)
squares = []
for value in range(1, 11):
squares.append(value**2)
print(squares)
digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print(sum(digits))
squares = [value**2 for value in range(1, 11)]
print(squares)
players = [‘charles‘, ‘martina‘, ‘michael‘, ‘florence‘, ‘eli‘]
print(players[0:3])
players = [‘charles‘, ‘martina‘, ‘michael‘, ‘florence‘, ‘eli‘]
print(players[1:4])
players = [‘charles‘, ‘martina‘, ‘michael‘, ‘florence‘, ‘eli‘]
print(players[:4])
players = [‘charles‘, ‘martina‘, ‘michael‘, ‘florence‘, ‘eli‘]
print(players[2:])
players = [‘charles‘, ‘martina‘, ‘michael‘, ‘florence‘, ‘eli‘]
print(players[-3:])
players = [‘charles‘, ‘martina‘, ‘michael‘, ‘florence‘, ‘eli‘]
print("Here are the first three players on my team:")
for player in players[:3]:
print(player.title())
my_foods = [‘pizza‘, ‘falafel‘, ‘carrot cake‘]
friend_foods = my_foods[:]
print("My favorite foods are:")
print(my_foods)
print("\nMy fiend‘s favorite foods are:")
print(friend_foods)
my_foods = [‘pizza‘, ‘falafel‘, ‘carrot cake‘]
friend_foods = my_foods[:]
my_foods.append(‘cannoli‘)
friend_foods.append(‘ice cream‘)
print("My favorite foods are:")
print(my_foods)
print("\nMy fiend‘s favorite foods are:")
print(friend_foods)
my_foods = [‘pizza‘, ‘falafel‘, ‘carrot cake‘]
friend_foods = my_foods # 这样会得到两个一样的列表
my_foods.append(‘cannoli‘)
friend_foods.append(‘ice cream‘)
print("My favorite foods are:")
print(my_foods)
print("\nMy fiend‘s favorite foods are:")
print(friend_foods)
dimensions = (200, 50)
print(dimensions[0])
print(dimensions[1])
dimensions = (200, 50)
dimensions = (666, 66)
for dimension in dimensions:
print(dimension)
dimensions = (200, 50)
print("Original dimensions:")
for dimension in dimensions:
print(dimension)
dimensions = (400, 100)
print("\nModified dimensions:")
for dimension in dimensions:
print(dimension)
numbers = range(1, 21) # 或者用numbers = list(range(1, 21))
for number in numbers:
print(number)
numbers = range(1, 1000001)
print(min(numbers))
print(max(numbers))
print(sum(numbers))
list = range(1, 20, 2)
for number in list:
print(number)
list = range(3, 33, 3)
for number in list:
print(number)
list = range(1, 11)
numbers = []
for n in list:
numbers.append(n**3)
print(numbers)
numbers = [n**3 for n in range(1, 11)]
print(numbers)
numbers = range(1, 11)
print("\nThe first three items in the list are:\n")
print(numbers[:3])
for n in numbers[:3]:
print(n)
print("\nThe items from tne middle of the list are:\n")
print(numbers[3:6])
for n in numbers[3:6]:
print(n)
print("\nThe last three items in the list are:\n")
print(numbers[-3:])
for n in numbers[-3:]: # 要取最后一个元素,后面只能用空;如果用-1,无法打印最后一个元素
print(n)
favorite_pizzas = [‘pepperoni‘, ‘hawaiian‘, ‘veggie‘]
friend_pizzas = favorite_pizzas[:]
favorite_pizzas.append("meat lover‘s")
friend_pizzas.append(‘pesto‘)
print("\nMy favorite pizzas are:\n")
for pizza in favorite_pizzas:
print(pizza)
print("\nMy friend‘s favorite pizzas are:\n")
for pizza in friend_pizzas:
print(pizza)
my_foods = [‘pizza‘, ‘falafel‘, ‘carrot cake‘]
friend_foods = my_foods[:]
my_foods.append(‘cannoli‘)
friend_foods.append(‘ice cream‘)
print("My favorite foods are:")
for food in my_foods:
print(food)
print("\nMy fiend‘s favorite foods are:")
for food in friend_foods:
print(food)
menu_items = (‘rockfish sandwich‘, ‘ice cream‘, ‘halibut nuggets‘, ‘smoked salmon chowder‘, ‘salmon burger‘, ‘crab cakes‘)
print("\nYou can choose the following menu items:")
for food in menu_items:
print("- " + food)
print(menu_items[0])
menu_items = (‘rockfish sandwich‘, ‘ice cream‘, ‘halibut nuggets‘, ‘smoked salmon chowder‘, ‘black cod tips‘, ‘king crab legs‘)
print("\n Our menu has been updated.")
print("\nYou can choose the following items:")
for food in menu_items:
print("- " + food)
标签:ike ext 循环 black ack player 语句 really like
原文地址:https://www.cnblogs.com/XDZ-TopTan/p/13211979.html