#38 Python Tutorial for Beginners | Fibonacci Sequence

preview_player
Показать описание
Check out our courses:

Coupon: TELUSKO10 (10% Discount)

Coupon: TELUSKO10 (10% Discount)

Coupon: TELUSKO10 (10% Discount)

Coupon: TELUSKO20 (20% Discount)

Udemy Courses:

For More Queries WhatsApp or Call on : +919008963671

Рекомендации по теме
Комментарии
Автор

# Assignment Fibonacci series
# Thank You Sir.

def fib(num):
if(num<0):
print("Invalid number")
else:
a=0
b=1

print(a)
print(b)

for i in range(num+1):
c=a+b
a=b
b=c
if(c<=num):
print(c)
else:
break
num=int(input("Enter the number till you want to see in fibonacci series : "))
fib(num)

clanhindustan
Автор

Nice and clear answer for the question:
def fib():
a, b = 0, 1
while a < 100:
print(a, end=" ")
a, b = b, a+b
fib()

talhaordukaya
Автор

My every morng in this lockdown start with your lecture of python sir ..thanx a lot sir👍👍

anamikaupadhya
Автор

def fib_last(n):
a=0
b=1

if n<1:
print("Invalid number entered")
elif n == 1:
print(a)
else:
# print(a)
# print(b)
for i in range(2, n):
c=a+b
a=b
b=c
d=a+b
if c < n and d > n:
print(c)

sreerajva
Автор

a=0
b=1
print(a)
print(b)
for i in range(100):
c=a+b
if c<=100:
a=b
b=c
print(c)
else:
print("done")
break
Your lectures are the best really, and specially in last you give us a problem to solve and that's the best part....Thank you sir, God bless you :)

prateekaphale
Автор

The way you translated the math into code was easier to understand than many other presenters. Thanks a million.

davidr.flores
Автор

I was actually learning from a Udemy video, but that was a bit confusing so I started to search on YouTube and I found this video. This video is extremely useful and helped me to understand the concept. Also, the use of visual representation makes things a lot more intuitive and easy. Thanks a lot Sir

ch_rahulsharma
Автор

def fib(num):
lst = [0, 1]
for i in range(20):
n = lst[i] + lst[i+1]
if n < num:
lst.append(n)
if n > num:
break
return lst
x = fib(100)
print(x)

najamulsaqib
Автор

assignment:
def fib(x):
a=0
b=1
if x<=0:
print("in valid")
elif x==1:
print(a)
else:
print(a)
print(b)
for i in range(2, x):
c=a+b
a=b
b=c
if(c<=x):
print(c)
x=int(input("enter the number of values"))
fib(x)

akhild
Автор

def fibonnaci(n):
a = 0
b = 1
sequence = []

while a < n:
sequence.append(a)
c = a + b
a = b
b = c

return sequence



print(fibonnaci(100))

mylifebd
Автор

Hi Navin, Your teaching is one of the best. You can only teach us the concept. It is our duty to play and try different approach. You have taught us every thing to create the following function.
This function is memory efficient and you don't have to check for 0 or negative inputs.
def fib(n):
a=0
b=1
for i in range(0, n):
print(a)
a, b = b, a+b

INDIAN-kqyo
Автор

def fib(n):
a=0
b=1
if(n>0):
if(n==1 ):
print(a)
else:
print(a)
print(b)

for i in range(2, n):
a, b=b, a+b
print(b)
else :
print('enterd negative value')

fib(10)

mamillajaswanth
Автор

n=int(input('Please type the no. of values-'))

def fib(n):
a=0
b=1
c=a+b
if n<0:
print('Invalid input')
else:
print(a)
print(b)
for i in range(2, n+1):
c=a+b
a=b
b=c
c=a+b
print(c)
return(c)
print()
fib(n)

Completed your assignment for the brilliant explanation.

ritusree
Автор

def fib(x):

a=[0, 1]


for i in range(x):
b=a[-2]+a[-1]
if b<x:
a.append(b)

return a

print(fib(104))

JohnvictorPaul-ecsm
Автор

I tried this code and it worked!
This is bit simpler than yours.

a = 0
b = 1

x = int(input("Please enter a number: "))

while a <= x:
print(a)
a, b = b, a+b

satyammhetre
Автор

Last assignment in this video:-
def fib(n):
a, b = 0, 1
c = 0
l = []
while c<n:
l.append(c)
c = a+b
a, b = b, c
print(l[-1])

fib(10)

vnd
Автор

I feel this is a better way as there is no need to print first two values, everything is handled by the for loop:
l=int(input("enter length: "))
def fib(l):
x, y = 0, 1
for i in range(l):
print(x)
next=x+y
x=y
y=next

fib(l)

sheoran
Автор

Def fib(n):
a=0
b=1
if n==0 or n==1:
print(a)
elif n<0:
print("please enter positive integer")
else:
print(a)
print(b)
c=a+b
for i in range(c, n-1)
print(c)
a=b
b=c
c=a+b
if c>n:
break
fib(100)

vinaykumarbellala
Автор

def fib(n):
a=0
b=1
if n==1:
print(a)
else:
print(a)
print(b)
for i in range (2, n):
c=a+b
a=b
b=c
if c>n:
break
print(c)






fib(n)

harshal
Автор

Fibonacci series is one of the evergreen topics that always interests both the Mathematicians and the Programmers. Navin's presentations is awesome - as always !!

speaktothepoint