高级编程技术,第二周

3.1

names = ['Mipha', 'Daruk', 'Revali', 'Urbosa', 'Link', 'Zelda']
print(names[0])
print(names[1])
print(names[2])
print(names[3])
print(names[4])
print(names[5])

3.2

names = ['Mipha', 'Daruk', 'Revali', 'Urbosa', 'Link', 'Zelda']
print(names[0] + ",Hello!")
print(names[1] + ",Hello!")
print(names[2] + ",Hello!")
print(names[3] + ",Hello!")
print(names[4] + ",Hello!")
print(names[5] + ",Hello!")

3.4

guests = ["link", "Mario", "Pikachu",  "Kirby", "Samus"]
for guest in guests:
	print(guest + ",welcome to our party!")

3.5 

guests = ["link", "Mario", "Pikachu",  "Kirby", "Samus"]
print("Samus can't be present")
guests[4] = "Mewtwo"
for guest in guests:
	print(guest + ",welcome to our party!")

3.6

guests = ["link", "Mario", "Pikachu",  "Kirby", "Samus"]
print("I've find a bigger table")
guests.insert(0, 'Zelda')
guests.insert(2, 'Peach')
guests.append('Marth')
for guest in guests:
	print(guest + ",welcome to our party!")

========================================================================

4.1 

pizzas = ['Margherita', 'Margherita', 'Romana']
for pizza in pizzas:
	print(pizza)
for pizza in pizzas:
	print("I like " + pizza)
print("I really like pizza!")

4.2

animals = ['tiger', 'lion', 'bear']
for animal in animals:
	print(animal)
for animal in animals:
	print(animal + " is fierce.")
print("All of these animals are fierce")

4.3

for value in range(1,21):
	print(value)

4.4

numbers = list(range(1,1000001))
print(numbers)
4.5
numbers = list(range(1,1000001))
print(min(numbers))
print(max(numbers))
print(sum(numbers))

4.6

numbers = list(range(1,21,2))
for n in numbers:
	print(n)

4.7

numbers = list(range(3,31,3))
for n in numbers:
	print(n)

4.8

l = []
for n in range(1,11):
	t = n**3
	l.append(t)
for n in l:
	print(n)

4.9

l = [num**3 for num in range(1,11)]
print(l)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值