#22 Python Tutorial for Beginners | Break Continue Pass in Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ม.ค. 2025

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

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

    My college life would be great if I had a professor like you in my college

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

      Hey Arjun! Never met another Arjun

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

      Arjun siva it really wouldn’t because we usually find another problem with the professor.

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

      damn really :) i would not study at all or daily 1 hour would be enough to get a rank :)

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

      Agreed

    • @PaWoW-PW
      @PaWoW-PW 2 ปีที่แล้ว +1

      @@arjunchavan9669 cap, Arjun's are everywhere

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

    i am experienced programmer so watching on 2x speed but for your bbye i slow down the speed!!!!! your way of saying bbye is awesome

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

    I will complete my python within 1 week by your teaching sir.
    I thank you very much sir for teaching this course.

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

      yeah I am planning to complete it in a single night lol

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

      @@siddharthrajan616 quite possible though

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

      @@siddharthrajan616 😂😂🤣 exectly

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

    I had literally searched whole TH-cam in search of a video that could explain me loops but I didn't get one. Then, I found this channel and finally I understood loops and even make programs using while and for loops.
    Thank you Navin sir :)

    • @pradeepchandertiwari2883
      @pradeepchandertiwari2883 7 หลายเดือนก่อน

      My vending machine is not working even with the same code

  • @tirthshah3350
    @tirthshah3350 6 ปีที่แล้ว +27

    I had just started your python tutorial and it was the best. One request is that at last please also show how to make games and software in python.

  • @flamboyantperson5936
    @flamboyantperson5936 6 ปีที่แล้ว +213

    When you will start with "Machine Learning"? It's going to be awesome if you teach us.

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

      Not only machine learning we want Artificial Intelligence TOO.

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

      +1

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

    You are a really great man.... I learned from you and practise some programs and i did it... First time in my life i can create the logic..🙌🙌🙌

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

    x=int(input("Enter a no."))
    s=0
    i=1
    while(i

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

      good one

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

      @@suryanshugarg10 thank you

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

      Nice one .

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

      why do we need to check s==2:;why not s==1?

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

      @@divyasree24 a prime number is divisible by 1 and itself implying that the "if" block would have executed twice if the number was prime.

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

    Teaching is an art. You've got it man👍 very logical progression for beginners.

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

    2.
    a=int(input("enter a integer"))
    count=0
    for i in range(1,a+1):
    if(a%i==0):
    count=count+1
    if count==2:
    print(a)

  • @DevendraSingh-xt2wn
    @DevendraSingh-xt2wn 6 ปีที่แล้ว +158

    #fibonacci
    list1 = [0, 1]
    for i in range(48):
    list1.append(list1[-1]+list1[-2])
    print('bye')
    print(list1)

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

      Smart Logic

    • @anon5788
      @anon5788 6 ปีที่แล้ว +7

      This is very nice approach. learnt a new thing

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

      Woow

    • @rubanaugastin9049
      @rubanaugastin9049 6 ปีที่แล้ว

      What's out put of this code

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

      hey, looks simple but whats the logic here.. can you explain

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

    sir you are a very great teacher i am 13 years old and i am learning python and as well i could understand each and every thing you say..you're teaching style is really great..

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

    fibonacci solution
    a = [0,1]
    for i in range(0,49):
    b = a[-1]+a[-2]
    a.append(b)
    print(a)

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

      b=a [0]+a [1] is also right na

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

      @@babasahebbhosale7908 no it's wrong if you do like that you will get [0,1,1,1,1,1,1...........]

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

      @@babasahebbhosale7908 If you do that, it will keep adding only first 2 numbers and that would be 0+1 always. Doing a[-1] + a[-2] would do a sum of last 2 digits, which is what is needed for fibonacci series

  • @DineshKumar-xi8rv
    @DineshKumar-xi8rv ปีที่แล้ว +1

    Sir I am in 7th grade and you are one of the best coding teacher ever as well as your examples make easy to understanding coding in py.

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

    av=6
    x=int(input('how many candies do you want'))
    for i in range(0,x):
    if i

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

    Why we need udemy when we have a professor like you. Outstanding explanation.

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

    Sir the way of your teaching has just made learning python so easy and I'm blessed to learn from you sir.
    Hope i could meet you some day.

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

    I have never heard a explanation about loop... Brilliant explanation 👌... Thanks a lot sir.

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

    x=int(input('enter a number'))
    i=2
    while i

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

      According to your code, 9 is a prime no which it is not.

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

      @@vivekrenikunta2398 Recheck it.. Its certainly giving not a prime number as 9 as an input... I think u misinterpreted the output...Try again using proper indentation...!

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

      Yeahh... I'm sorry'😅

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

      @@vivekrenikunta2398 no issues...

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

    1-n=int(input("Enter no of Sequence:"))
    def fib(n):
    a,b=0,1
    while b

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

    n=int(input("enter the number for checking it is prime or not:"))
    i=2
    while i

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

    Break : to end the loop. It uses with if statement to put a condition so you can break the loop and exit.
    Continue : to skip the remaining code of the loop when a certain condition happen (like in if statement), but still looping.
    Pass: uses for impty blocks when you don't have a code to write.

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

      thx!

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

      can someone explain me...why he use * while i

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

      @@YourHotMan i means no. of candies & x is the Limit of candies no. i.e. total candies want

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

      @@YourHotMan it's not * bro it is colon :

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

      Here it looked like continue & pass are the same. Whats the difference? Used continue to skip number div. by 3 & used pass to skip odd numbers.

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

    av=6
    x=int(input("how many candies you want :"))
    i = 1
    while iav:
    print("Please Collect",i-1,"Candies &",x-av," Candies are Out of Stock ")
    break
    print(i,"Candy")
    i+=1

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

    To check if a given number is prime or not:
    i=2
    p = int(input("Enter a number:"))
    while i

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

    a=int(input('How many candies?'))
    av=5
    i=1
    While iav:
    Print('candies left=, end='')
    Print (av)
    break
    Print ('candy')
    i=i+1

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

    you r the only one best teacher....thank u so much, sir....just because of u all the concept are clear now

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

    I made my previous prime checker better. Super satisfied:
    x=int(input("For what number would you like to check primeness? "))
    factor=2
    while factorx/factor:
    print(x,"is a prime number.")

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

    Tq for your teachings sir....u made python easy to learn and understand...
    Waiting for machine learning teachings...

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

    a=int(input("enter a number"))
    if(a==2):
    print('prime number')
    else:
    for i in range (2,a):
    if(a%i==0):
    print('not a prime')
    break
    if(i==(a-1)):
    print("prime number")

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

      i like i(i==a-1)

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

      @@sandeepch If you limit your range to the square root of a, you'll go faster. Granted, I don't think range will take a float number so you might need to ceil it. But essentially half of the factors exist before the square root and half exist after. But if you check everything in the first half, you'll find their pair in the second half. Thus you only need to check the first half.

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

    I love that you use analogies to explain abstract concepts, great video!

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

    n = int(input('enter the no fibonnacci num'))
    n1=0
    n2=1
    print(n,"first fibonacci numbers are",)
    print(n1,' ',n2,end='\t')
    i=0
    while i

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

    1. Fibonacci Series Code:
    x=0
    y=1
    print('The Fibonacci Series will be:
    ')
    print(x)
    print(y)
    i=1
    while i

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

      Thanks buddy 😄

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

      why 48 not 50?

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

      @@bmguitarhub6135 Because we are already printing value 0 and 1 before entering while loop so that leaves us with 48 more values to complete first 50 fibonacci numbers

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

      @@akarshasudheer6626 yeah, thank youuu

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

      Can you explain 'pass' statement clearly....for yy we are use that condition??...plz anybody

  • @mtromanff320
    @mtromanff320 5 หลายเดือนก่อน +2

    You are just rocking🔥....the way of teaching is out of world 🫡

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

    1st 50 fib numbers :
    first = 1
    second = 1
    temp = 0
    for i in range (50):
    if i == 0 or i == 1 :
    print(1)
    else:
    print(first+second)
    temp = first+second
    first = second
    second = temp

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

    from math import sqrt
    x = int(input('Enter a number to check primeness: '))
    n = 2
    for i in range(1,x-1):
    if x%n==0:
    print("not a prime")
    break
    elif n==x-1:
    print("prime")
    break
    n += 1

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

    list = [0,1]
    for i in range(49):
    list.append(list[-1]+list[-2])
    print("Fibonacci Sequence is = ", end="")
    for i in list:
    print(i, end=" ")

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

      Your condition will print 51 fibonacci numbers

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

      awesome logic sir.Great

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

    import math
    total = 0
    P_num = int(input("Enter the value"))
    for i in range(1,P_num + 1):
    remainder = P_num % i
    if remainder == 0:
    total = total + 1
    if total == 2:
    print(f"{P_num} is prime Number")
    else:
    print (f"{P_num} is not Prime number")
    Thank you so much Teluskon

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

    This is the only channel which made me satisfied :) Thanks dude

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

    availableCandy = 20
    numberCandy =int(input("How many candies you want"))
    #i =1
    #while iavailableCandy:
    print("sorry!out of Stock")
    break
    print("Candy")
    i=i+1


    print("Bye!Have a good Day")

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

    x = int(input("Enter the Number : "))
    # To find the given number is prime for not
    z = 2
    for i in range(1, x):
    if x % z == 0:
    if x == z:
    print(z, " Is a prime number..")
    else:
    print(x, " is not a prime number...")
    break
    else:
    z += 1
    #Finally done

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

      But 4 also gives 0 remainder but it is not prime

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

      @@cv5033 Then it will print not prime

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

      this code fails for input 1.

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

      @@sumant5588 aap batao 1 prime ya not prime .....1 ko consider nhi karte ...i want to just add command for 1 input from user it will show invalid or u can show any thing u want to

  • @J.S.W0822
    @J.S.W0822 2 ปีที่แล้ว +2

    n=int(input ("enter the any number"))
    i=1
    List=[]
    for i in range (1,n+1):
    if (n%i==0):
    List.append (i)
    print (List)
    if len(List)

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

    You are the best teacher of python on this planet 🌍🌍🌍

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

    2:52
    x = int(input(" How many Candies you want :"))
    i = 1
    if x

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

    first=0
    second=1
    print(first)
    print(second)
    for i in range(0,48):
    next=first+second
    print(next)
    first=second
    second=next

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

    Ass 2:
    i=int(input('Enter a number: '))
    n=2
    while n

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

    a = 10007
    b = a
    if a==1:
    print(a, "Is not prime")
    while b > 2:
    b -= 1
    if a%b==0:
    print(a, "is divisible by", b, ",", a, "is not prime")
    break
    if b==2:
    print(a, "Is a prime")

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

    print("WE HAVE 10 CANDY ONLY")
    a=10
    x=int(input("Enter the number of candy?"))
    i=1
    while ia:
    print("Out of stock")
    break
    print("candy")
    i +=1
    print("Thank you for visiting")

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

    a,b=0,1
    for i in range(0,51,1):
    print(a,end=' ')
    a,b=b,a+b

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

    This is how I understood the three concepts.
    break - terminates the loop, or comes out of the loop
    continue - goes to the start of the loop
    pass - as the word suggests, goes to the next step in the loop

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

    Sir I am Agrim of class 8 and I want to learn python because I like coding and programming (as you say programming is so fun😉)and I am learning by your videos. Thank you a lot sir and please keep guiding us.

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

      You can check mine too. The detailed Python playlist provides all the tuturials, and source files.

  • @ML.ArtificialIntelligence
    @ML.ArtificialIntelligence 4 ปีที่แล้ว

    x=int(input("enter a number"))
    i=2
    while i

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

    Hello. My question is couldn't we use continue for the code you've written for pass and vice versa? Isn't the logic same for both continue and pass?

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

      Even i was thinking the same :
      Got an Anwser ... "Continue forces the loop to start at the next iteration while pass means "there is no code to execute here" and will continue through the remainder or the loop body.
      Continue will jump back to the top of the loop. pass will continue processing.."

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

      Diff b/w Continue and Pass:
      Continue skip the loop , will not executes the below statements and goes to top of loop, where pass executes the remaining logic. Example below.
      Continue :
      for i in range(11):
      if (i%2==0):
      continue
      print( i , " is odd")
      ----------------------------------------
      1 is odd
      3 is odd
      5 is odd
      7 is odd
      9 is odd
      Pass :
      for i in range(11):
      if (i%2==0):
      pass
      print( i , " is an number")
      ---------------------------------------------
      0 is an number
      1 is an number
      2 is an number
      3 is an number
      4 is an number
      5 is an number
      6 is an number
      7 is an number
      8 is an number
      9 is an number
      10 is an number

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

    FIBONACCI SERIES:
    a,b=0,1
    while a

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

    Thanks sir, I'm from Mechanical background and just joined Infosys..... Ur videos are helping me alot in my training period. 🙏🏼

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

    QUIZ ANSWER :
    1.
    fib1=0
    fib2=1
    for i in range(0,50):
    if i

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

    Great course! The answer beneath looks correct to find out if a number is prime.
    x=int(input("is this number prime?"))
    for i in range (2,x):
    if x%i==0:
    print (x, " is not prime")
    break
    else :
    print (x, "is prime")
    break

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

      a dude can u explain me the logic plz

    • @lokeshsharma4363
      @lokeshsharma4363 6 หลายเดือนก่อน

      this will throw an error for values like 9

    • @DonaldOkonkwo-n5e
      @DonaldOkonkwo-n5e 4 หลายเดือนก่อน

      No output would be visible if for a number like 2

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

    fibonacci series
    a=0
    b=1
    print(a)
    print(b)
    for i in range(0,10):
    c=a+b
    print(c)
    a=b
    b=c

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

    Fib:
    x=0
    y=1
    for i in range(0,50):
    print(x," ", end="")
    next=x+y
    x=y
    y=next

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

      well but 0 is not first in series

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

      @@Svcollections941 crt ?

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

    Candy program using for loop:
    available = 5
    x = int(input('How many candies you want? '))
    for i in range(1, x + 1):
    if i > available:
    print('Out of stock!')
    break
    else:
    print(i, 'candy!!')

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

      @Capt. John Price Where I missed that? I don't think we need i==1 anywhere in this program?

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

      @Capt. John Price You mean I should initialize it first? As per my understanding, i is an iterator here and range function gives it an initial value as well which is 1 in this case because I have mentioned it, otherwise it'd have been 0.
      Please correct me if I am wrong.

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

    1. Print first 50 fibonacci numbers
    lim = 50
    count = 0
    n1 = 0
    n2 = 1
    while count < lim:
    print(n1)
    last_number = n1 + n2
    n1 = n2
    n2 = last_number
    count += 1
    2. Check a given number is prime or not
    num = int(input("Enter Number : "))
    if(num==2):
    print('Prime')
    else:
    for i in range(2,num):
    if num % i == 0:
    print("Not prime")
    break
    else:
    print("Prime")

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

    # for prime number
    x=int(input("enter the no."))
    b=False
    if x==1 or x==2:
    print("prime number")
    elif x==0:
    print('zero')
    else:
    for i in range(2,x):
    if x%i==0:
    b=True
    if b:
    print('not prime')
    else:
    print('prime')

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

    Prime Number:
    x = int(input("Enter Number"))
    if x==0 or x==1:
    print("NP")
    else:
    i=2
    while i

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

    easiest solution for fibonacci
    x,y=0,1
    while y

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

      Cool bro

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

      @ENTERTAINMENT WORLD i ran the loop till 50, it will run fibonacci numbers till 50

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

    avg=20
    x=int(input("ENter number of candies you want:"))
    i=1
    while iavg:
    print("SOrry! we only have" + " " + str(avg) + " " + "candies left")
    break
    print("candy")
    i+=1

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

    For the first one:
    a = 1
    b = 1
    for i in range(50):
    print(a)
    print(b)
    a = a + b
    b = b + a

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

      niceee

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

      Epic. But this code prints 100 Fibonacci numbers because we print a and b both till i=50. so use range(25).
      IDK how to do it with odd numbers like 51 because we can't take 25(50 nos), 26(52 nos) and 25.5 is not a thing.

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

      @@YashhC Yes, you are right. Here is the code. It works exactly like you want. I arranged for you :)
      a, b = 1, 1
      print(a)
      for i in range(49):
      print(b)
      b, a = a + b, b

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

      @@talhaordukaya2204 Yes that makes more sense! This can do any amt of numbers ^^

    • @kr.vinay4669
      @kr.vinay4669 8 หลายเดือนก่อน

      Please replace a= 0 to start sequence with 0

  • @hallo-xp2wh
    @hallo-xp2wh 3 ปีที่แล้ว +1

    first one answer
    c=0
    i=1
    print(c+1)
    while i

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

    num = int(input("enter number of digits you want in series (minimum 2): "))

    first = 0
    second = 1

    print("
    fibonacci series is:")
    print(first, ",", second, end=", ")

    for i in range(2, num):
    next = first + second
    print(next, end=", ")

    first = second
    second = next

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

    Just started learning.. converted to for loop
    x=int(input("enter the value"))
    for i in range(0,x):
    if x>av:
    print('out of stock')
    break
    print("candy")

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

    x = int(input("how many candies you want?"))
    if x

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

      still print 10 candies but the avialble candy is 5

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

      in else statement print('
      candies'*5) instead of print('
      candies'*x) or first take available=5, then print('
      candies'*available)
      x = int(input("how many candies you want?"))
      available=10
      if x

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

    a=list(range(1,51))
    a[0]=0
    a[1]=1
    i=2
    while i

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

    This video is awesome. I understood everything thanks a lot

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

    Teaching is an art. thank youuuuuuuuuuu

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

    This has been so incredibly helpful. Thank you!!!

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

    Diff b/w Continue and Pass:
    Continue skip the loop , will not executes the below statements and goes to top of loop, where pass executes the remaining logic. Example below.
    Continue :
    for i in range(11):
    if (i%2==0):
    continue
    print( i , " is odd")
    ----------------------------------------
    1 is odd
    3 is odd
    5 is odd
    7 is odd
    9 is odd
    Pass :
    for i in range(11):
    if (i%2==0):
    pass
    print( i , " is an number")
    ---------------------------------------------
    0 is an number
    1 is an number
    2 is an number
    3 is an number
    4 is an number
    5 is an number
    6 is an number
    7 is an number
    8 is an number
    9 is an number
    10 is an number

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

    Prime no checking:
    x=int(input("enter no:")
    for i in range(2,x,1):
    If x%i==0:
    print("no not prime")
    break
    else:
    print("no is prime")

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

      Its not working for x=1

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

      x=int(input("Enter an ineger: "))
      if x>1:
      for i in range(2,x):
      if (x%i == 0):
      print("Its not a prime number")
      break
      else:
      print("Its a Prime number")
      else:
      print("Its not a prime number")

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

      @@anandhisiva93 1 is not a prime number

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

      This doesn't work for 15

  • @webbrain19
    @webbrain19 9 หลายเดือนก่อน +1

    fib50 = [0, 1]
    for i in range(2, 50):
    fib_next = fib50[-1] + fib50[-2]
    fib50.append(fib_next)
    print(fib50)

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

    Hello Navin, I am basically Mechanical Design Engineer having 6+Years of experience. I am learing python from your videos on youtube. Your concept explanation is fantastic. How i can download practice examples?

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

    And one last pass at the prime number question because I'm having fun with this one in particular. Readded the upper variable to cut down on operations while only storing one more variable. Added checks for anything less than 2. I had fun with this one.
    x=int(input("For what integer would you like to check primeness? "))
    from math import sqrt
    if x

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

      how about this?
      x = int(input("give a number"))
      i = 2
      while i

  • @harshvora1922
    @harshvora1922 6 ปีที่แล้ว +8

    Number is prime or not:
    x = int(input("Enter a number: "))
    i = 2
    while i

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

    For prime numbers:
    x=int(input("For what number would you like to check primeness? "))
    factor=2
    upper=x
    while factorupper:
    print(x,"is a prime number.")
    The point of the upper variable is to limit the number of actual operations needed to check. I'm checking one by one going up a list. But I know for a fact that once the numbers are dividing by are bigger than their results, it's a pointless task. So I'm basically constantly updating my upper bound for what I can check. Granted, I could also just set the while loop to only work when factor is less than x/factor, which does save memory. But I got way too much pleasure figuring out this method.

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

      @Papa Bear Your logic is fine, but you end up checking a lot of unnecessary numbers when in reality, if you find a factor n such that 1

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

    Really great effort Sir..It was really amazing ..!

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

    Everyone explains about the loop but sir you explained the workflow of loop and that's the best. Thank you so much for this course
    I just started now 😊

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

    Hi,
    Your python videos are very useful.
    Can you guide me how to improve my program skills because I don't have any programming knowledge before.

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

    I like your delivery style. For some reason Indian people present this stuff better for me. Thanks for the concise explanation.

  • @vinaybojjalwar
    @vinaybojjalwar 6 ปีที่แล้ว +7

    For 50 fibonacci series
    First=0
    Second=1
    Temp=0
    For i in range(49)
    Print(temp)
    First=second
    Second=temp
    Temp=first+second

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

      0
      1
      2
      3
      5
      8
      13
      21
      output is not the correct Fibonacci series.

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

      though the logic is correct

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

    x = [0,1]
    for i in range(0,50,1):
    if (i

  • @ManishSharma-lt6ig
    @ManishSharma-lt6ig 3 ปีที่แล้ว +1

    a=0
    b=1
    c=1
    print(a,end=' ')
    print(b,end=' ')
    while c

  • @kibreabhaileselassie5136
    @kibreabhaileselassie5136 6 ปีที่แล้ว +14

    When you will start with "Machine Learning"?pls

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

      Not only machine learning we want Artificial Intelligence TOO.

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

    import math as m
    n = int(input("Enter number 'n': "))
    i = 2
    while i 1 and i > m.sqrt(n):
    print("Prime")

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

    #Check the number is prime or not
    num = int(input("Enter no"))
    for i in range(2,num):
    if num % i == 0:
    print("Not prime")
    break
    else:
    print("Prime")

  • @urvi.sharma
    @urvi.sharma 3 ปีที่แล้ว +1

    1) First 50 Fibonacci Numbers
    x = [0,1]
    for i in range(1,50):
    y = x[-1]+x[-2]
    x.append(y)
    print(x)
    2)
    import math as m
    x = int(input("Enter a number"))
    if x == 1:
    print("Neither")
    else:
    for i in range(2,int(m.sqrt(x))+1):
    if x % i == 0:
    print(x, "is not Prime")
    break
    else:
    print(x, " is Prime")

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

      its (1,51) because 50 gets excluded

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

    Hi Navin,
    First of all kudos on your wonderful work!
    I have a doubt here regarding the difference b/w "pass" & "continue".
    Even if we look at the example in this video....even if we had used "continue" instead if "pass", odd numbers could have got printed.
    So, my doubt is that if both the keywords (pass & continue) are asking to ignore the remaining code of the loop 'for that iteration', then what is exactly different about them??
    Thanks in advance!

    • @madhavmishra6937
      @madhavmishra6937 6 ปีที่แล้ว

      Thanks...that cleared the air considerably....

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

      if we use continue it completely skips the whole process and proceeds for the next iteration in the for loop but whereas
      pass gets exit from that particular block and execute the remaining block

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

      like wise in the given code , pass goes to else block and if we use continue it doesnt go to else block

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

    q1:
    a=1
    b=2
    print(a,b,end=" ")
    for i in range(3,51):
    c=a+b
    print(c, end=" ")
    a=b
    b=c
    q2:
    num=int(input("enter your number to check: "))
    for i in range(2,num):
    if num%i==0:
    print("not a prime")
    break
    else:
    print("is a prime")

    here is mine:)

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

    Hi Sir, all your sessions are awesome 👏 Thanku so much🙏🏻 I’ve a question.. can’t we use continue instead of pass statement ?

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

      I have also the same doubt as both works in A same way 😳

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

      Yup

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

      no, you can't use. Those are two different thing. Try to use debug to see what's the difference.

  • @IndianForestService-1
    @IndianForestService-1 6 ปีที่แล้ว

    First 50 fibonacci numbers
    ##
    C=int(input("Enter the value of c:"))
    If c>0:
    i=1
    a=0
    While i

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

    Amazingly explained! Thank you sir!

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

    x= int(input("how many candies do u want"))
    while x81:
    print("candies aren't available")

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

    # 2nd assignment Prime Number Finder
    num = int(input('enter a number
    '))
    prime = True
    for i in range(2,num):
    if(num%i==0):
    prime = False
    break
    if prime:
    print("This Number is prime")
    else:
    print("This Number is not prime")

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

    i=1
    a=0
    b=1
    print(a)
    print(b)
    while i