#38 Python Tutorial for Beginners | Fibonacci Sequence

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ต.ค. 2024
  • Check out our courses:
    Spring Boot and Microservices Live Course : go.telusko.com...
    Coupon: TELUSKO10 (10% Discount)
    Complete Java Developer Course Batch-3: go.telusko.com...
    Coupon: TELUSKO10 (10% Discount)
    Enterprise Java Spring Microservices: go.telusko.com...
    Coupon: TELUSKO10 (10% Discount)
    Master Java Spring Development : go.telusko.com...
    Coupon: TELUSKO20 (20% Discount)
    Udemy Courses:
    Spring: go.telusko.com...
    Java:- go.telusko.com...
    Java Spring:- go.telusko.com...
    Java For Programmers:- go.telusko.com...
    Python : go.telusko.com...
    Git : go.telusko.com...
    Docker : go.telusko.com...
    For More Queries WhatsApp or Call on : +919008963671
    website : courses.telusk...
    Instagram : / navinreddyofficial
    Linkedin : / navinreddy20
    TELUSKO Android App : bit.ly/TeluskoApp
    Discord : / discord
    Github :- github.com/nav...

ความคิดเห็น • 1.3K

  • @anamikaupadhya144
    @anamikaupadhya144 4 ปีที่แล้ว +480

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

    • @viswatalks411
      @viswatalks411 4 ปีที่แล้ว +7

      Wow really very nice yar😍😍😍,, I am also trying to learn python in this lockdown,,, nd Navin sir lecture is just simply superb ♥️

    • @youngsgaming5620
      @youngsgaming5620 4 ปีที่แล้ว +3

      mine too :)

    • @mohammadmohsinmohammedmohs9717
      @mohammadmohsinmohammedmohs9717 4 ปีที่แล้ว +1

      Ok let's learn together 😄😄👍

    • @simranjitsingh5126
      @simranjitsingh5126 4 ปีที่แล้ว

      Hlo... Hope u r doing well, Which college?

    • @nadeemshaik157
      @nadeemshaik157 4 ปีที่แล้ว +2

      Ur so beautiful in ur profile

  • @clanhindustan358
    @clanhindustan358 3 ปีที่แล้ว +54

    # Assignment Fibonacci series
    # Thank You Sir.
    def fib(num):
    if(num

    • @patelprit442
      @patelprit442 ปีที่แล้ว

      why you take n+1 in for loop range

    • @shilpakannan9058
      @shilpakannan9058 ปีที่แล้ว +2

      Cos if you want till num ,should take one number ahead to get that..for eg to get 24 we write 24+1 which gives till 24 value

    • @hardikkumar5188
      @hardikkumar5188 5 หลายเดือนก่อน

      ​@@shilpakannan9058it works without adding+1 too

  • @davidr.flores2043
    @davidr.flores2043 2 ปีที่แล้ว +15

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

  • @talhaordukaya2204
    @talhaordukaya2204 2 ปีที่แล้ว +8

    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()

  • @speaktothepoint2108
    @speaktothepoint2108 5 ปีที่แล้ว +81

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

  • @sreerajva1916
    @sreerajva1916 5 ปีที่แล้ว +3

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

    if n n:
    print(c)

  • @prateekaphale1134
    @prateekaphale1134 3 ปีที่แล้ว +32

    a=0
    b=1
    print(a)
    print(b)
    for i in range(100):
    c=a+b
    if c

    • @Your_pie655
      @Your_pie655 ปีที่แล้ว

      thankyou so much for this!

  • @ch_rahulsharma
    @ch_rahulsharma 4 ปีที่แล้ว +41

    I was actually learning from a Udemy video, but that was a bit confusing so I started to search on TH-cam 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

    • @davidr.flores2043
      @davidr.flores2043 2 ปีที่แล้ว +3

      I was on the 'exact same ship', but this presenter was way better when it comes to translating a math problem into Python code. Regards!

  • @akhild9900
    @akhild9900 4 ปีที่แล้ว +94

    assignment:
    def fib(x):
    a=0
    b=1
    if x

    • @abhaykulkarni8332
      @abhaykulkarni8332 4 ปีที่แล้ว +1

      Hello, can you explain how the if statement at last is making the difference

    • @arpdahod5275
      @arpdahod5275 2 ปีที่แล้ว +1

      abay, there is two assignment, and that 'last if' is for second assignment.

    • @vedanthasm2659
      @vedanthasm2659 2 ปีที่แล้ว

      fib(0) ---> "in valid"
      is this correct?..as per above code?
      is it....fib(0) ---> 0

    • @gulammujthaba5778
      @gulammujthaba5778 2 ปีที่แล้ว

      n=int(input("enter number "))
      a=0
      b=1
      if n

    • @mr.indiangamer1384
      @mr.indiangamer1384 2 ปีที่แล้ว +1

      thanks bro

  • @1najamulsaqib
    @1najamulsaqib 4 ปีที่แล้ว +1

    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)

  • @varunabhi
    @varunabhi 4 ปีที่แล้ว +12

    2nd assignment:--
    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

    • @nastyyt9639
      @nastyyt9639 ปีที่แล้ว

      u can do , if c>100 break

  • @bhoomigupta6688
    @bhoomigupta6688 3 ปีที่แล้ว +38

    Assignment solution::
    def fib(n):
    a=0
    b=1
    if n100:
    break
    else:
    print(c)
    n = int(input("Please enter the no. of value you want in your fibonacci series"))
    fib(n)

    • @Rajadahana
      @Rajadahana 2 ปีที่แล้ว +2

      Without going for if c>100 and adding a break at the end, you could have tried that at the top in the first if statement.
      if n100:
      If the input is : - 101
      Output will be : - "Invalid input"
      That would have shortened your code. Keep up the good work!

    • @rupaksarma672
      @rupaksarma672 2 ปีที่แล้ว +2

      @@Rajadahana You have not understood the problem..the question says to print sum of numbers less than 100 not total Fibonacci numbers

    • @japhethachimba174
      @japhethachimba174 2 ปีที่แล้ว +1

      great one i was trying to use break out of the loop i got error your code is nice

    • @mrfoodboss1076
      @mrfoodboss1076 2 ปีที่แล้ว

      What is the algorithm for this

    • @harshanr3762
      @harshanr3762 ปีที่แล้ว +1

      urs is the best one on the comment section , u truely helped me out thanks

  • @INDIAN-kq6yo
    @INDIAN-kq6yo 4 ปีที่แล้ว +13

    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

  • @michaeldonki9947
    @michaeldonki9947 4 ปีที่แล้ว +49

    # Fibonacci sequence with arbitrary boundary as input:
    def fib(bound):
    a, b = 0, 1
    while a < bound:
    print(a, end=" ")
    a, b = b, a+b
    print()

  • @BoomcoreIsLive
    @BoomcoreIsLive 5 ปีที่แล้ว +44

    #FibonacciSeries
    def fib(n):
    first,second=0,1
    if n

    • @swapnilshinde2540
      @swapnilshinde2540 5 ปีที่แล้ว +1

      This code is short and amazing thnx bro

    • @BoomcoreIsLive
      @BoomcoreIsLive 5 ปีที่แล้ว

      @@swapnilshinde2540 thank you!😁

    • @Rahulpandey-hp2pf
      @Rahulpandey-hp2pf 5 ปีที่แล้ว

      Fibonacci series in reverse order ex.0,-1,-1,-2,-3.....

    • @Rahulpandey-hp2pf
      @Rahulpandey-hp2pf 5 ปีที่แล้ว +1

      @@BoomcoreIsLive hmm

    • @thinkwith_shannu
      @thinkwith_shannu 5 ปีที่แล้ว +1

      @@Rahulpandey-hp2pf
      def fib(n):
      a=0
      b=-1
      print(a)
      print(b)
      for i in range(2,n):
      c=a+b
      a=b
      b=c
      print(c)
      fib(10)

  • @muhammadtalhataj3766
    @muhammadtalhataj3766 3 ปีที่แล้ว +21

    def num(n):
    a=0
    b=1
    if(n

    • @dhirajsarkar7246
      @dhirajsarkar7246 3 ปีที่แล้ว +1

      U forgot ' ' in print.
      It should be print('0')

    • @muhammadtalhataj3766
      @muhammadtalhataj3766 3 ปีที่แล้ว

      @@dhirajsarkar7246 no it running good at that time

    • @poojagawande3278
      @poojagawande3278 3 ปีที่แล้ว +1

      Yeah it's really work ...👍 thanks

  • @sheoran2848
    @sheoran2848 4 ปีที่แล้ว +19

    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)

    • @vishugusain5232
      @vishugusain5232 3 ปีที่แล้ว +8

      yes your answer is good but you have to return a statement to user that his/her input is invalid for that i made some changes in your function, I hope you will like it >>>>>
      l=int(input("enter length: "))
      def fib(l):
      if l

  • @JohnvictorPaul-ec1sm
    @JohnvictorPaul-ec1sm 4 หลายเดือนก่อน

    def fib(x):
    a=[0,1]
    for i in range(x):
    b=a[-2]+a[-1]
    if b

  • @satyammhetre2832
    @satyammhetre2832 4 ปีที่แล้ว +21

    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

    • @yuvaltasher2054
      @yuvaltasher2054 4 ปีที่แล้ว +1

      Change it to a for loop

    • @GhaniEdu
      @GhaniEdu 4 ปีที่แล้ว

      can u explain it

    • @freudoulon3179
      @freudoulon3179 4 ปีที่แล้ว +2

      issue with the condition for the loop. Here is a more comprehensible code
      def fib(x):
      a = 0
      b = 1
      if x==1:
      print("0")
      elif(x

    • @yashsurana2554
      @yashsurana2554 4 ปีที่แล้ว

      This is great but it will not work in the while loop as it will stop when a is lesser than x.
      So suppose I take x as 5, the output will be :
      0
      1
      1
      2
      3
      5
      8
      it will stop at 8 because 8(a) is less than 10(x).
      For this purpose, we must use for loop keeping x as a range input.
      a = 0
      b = 1
      x = 10
      for i in range(x):
      print (a)
      a,b = b,a+b

  • @mylifebd2024
    @mylifebd2024 ปีที่แล้ว +2

    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))

  • @d.9900
    @d.9900 3 ปีที่แล้ว +14

    Assignment 2 : To get the fibonacci sequence with condition of Comparison / Identity operators -
    n=int(input("Fibonacci Sequence until last term is less than :"))
    a=0
    b=1
    print(a)
    print(b)
    c=0
    while True :
    c=a+b
    a=b
    b=c
    if c

    • @RockstarBuddies
      @RockstarBuddies 2 ปีที่แล้ว +2

      When inputted 0, this code would not give 0 as an output so we could add
      if n == 1:
      print(c)
      after defining c and before starting the while loop.
      After this, we could even write
      elif n < 0:
      print('Invalid Input')
      so that it doesn't take negative numbers

  • @mamillajaswanth8844
    @mamillajaswanth8844 ปีที่แล้ว +2

    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)

  • @harshal1611
    @harshal1611 4 ปีที่แล้ว +14

    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)

  • @vnd21
    @vnd21 3 ปีที่แล้ว

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

  • @sparshjain4736
    @sparshjain4736 4 ปีที่แล้ว +26

    Navin sir,
    This can also be done using
    for i in range (2,n):
    a, b=b, a+b
    Print (b)
    Therefore you will not have to use a third variable which will make the coding memory efficient 😀
    Thanks,
    Your student.

    • @shalemrobin6233
      @shalemrobin6233 4 ปีที่แล้ว +1

      Hi,
      Thank you for the code which will make coding memory efficient and I tried it and it did work.
      One more I want to ask, in for we all know that it won't run till n times for Fibonacci series
      for e.g. if n is 100 it loop will not run for 100 times, if it gets any value greater than 100, it will end, if we give n in range will it take more memory, if it will take memory space what would be alternative to do it.

    • @kisankumavat8387
      @kisankumavat8387 4 ปีที่แล้ว +2

      This will also work...
      def fib(x):
      a=0
      b=1
      c=0
      while c

    • @kisankumavat8387
      @kisankumavat8387 4 ปีที่แล้ว

      @@samp_sampath9493 yaa bro...✌️

    • @dishantkumbhar8822
      @dishantkumbhar8822 4 ปีที่แล้ว

      Really efficient 🔥🙌

    • @Coder_DhruvArora
      @Coder_DhruvArora 4 ปีที่แล้ว +1

      Can you explain it Please ?
      3rd variable was easy to do 😅

  • @myyogesh4539
    @myyogesh4539 5 หลายเดือนก่อน

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

  • @kelleyannbart8348
    @kelleyannbart8348 ปีที่แล้ว +5

    Visual presentation and examples are really helpful. Am using your youtube videos to re-enforce learning things I do not understand in lectures in my course study. Thank you so much!!

  • @vinaykumarbellala9984
    @vinaykumarbellala9984 4 ปีที่แล้ว +1

    Def fib(n):
    a=0
    b=1
    if n==0 or n==1:
    print(a)
    elif nn:
    break
    fib(100)

  • @kp-discovers8813
    @kp-discovers8813 4 ปีที่แล้ว +9

    your sessions are amazing and makes python an easy language to learn
    the last assignment of this session is very simple put if c

    • @bharathchandran6274
      @bharathchandran6274 4 ปีที่แล้ว

      this wont work brother

    • @sumanth5087
      @sumanth5087 4 ปีที่แล้ว

      @@bharathchandran6274 😕😂
      Why brother??

    • @assk1728
      @assk1728 2 ปีที่แล้ว

      Hey it works bro

    • @shreyashthakur607
      @shreyashthakur607 2 ปีที่แล้ว

      No actually it should be if c

  • @pimppakoda1153
    @pimppakoda1153 4 ปีที่แล้ว +1

    For numbers upto user specified:-
    def fib(n):
    a = 0
    b = 1
    if n

    • @BNTechyoutuber
      @BNTechyoutuber 2 ปีที่แล้ว

      Hey, Can you create program where at the end it prints the sum of the sequence?

  • @ritusree05
    @ritusree05 4 ปีที่แล้ว +9

    n=int(input('Please type the no. of values-'))
    def fib(n):
    a=0
    b=1
    c=a+b
    if n

    • @Mohit_312
      @Mohit_312 9 หลายเดือนก่อน

      n = int(input('Enter the no. of values: '))
      def fib(n):
      a=0
      b=1
      if n

    • @therealthinker9085
      @therealthinker9085 8 หลายเดือนก่อน

      Thanks 🙏

  • @anuragpagar9641
    @anuragpagar9641 2 ปีที่แล้ว +1

    def fib(n):
    if nn:
    break
    print(c)
    fib(100)

  • @prasannakatre4040
    @prasannakatre4040 ปีที่แล้ว +3

    # Assignment 02 to print Fibonacci series for positive number and no of series elements
    def fib(n):
    a = 0
    b = 1
    if n == 1:
    print(b)
    else:
    print(a)
    print(b)
    for i in range(2, n):
    c = 0
    c = a + b
    a = b
    b = c
    if c > n:
    break
    else:
    print(c)
    x = int(input("Enter the no of values you want in the Fibonacci series: "))
    if x < 0:
    print("Series must have positive value!")
    else:
    fib(x)

  • @priyadambhe1097
    @priyadambhe1097 5 ปีที่แล้ว +1

    def fibo(num):

    a = 0

    b = 1

    if num

  • @cinemaplus150
    @cinemaplus150 4 ปีที่แล้ว +6

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

    • @husamalvi3948
      @husamalvi3948 4 ปีที่แล้ว

      Great bhai....

    • @bissiratnegusse5716
      @bissiratnegusse5716 4 ปีที่แล้ว +2

      I think you forgot to include what happens if the input is one (n = 1)....lol

  • @anshpatidar5842
    @anshpatidar5842 4 ปีที่แล้ว +1

    solution:
    def fib (n):
    a=0
    b=1
    if n

  • @todaysspark3280
    @todaysspark3280 2 ปีที่แล้ว +17

    Assignment(1) checking for negative n value
    def feb(n):
    a=0
    b=1
    if n

  • @EVtalkMS
    @EVtalkMS 3 ปีที่แล้ว +7

    To print a fibonnaci series upto certain val(Assign 2)
    x=int(input('enter a val')
    a,b=0
    If x>0:
    Print(a)
    Print(b)
    For i in range(1,x):
    C=a+b
    a,b=b,c
    If c

  • @lingamrakesh9918
    @lingamrakesh9918 2 ปีที่แล้ว

    def fib(n):
    a = 0
    b = 1
    i = 0
    while i=100:
    break
    else:
    print(a,end=' ')
    c = a + b
    a = b
    b = c
    i+=1
    fib(100)

  • @atishayjain690
    @atishayjain690 4 ปีที่แล้ว +8

    Here's my approach towards the assignment. I hope you like it.
    def fib():
    a = []
    n = int(input("enter the value of n : "))
    a.append(0)
    a.append(1)
    for i in range(2,n):
    a.append( a[i-1] + a[i-2])
    if a[i] >= n:
    a.pop(i)
    break
    print(a)
    fib()

    • @avinashwagh1058
      @avinashwagh1058 3 ปีที่แล้ว

      how does it works for a.append(a[i-1]+a[i-2]) this equation

    • @jimpagyatso486
      @jimpagyatso486 3 ปีที่แล้ว

      @@avinashwagh1058 it work as c=a +b

    • @avinashwagh1058
      @avinashwagh1058 3 ปีที่แล้ว

      @@jimpagyatso486 so [i-1] is positioned indexing ??

    • @jimpagyatso486
      @jimpagyatso486 3 ปีที่แล้ว +1

      @@avinashwagh1058 yap...

    • @avinashwagh1058
      @avinashwagh1058 3 ปีที่แล้ว

      @@jimpagyatso486 thank you

  • @ajaydattatray6433
    @ajaydattatray6433 5 ปีที่แล้ว

    code for less than 100
    def fib(n):
    a=0
    b=1
    while True:
    c=a+b
    a=b
    b=c
    if c

  • @tokay6467
    @tokay6467 4 ปีที่แล้ว +15

    If n

  • @arahanthjain4257
    @arahanthjain4257 4 ปีที่แล้ว +1

    def fib(n):
    a = 0
    b = 1
    if input==0:
    print(a)
    count=1
    print("the total numbers", count)
    else:
    print(a)
    print(b)
    count=0
    for i in range(input):
    c = a + b
    a, b = b, c
    if c > input:
    break
    print(c)
    count+=1
    print("the total numbers", count+2)
    input = int(input('enter the number'))
    fib(input)

  • @cheesball96
    @cheesball96 3 ปีที่แล้ว +4

    To end code at number that’s below 100
    for I in range (2, n):
    c = a + b
    a = b
    b = c
    if c >= 100:
    break
    print (c)

  • @mahendrad50
    @mahendrad50 3 ปีที่แล้ว

    def fibo(n):
    a=0
    b=1
    print(a)
    print(b)
    c=0
    while cn:
    break
    print(c)
    fibo(100)

  • @yashdixit8378
    @yashdixit8378 4 ปีที่แล้ว +4

    fib = lambda n: 0 if n == 0 else ( 1 if n == 1 else fib(n-1) + fib(n-2))
    for i in range(10):
    print(fib(i))

  • @rahulbaadal5418
    @rahulbaadal5418 3 ปีที่แล้ว

    a=0
    b=1
    c=0
    k=int(input("specify limit"))
    while ck:
    break
    a=b
    b=c
    print(c)

  • @karunkumar6163
    @karunkumar6163 3 ปีที่แล้ว +2

    def fib(n):
    a=0
    b=1
    if n==1:
    print(a)
    elif n100:
    print("sum of fib is greater than 100")
    break
    else:
    print(c)

    fib(100)

  • @PawanK2213
    @PawanK2213 4 ปีที่แล้ว +59

    If I become a programmer in future, because of Navin sir: Great sir.

  • @AaryanGupta-c4g
    @AaryanGupta-c4g 4 หลายเดือนก่อน +1

    n = int(input("Enter a number: "))
    def fib(n):
    if n

  • @pandapiz2910
    @pandapiz2910 5 ปีที่แล้ว +4

    assignment 2:
    i have taken range upto 50 numbers as the user only mentions a value and we have to print the value in the fibonacci series which is less than the user entry value
    def fib(n):
    a=0
    b=1
    if n==0:
    print("Invalid")
    elif n==1:
    print("The value before",n,"is :",0)
    else:
    for i in range(1,51):
    if i=n and b

  • @adarshyadav340
    @adarshyadav340 3 ปีที่แล้ว

    to find number that is less than the entered number
    def fib(n):
    a,b=0,1
    if n=0 :
    a,b=b,a+b
    if b

  • @sanjaykhandelwal6013
    @sanjaykhandelwal6013 4 ปีที่แล้ว +12

    If a,b

  • @karthikkeyansmk2727
    @karthikkeyansmk2727 4 ปีที่แล้ว +1

    my assignmnt with differen way:
    def fib(num):
    a = 0
    b = 1
    e =[]
    if num

  • @StrictlyCards
    @StrictlyCards 3 ปีที่แล้ว +4

    Thank you so much for the great breakdown! I was having trouble understanding how to do this via my textbook and after watching your video I finally get it!

  • @prachipatil9726
    @prachipatil9726 4 ปีที่แล้ว +1

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

  • @jonitadsouza5410
    @jonitadsouza5410 4 ปีที่แล้ว +4

    I think this is right and I hope this helps! Feel free to tell me if its wrong I'm a learner too:
    def fibo(num):
    a = 0
    b = 1
    c = 0
    if num == 0:
    print(a)
    else:
    print(a)
    print(b)
    while num > c + a:
    c = a + b
    a = b
    b = c
    print(c)
    thelast = int(input('The last number of the Fibonnaci sequence you wish to see '))
    fibo(thelast)

  • @deepakreddy5738
    @deepakreddy5738 4 หลายเดือนก่อน

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

  • @panomapet9441
    @panomapet9441 5 ปีที่แล้ว +18

    Hello Telusko, kindly make a series on programming challenges/questions only. This can help us much!

  • @ashokreddy8273
    @ashokreddy8273 2 ปีที่แล้ว +1

    To print the Fibonacci number less than the entered value:
    def fibo(n):
    a=0
    b=1
    if n==1:
    print(0)
    elif n

  • @dineshgurumoorthy3564
    @dineshgurumoorthy3564 5 ปีที่แล้ว +5

    Jus add if condition after the def function with proper indentations
    If n< 1:
    Print(“invalid”)
    Else:
    Pass
    .
    .
    .
    .
    For loop
    .
    .
    .
    .
    Fib(5)

    • @asleeperj
      @asleeperj 5 ปีที่แล้ว

      What if you wanted the program to print the negative fib numbers?

  • @sarmisthapanigrahi9368
    @sarmisthapanigrahi9368 ปีที่แล้ว

    def fib(n):
    a=0
    b=1
    print(a)
    print(b)
    for i in range(n):
    c= a+b
    a=b
    b=c
    if c

  • @MrRohit000
    @MrRohit000 4 ปีที่แล้ว +3

    Sir, you are awesome. Please keep posting more videos.
    And about the for loop, for(start,end,step) --> for loop will print till end- step
    say for instance you have for i in range(1,100,1)-- it will print till 99[end(100) - step(1)]
    I felt that part was not clear
    Thank You sir

    • @BA-ve7xp
      @BA-ve7xp 2 ปีที่แล้ว

      yes, can you clarify the end part plz

  • @marksteventagaro2171
    @marksteventagaro2171 3 ปีที่แล้ว

    def fib(n):
    a=0
    b=1
    d=0
    if n c:
    d = c
    print(d)

  • @sreeyagalla5158
    @sreeyagalla5158 4 ปีที่แล้ว +10

    you are best tutor sir.thank u so much sir.really helped a lot in my exams

  • @atulayagupta785
    @atulayagupta785 4 ปีที่แล้ว +3

    n = int(input("Enter the numnber of sequence needed to fabonacci series: ", ))
    first = 0
    second = 1
    if n == first:
    print("Series : ", first)
    else:
    print(first)
    print(second)
    for i in range(n):
    next = first + second
    first = second
    second = next
    print(next)

  • @beecrofttobiloba1869
    @beecrofttobiloba1869 4 หลายเดือนก่อน

    1st and 2nd assignment solution:
    def fibi(m):
    if mm:
    break
    a = b
    b = c
    print(c)
    fibi(-1)
    fibi(20)

  • @mateenahmedkhan3780
    @mateenahmedkhan3780 4 ปีที่แล้ว +5

    seeing so many answers, i think we can do it more simple. In the start of the function just check if value < 0 then just return nothing. Something like this
    if(n

    • @vinaysudheer474
      @vinaysudheer474 4 ปีที่แล้ว

      Why not a break is not applicable in the code

    • @mateenahmedkhan3780
      @mateenahmedkhan3780 4 ปีที่แล้ว

      @@vinaysudheer474 breaks exists within loops like for and while

  • @jananivamp
    @jananivamp 8 หลายเดือนก่อน +1

    def fib(n):
    a=0
    b=1
    if n < 0:
    print("invalid")
    if n==1:
    print(a)
    else:
    print(a)
    print(b)
    for i in range(2,n):
    c=a+b
    a=b
    b=c
    print(c)
    fib(-1)

  • @pimppakoda1153
    @pimppakoda1153 4 ปีที่แล้ว +7

    For number less than 0:
    def fib(n):
    a = 0
    b = 1
    if n

  • @ITechniques
    @ITechniques 4 ปีที่แล้ว +1

    def fib(n):# task 3 { Fibonacci series }
    a=0
    b=1
    if n==1:
    print(a)
    elif nn:
    break
    print(b,' ',end="")
    n=int(input('enter the number'))
    fib(n)

  • @ameykhedekar6205
    @ameykhedekar6205 4 ปีที่แล้ว +5

    use elif n

  • @naghmaniyaz8348
    @naghmaniyaz8348 4 ปีที่แล้ว +2

    def fib(x):
    a = 0
    b = 1
    i = 0
    print(a)
    print(b)
    while a+b

    • @siddarthreddy7375
      @siddarthreddy7375 4 ปีที่แล้ว

      I guess it is possible even without 'i' variable

  • @varunabhi
    @varunabhi 4 ปีที่แล้ว +2

    Total fibonacci series with no errors. Can play as many times as you want without running each time.(1st assignment)
    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
    print(c)
    a = 1
    while a==1:
    n = input("Enter the number of sequences you want for fibonacci sequence:")
    try:
    n = int(n)
    except:
    print("String's can't be used with fibanacci series.")
    continue
    if n

  • @nigampratap2466
    @nigampratap2466 5 ปีที่แล้ว +1

    def fib():
    n=int(input("the length of series is"))
    if n

  • @amansilawat8353
    @amansilawat8353 5 ปีที่แล้ว +3

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

  • @manokm7348
    @manokm7348 3 ปีที่แล้ว +2

    def fib(n):
    a=0
    b=1
    if n>=2:
    print(a)
    print(b)
    for i in range(n-2):
    c=a+b
    b=c
    a=b-a
    print(c)
    else:
    if n==1:
    print(a)
    else:
    pass
    fib(0)
    This works too. Thanks Navin, your teaching is great

  • @AshishKumar-rz7ul
    @AshishKumar-rz7ul 4 ปีที่แล้ว +2

    n = int(input("Enter length : "))
    a = [0,1]
    n= n-1
    for i in range(1,n):
    a.append(a[i]+a[i-1])
    print(a)

  • @amanakash893
    @amanakash893 4 ปีที่แล้ว +3

    There's a small fault in this program. If you enter n=2, output will be 0 1 1 ie 3 outputs because before for loop, 2 output will be printed and in for loop, 2 will give Boolean true ie for loop will run once giving 3rd output

  • @sumanshekar2023
    @sumanshekar2023 5 ปีที่แล้ว +2

    Assign 2
    def fib(n):
    if n>=0:
    a=0
    b=1
    print(a)
    print(b)
    else:
    print("should not be negtive number")
    for i in range(2,n):
    c=a+b
    a=b
    b=c
    If c

  • @arunpurohit4866
    @arunpurohit4866 4 ปีที่แล้ว +5

    Simply put if condition before c if c>100: break

  • @somaysharma3611
    @somaysharma3611 4 ปีที่แล้ว +1

    mylist = list()
    x = int(input("Enter how many numbers you want in fibonacci secquence :"))
    def fibo():
    if x = 0:
    print(a)
    print(b)
    for i in range(2,x):
    c = a + b
    a = b
    b = c
    if c >= 100:
    break
    else:
    print(c)
    mylist.append(i)
    fibo()
    Sir, here's my project along with both the assignment done at the same and thanks a lot for teaching us wonderful stuff about python
    Ba bye...

  • @meetangad
    @meetangad 4 ปีที่แล้ว +4

    #Fibonacci Sequence using functions
    def fib(n):
    a=0
    b=1
    if n==1:
    print(a)
    elif n n):
    break
    print(a)
    fib(150)
    Result will be 144

    • @ankitsahoo307
      @ankitsahoo307 4 ปีที่แล้ว

      It should be print(c) in the inner if condition

  • @ziyodullapayek6221
    @ziyodullapayek6221 ปีที่แล้ว +1

    for finding fibonacci numbers within input range:
    def fib(x):
    a = 0
    b = 1
    print(a)
    print(b)
    for i in range(2,x):
    c=a+b
    a=b
    b=c
    if c

  • @adityaprakash5677
    @adityaprakash5677 5 ปีที่แล้ว +6

    Please start some project on Java or python. Not live project in which only few can participate but For every one. All can make on their own by seeing your videos it will be helpful for our resume...... small and large projects both will be helpful for widening the concept.

  • @ismailbadhusha96
    @ismailbadhusha96 4 ปีที่แล้ว

    2nd Assignment:
    def fib():
    g =(int(input("enter the number")))
    a = 0
    b = 1
    if g == 1:
    print(a)
    elif (g > 1):
    print(a)
    print(b)
    for i in range(2, g):
    c = a + b
    a = b
    b = c
    if c

  • @amitkumar-ny2jd
    @amitkumar-ny2jd 5 ปีที่แล้ว +8

    How to program Catalan numbers? I would like to request you, can you make a short video on this?

    • @zavier9788
      @zavier9788 3 ปีที่แล้ว

      to print nth catalan number :
      def fact(n):
      a=1
      for i in range(1,n+1):
      a*=i
      return a
      n=int(input())
      n-=1
      cat=fact(2*n)/(fact(n+1)*fact(n))
      print(cat)
      to print series of catalan numbers upto n:
      def fact(n):
      a=1
      for i in range(1,n+1):
      a*=i
      return a
      n=int(input())
      cat=fact(2*n)/(fact(n+1)*fact(n))
      for i in range(n):
      cat = fact(2 * i) / (fact(i + 1) * fact(i))
      print(cat)

  • @ashokreddy8273
    @ashokreddy8273 2 ปีที่แล้ว +1

    def fibo(n):
    a=0
    b=1
    sum=1
    if n==1:
    print(0)
    elif n

  • @TheSwatisadhukhan
    @TheSwatisadhukhan 5 ปีที่แล้ว +4

    def fib(n):
    result = []
    for i in range(n):
    if i==0:
    result.append(0)
    elif i==1:
    result.append(1)
    else:
    result.append(result[i-1]+result[i-2])
    print(result)
    fib(10)

  • @kajaljaiswal729
    @kajaljaiswal729 4 ปีที่แล้ว

    x=int(input("Enter the positive integer: "))
    def fib(n):
    a=0
    b=1
    if n==1:
    print(a)
    else:
    print(a)
    print(b)
    for _ in range(2,x):
    c=a+b
    a=b
    b=c

    if c

  • @Ashish123
    @Ashish123 4 ปีที่แล้ว +3

    we can simply use elif after if
    elif n

  • @sombithsen177
    @sombithsen177 3 ปีที่แล้ว

    lst=[]
    t=int(input("Enter how many terms: "))
    a,b=0,1
    n=int(input("Enter the last range: "))
    for i in range(0,t):
    if a

  • @shashanksharma9350
    @shashanksharma9350 4 ปีที่แล้ว +9

    very coherent , very easy. Thanks for the series.

  • @mehdidn4301
    @mehdidn4301 3 ปีที่แล้ว +1

    in case you want the last assignment, I wrote this code and it works but I'm not sure it's the most optimized way.
    .
    .
    def fib(n):
    a = 0
    b = 1
    if n == 1:
    print(a)
    elif n

  • @techsp6379
    @techsp6379 4 ปีที่แล้ว +4

    Due to your Lectures our knowledge × n
    Thank-you Sir

    • @omhpatil
      @omhpatil ปีที่แล้ว

      where n = infinite

  • @yashthakkar7468
    @yashthakkar7468 3 ปีที่แล้ว +3

    From where can we get the assignment solutions to verify

  • @alexlu2
    @alexlu2 ปีที่แล้ว

    x = int(input("Enter upper limit of Fibonacci sequence"))
    def fib(x):
    a = 0
    b = 1
    c = 1
    while c < x:
    c = a + b
    a = b
    b = c
    else:
    print(a)
    fib(x)

  • @swastiktyagi8246
    @swastiktyagi8246 5 ปีที่แล้ว +5

    Sir you are great
    Finally i had clear all dought in python🤙❤
    Your Student - Alien 👽

    • @islay.okay.3630
      @islay.okay.3630 5 ปีที่แล้ว +3

      Phle doubt ki spelling to clear kar le 😂 "dought"

    • @ankitjain154
      @ankitjain154 5 ปีที่แล้ว +1

      @@islay.okay.3630 hahaha

    • @42najibshaikh98
      @42najibshaikh98 4 ปีที่แล้ว

      @@islay.okay.3630 😂😂😂

  • @mahammadsayeed3972
    @mahammadsayeed3972 4 ปีที่แล้ว

    assigment 2
    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

  • @mahmudulhasan6224
    @mahmudulhasan6224 5 ปีที่แล้ว +4

    if c