Lately, I've been, I've been losing sleep
Dreaming about the things that we could be
But baby, I've been, I've been playing hard,
Sitting, no more counting dollars
We'll be counting stars, yeah we'll be counting stars
I see this life like a swinging vine
Swing my heart across the line
And my face is flashing signs
Seek it out and you shall find
Oh, but I'm not that old
Young, but I'm not that bold
I don't think the world is sold
I'm just doing what we're told
I feel something so right
Doing the wrong thing
I feel something so wrong
Doing the right thing
I could lie, could lie, could lie
Everything that kills me makes me feel alive
今天老西儿用python数星星,一开始数了21颗,后来越数越多,越数越多……从1数到了1000000!自己数,手指头不够用啊!最后从1加到1000000,一共是多少呢?哎呀头痛!
作业来源:《Python编程:从入门到实践》
图源:马蜂窝
4-3 21 stars
for value in range(1,21):
print(value)
图源:堆糖
4-4 millionaire
stars = list(range(1,1000001))
for value in stars:
print(value)
图源:astroarts
4-5 counting stars
print(min(stars))
print(max(stars))
print(sum(stars))
input()
运行效果:
▼
领取专属 10元无门槛券
私享最新 技术干货