fibs[-1]表示fibs列表的最后一个元素,fibs[-2]表示倒数第二个元素。
fibs.append(fibs[-2] + fibs[-1])表示将fibs列表最后两个元素相加,然后添加到列表的末尾。
for i in range(8): 表示上述操作重复8次,这样就得到了最终10个元素的结果。
斐波那契数列指的是这样一个数列 0, 1, 1, 2, 3, 5, 8, 13,特别指出:第0项是0,第1项是第一个1。从第三项开始,每一项都等于前两项之和。
def fib(num):
fibs=[0,1]
#num=input('请输入婓波那契数列中的数据个数:')。
for i in range(int(num)-2):。
fibs.append(fibs[-2]+fibs[-1])。
print(fibs)
print(fibs[-2])。
fib(10)
在数学上
斐波那契数列以如下被以递推的方法定义:F(0)=0,F(1)=1, F(n)=F(n - 1)+F(n - 2)(n ≥ 2,n ∈ N*)在现代物理、准晶体结构、化学等领域,斐波纳契数列都有直接的应用,为此,美国数学会从 1963 年起出版了以《斐波纳契数列季刊》为名的一份数学杂志,用于专门刊载这方面的研究成果。
先上修改后的代码:
def fibs(num):
result = [0, 1]。
for i in range(2, num):。
result.append(result[-2] + result[-1])。
return result。
print(fibs(9))
1、修改for循环的范围,改为从2~num。
2、计算式应该是result[-2] + result[-1]。
3、return result应该是和for对齐的,不然执行一次for就返回了。
请看结果:
the warning-eminem。
Only reason I dissed you in the first place is because you denied seeing me, 老子起先骂你只是因为你否认我的存在,
Now Im pissed off. 现在我是真的毛了!
Sit back homey relax, infact grab a six pack, kick back while I kick facts, 老兄坐低别紧张 半打啤酒提好 当我爆猛料时你可要放松。
Yeah Dre sick track, perfect way to get back 没错,DRE的牛B单曲的最好回归。
Wanna hear something wick wack? 想不想听些鸟事?
I got the same exact tat thats on Nicks back 我和NICK背上有一模一样的纹身!
Im obsessed now, 我现在着迷了?
Oh gee, is that supposed to be me in the video with the goatee, 噢,天呐!那出现在录影带上面的胡子男本该是我?
Wow Mariah, didnt expect her to go balls out, 我可不想倾尽全力,
Bitch, shut the fuck up before I put all them phone calls out, 贱货,最好闭上你的鸟嘴,。
You made to my house when you was wild n out before Nick, 小心我把你在NICK之前打给我家那些狂野电话统统放出来。
When you was on my dick and give you somethin to smile about, 当你坐在我的DIAO上,我给你些东西让你笑,
How many times you fly to my house? Still trying to count, 你飞去我家有多少次?是不是都难以计数?
Better shut your lying mouth if you dont want Nick finding out, 如果你不想NICK兄弟知道,那就最好闭上你那满口谎言的嘴。
You probably think cuz its been so long if i had something on you I woulda did it by now, 你也许在想,如果我对你有那么点意思的话,怎么那么久都不见行动?
Oh on the contrary, Mary Poppins, 正相反,
Im mixing our studio session down and sending it to mastering to make it loud, 我这就正忙着录这骂你的歌,还要搞些大师制作让它更劲爆!
Enough dirt on you to murder you, 足够搞臭你搞S你,
This is what the fuck I do, 这就是我TMD在做的事!
Mariah, it ever occur to you that I still have pictures? 如果我两啥事没有,怎么我手上还有那些艳照。
However you prefer to do and goes for Nick too, faggot 不管你和NICK那娘娘腔想干啥,
You think Im scared of you? 你认为我会怕你们??
You gonna ruin my career you better get one, 想毁掉我的事业你们最好选好对象!
Like Ima sit and fight with you over some slut bitch cunt 难道老子为了掰开那些骚B的双腿干上一炮。
That made me put up with her psycho ass over 6 months and only spread her legs to let me hit once, 就要忍受她们的傻B性格达6个月之久吗?
Yeah, what you gonna say? Im lucky? 是啊,你又要怎么说?我很幸运?
Tell the public that I was so ugly that you fucking had to be drunk to fuck me? 不妨告诉大家老子奇丑无比,你要喝醉了才敢和我干?
Second base? What the fuck you tell Nick, pumpkin? 上了二垒?你给NICK说了什么,废物?
In the second week we was dry humping. Its gotta count for something, 第二周见面我们就亲热摸搞起来,那总算是有些什么吧。
Listen, girly. Surely you dont want me to talk about how I nutted early 听着,小妹妹,你肯定不想我谈谈我怎么那么早就射在你身上。
'cos ejaculated prematurely and bust all over your belly, 因为我一来就勃起在你那里忙个不停,
and you almost started hurling and said I was gross, go get a towel youre stomachs curling. 你当时就要骂起我来,还说我恶心,快去拿个毛巾来,你有点胃部不适,
Or maybe you do. 或者你真的是那样想的。
But if Im embarrassing me, Im embarrassing you and dont you dare say it isnt true. 如果这是我在让我出丑,那我也是在让你出糗,你敢说这些不是真的?
As long as the songs getting airplay Im dissing you. 只要这歌在电台播放多久,我就要骂你多久。
Im a hair away from getting carried away and getting sued. 我距被抓和被起诉只有一线之隔。
I was gonna stop at 16. That was 32. This is 34 bars.本来我要说唱上16句,结果说了32句,现在都到34句了,
We aint even third of the way through. 我们的事都还没说到1/3!
Damn, Slim. Mariah played you. Mariah who? 他妈的,SLIM,Mariah玩了你,Mariah是谁?
Oh did I say whore, Nick? I meant a liar too. 噢,NICK,我是不是说....那个婊子?我的意思是,她也是个骗子。
Like Ive been goin off on you all this time for no reason, 就象我无缘无故离开你这些时间,
Girl you out ya alcholic mind. Check ya wine cellar. Look at all the amounts of all the wine, 女孩,你醉生梦死又失控,看看自己酒杯,看看那堆酒瓶,
Like I fuckin sit around and think about you all the time,以为我要一直坐在那傻bb的想你?
I just think this shit is funny when I pounce you on a rhyme. 只是想当我用这唱词痛击你时有多么有趣!
But fuck it now im about to draw the line. 但现在我要来画一条线,。
And for you to cross it thats a mountain that I doubt you wanna climb. 如果你想来跨越可能对你来说比登山还难!
I can describe areas of your house you wouldnt find on an episode of Cribs, 我知道你那非黄金地段的家里的每个角落,
A blow below the ribs if I hear another word so dont go opening your jibs 肥妞加排骨!如果我听到其他的词汇我照样骂出来。
cos every time you do its just another load of fibs, 所以不要张嘴说话,因为每次你一张开就是一堆谎言!
I aint saying this shit again, ho, you know what it is. 我不会再提这些,骚货,你知道那是什么。
Its a warning shot for I blow up ya whole spot, 这只是鸣枪示警,在我真正干掉你们之前。
Call my bluff and Ill release every fucking thing I got, 叫我大话王,老子就把手上的东西都放出来。
Including the voicemails right before you flipped your top, 包括那些语音邮件:就是在你发飙的那当儿,
When me and Luis were tryin to stick two CDs in the same spot, 我和LUIS都在试着把两张"CD"插入同一个地方....。
(Slim Shady I love you)。
I love you too
Let me whisper sweet nothings into your ear, boo. Now what you say? 让我给你耳边说些甜言蜜语,亲爱的,现在你想说什么。
(Its nothing) (没什么)。
Yeah so what Ill do? 猜我要做什么。
Is refresh your memory when you said I want you 我要唤起你的记忆当你对我说“我要你”的时候。
Now should I keep going or should we call truce? 现在我们是继续还是休战?
(You think youre cute, right? Hahaha) (你认为你很可爱吗?)。
You bet your sweet ass I do 你一定傻B的认为我会的。
(Im Mary Poppins, b) (我是Mary天后, b)
And Im Superman, ooo 那我就是超人,恩~~。
(Mary P. Slim Shady)。
Comin at you 冲你来了!。
So if youll still be my (babygirl) 如果你还是我的宝贝儿。
Then Ill still be your (Superhero, Wilma M.) 那我就还是你的超级英雄。
Yeah, Im right here 是的,我就在这儿。
(You like this) (你喜欢这样)。
Nope. Not anymore, Dear. 不,不再了,亲爱的。
It cuts like a (knife) when I tell ya get a (life) 心如刀割当我叫你走自己的路。
But Im movin on with mine 而我要走我的路。
Nick, is that your (wife) NICK,那是你老婆么?
Well tell her to shut her mouth then Ill leave her alone, 那么请叫她闭嘴,然后我就会放过她。
If she dont (sing this script?) then Ima just keep goin. 如果她不这样,那我就仍会继续骂下去!
(I see Mary Ann. Mary Anns saying cut the tape, cut the tape. Knife!)(我看见Mary Ann了. Mary Ann说 ”剪掉这盒带,剪掉这盒带”,刀呢?)。
婓波那契数列(前两个数的和是第三个数)
def fib(num):
fibs=[0,1]
#num=input('请输入婓波那契数列中的数据个数:')。
for i in range(int(num)-2):。
fibs.append(fibs[-2]+fibs[-1])。
print(fibs)
print(fibs[-2])。
fib(10)