P_09 Coding Exercises for Beginners in Python | Exercise #2 | Program to swap two numbers

Поделиться
HTML-код
  • Опубликовано: 27 ноя 2024

Комментарии • 210

  • @srikaryenugula
    @srikaryenugula Год назад +17

    The way you are explaining with real life examples is very good🥳
    Your classes are excellent🎉
    One of the best lecturer!

  • @achugh52
    @achugh52 2 месяца назад +2

    the example of how to interchange tea and coffee is perfect and unforgettable. great way of teaching

  • @wisdomkekang896
    @wisdomkekang896 Год назад +8

    U are really good teacher ma
    The real life example you gave immediately gave me a clear understanding of the swappingg

  • @itsmylife4048
    @itsmylife4048 Месяц назад

    Great real life example and it worked. Of course there might be efficient ways to write this but this is what I first thought...
    a=input("enter value of a ")
    b=input("enter value of b ")
    c=a
    a=b
    b=c
    print("a is " +a)
    print("b is " +b)

  • @saipukale8457
    @saipukale8457 10 месяцев назад +9

    Another way to swap numbers
    a = input("a = ")
    b = input("b = ")
    a,b =b,a
    print("a = "+a)
    print("b = "+b)

  • @acharyaguy
    @acharyaguy 2 года назад +13

    a=input(print("Enter value for a: "));
    b=input(print("Enter value for b: "));
    print("Value of a: ",b);
    print("Value of b: ",a);

    • @Lildev19
      @Lildev19 Год назад +5

      you can't use this
      because the question is to swap the value which means the value of "a" should swap to "b" and the value of "b" should swap to "a"
      at the end when you print the variable "a" it should print the value of "b"
      it's not about showing the value the question is about to change the value from one variable to another vice-versa
      I hope this comment will help you, but it's been 11 months you commented to this video but i replayed now hope you understand this.

  • @Kingkong_1013
    @Kingkong_1013 4 месяца назад +2

    Aap teaching krte krte bich me smile krte ho ,to hmare face par bhi smile ata hai😂

  • @swarpranalimusic6651
    @swarpranalimusic6651 Год назад +3

    a=input("Enter Value of a = ")
    b=input ("Enter Value of b =")
    print ("a = " + b)
    print ("b = " + a)

  • @devSackey
    @devSackey Год назад +17

    a = input("Enter the first number...")
    b = input("Enter the second number...")
    # swapping the value
    temp = a
    a = b
    b = temp
    print(a)
    print(b)

    • @crazyeditzz2437
      @crazyeditzz2437 5 месяцев назад

      It's not correct

    • @devSackey
      @devSackey 5 месяцев назад

      @@crazyeditzz2437 please tell me where am wrong

    • @crazyeditzz2437
      @crazyeditzz2437 5 месяцев назад

      @@devSackey I tried print(a) and print(b) then in python it shows only a & b but not the values like a=2 and b =3 I hope u understand

    • @devSackey
      @devSackey 5 месяцев назад +1

      @@crazyeditzz2437 i understand but i also tried it here and it showed me the value of a and b as required

    • @crazyeditzz2437
      @crazyeditzz2437 5 месяцев назад

      @@devSackey yeah it's working good job🥰 but we should get it as a=some number and b= some number it should indicate

  • @santhoshk2722
    @santhoshk2722 Год назад +7

    Another method for swapping is
    a = int(input("Enter number a: "))
    b = int(input("Enter number b: "))
    a = a+b
    b = a - b
    a = a - b
    # Use f-String to print this
    print(f"a = {a}
    b = {b}")

  • @SsgulRajhani
    @SsgulRajhani Год назад +1

    Amazing jenny ..
    First program i can do it with my self with complete logic
    Thanks

  • @tinklingclaps2499
    @tinklingclaps2499 Месяц назад

    Wow!You have exemplified all concepts really well.

  • @randomhuman5208
    @randomhuman5208 4 месяца назад

    I listened to your lectures man for my python final exams I passed tysm mam

  • @pratapsatyam
    @pratapsatyam 2 года назад +5

    Thank you for honest teaching 🙏

  • @chamara854
    @chamara854 Год назад +2

    Thanks your teaching very interest, I actually like your eyes also it's beautiful.

  • @TheOdiaTrader
    @TheOdiaTrader 2 года назад +1

    *itni sundar maam 😍😍mujhe btech me milti to me Abhi Coding expert ban chhuka hota!* 😰

  • @pragathi068
    @pragathi068 2 года назад +5

    a,b=1,2
    a,b=b,a
    print("after updation a= "+str(a))
    print("after updation b= "+str(b))

  • @limitess9539
    @limitess9539 Год назад +1

    a=float(input("Enter value of a: "))
    b=int(input("Enter value of b: "))
    c=a #c==a a==a b==b
    a=b #c==a a==b b==b
    b=c
    print(f"a = {a}")
    print(f"b = {b}")
    What's interesting is that it changes types too, a is now int type and b is now float type and says 10.0

    • @Rishithabajjuri
      @Rishithabajjuri Год назад

      why f is required in the print statement at last what does it mean bro?

  • @yashaggarwal6013
    @yashaggarwal6013 Год назад

    a = input("enter value of a = ")
    b = input("enter value of b = ")
    a,b = b,a
    print("a = " + a)
    print("b = " + b)

  • @muhsinbinirshad
    @muhsinbinirshad 6 месяцев назад +1

    a = input("Enter the value of a: ")
    b = input("Enter the value of b: ")
    # Display initial values
    print("The initial value of a =", a)
    print("The initial value of b =", b)
    # Swap the values using a temporary variable
    temp = a
    a = b
    b = temp
    # Display swapped values
    print("The swapped value of a =", a)
    print("The swapped value of b =", b)

  • @lilliana_es
    @lilliana_es 9 месяцев назад

    7:05 thank you madam, love your teachings

  • @Aristokrat92
    @Aristokrat92 6 месяцев назад

    I love it, you made great job. Your explanation so simple and amazing same time! Thank you very much, Jenny! Also I like when you draw examples and show everyhing how it works!😍

  • @venkatgunda7182
    @venkatgunda7182 9 месяцев назад

    #swap 2 numbers
    a = 20
    b = 30
    c=b
    b=a
    a=c
    print(a,b)

  • @priya-we2hg
    @priya-we2hg 2 года назад +3

    जीवन में कठिनाइयां हमें बर्बाद करने नहीं आती है, बल्कि यह हमारी छुपी हुई सामथ्र्य और शक्तियों को बाहर निकालने में हमारी मदद करती हैं कठिनाइयों को यह जान लेने दो की आप उससे भी ज्यादा कठिन हो।... 👍🏻👍🏻

  • @abhishekdubey9920
    @abhishekdubey9920 2 года назад

    Fast content delivery is important to relay on it. When exams are over then what you are uploading daily its good

  • @ThandaraDigital
    @ThandaraDigital Год назад +1

    The tutorial is so easy to follow and understand.

  • @kartheek6495
    @kartheek6495 2 года назад +2

    a= 1
    b=2
    a,b = b,a
    print(a,b)

  • @ONLINESTUDYHELPER
    @ONLINESTUDYHELPER 2 года назад

    Best channel i ever saw❤❤

  • @fbushphone
    @fbushphone 7 месяцев назад

    Great teaching style, thank you for sharing your knowledge

  • @man07imperfext
    @man07imperfext 5 месяцев назад

    a = input("Input your first number: ")
    b = input("Input your second number: ")
    swap = a
    a = b
    b = swap
    print("
    a = " + a + "
    b = " + b)

  • @_yes_you_are_right_214
    @_yes_you_are_right_214 2 года назад +1

    Okie...

  • @micmike
    @micmike 2 года назад

    yup, got it. I did have an unexpected output because I put a space in my code line but when I removed it i got the same result as you

  • @abdulhannan.018
    @abdulhannan.018 Год назад

    a = input("Enter the value of a: ")
    b = input("Enter the value of b: ")
    print(a,b)
    c = a # c = 1
    print(a, b, c)
    a = b # a = 2
    print(a,b,c)
    b = c # b = 1
    print(a,b,c)
    # basically we take another container c which is empty.
    # 1. c mein a wali value store krdi that is (1)
    # 2. a mein b wali value store krdi that is (2)
    # 3. b mein c wali value store krdi which was basically a ki value that is (1)
    # summary: aik khali container c liya, us mein a ki value daal di jis se a ki value a main aue c main dono main hogyi,
    # phir a main b ki value daal di jis se b ki value swap hogyi,
    # at the end b main c ki value daal di which was basically a ki value jis se a ki value swap hogyi
    print(a)
    print(b)
    Enter the value of a: 1
    Enter the value of b: 2
    1 2
    1 2 1
    2 2 1
    2 1 1
    2
    1

  • @AmazingCreationsStudio
    @AmazingCreationsStudio 11 месяцев назад

    a = input("Enter a value a: ")
    b = input("Enter a value b: ")
    temp = " "
    print("before:
    ")
    print( a + "," + b)
    temp = a
    a = b
    b = temp
    print("After:
    ")
    print( a + "," + b)

  • @Advanceauto999
    @Advanceauto999 Год назад

    a = 11
    b = 7
    temp = a
    a = b
    b = temp
    print(a)#7
    print(b)#11
    output
    7
    11
    Process finished with exit code 0

  • @praveenvaddadi194
    @praveenvaddadi194 2 года назад +1

    Glasses are cool ! Jenny madam

  • @TimesUp24
    @TimesUp24 Год назад

    val1 = input("enter the value of A = ")
    val2 = input("enter the value of B = ")
    print("A = " +val2)
    print("B = " +val1)

    • @Lildev19
      @Lildev19 Год назад

      hi, please go through the question and understand properly, You can't use this when an interviewer asked the question
      because the question is to swap the value which means the value of "a" should swap to "b" and the value of "b" should swap to "a"
      at the end when you print the variable "a" it should print the value of "b"
      it's not about showing the value the question is about to change the value from one variable to another vice-versa
      I hope this comment will help you.

  • @lokeshraybarman7007
    @lokeshraybarman7007 2 года назад

    You are inspiration mam ❤️💕💕💕

  • @murungicalvin5235
    @murungicalvin5235 Год назад +2

    Thank you so much. I find your tutorials much easier to understand. I hope to continue learning this python programming

  • @vasubhalani1636
    @vasubhalani1636 Год назад

    Ans of que at 5:10 input() is return string so we concate in print("a=" + a)

  • @MeenakshiAchutha
    @MeenakshiAchutha 4 месяца назад

    we can concatinate the integer also because the input function every value it taken as string

  • @-SakuraNoHana-
    @-SakuraNoHana- Год назад

    another way:
    a=int(input("Enter value of a="))
    b=int(input("Enter value of b="))
    num_1=b
    num_2=a
    print(f"a={num_1}
    b={num_2}.")

  • @sagaswami2668
    @sagaswami2668 Год назад

    Thank you so much mam for next level of teaching

  • @tanishshriyan-ho2yt
    @tanishshriyan-ho2yt 5 месяцев назад +2

    we can do this also ??
    x = input("Enter a number a:" )
    y = input("Enter a number b: ")
    print("a =", y)
    print("b = ", x)

  • @sajanbrother
    @sajanbrother 2 года назад

    Nice looking ma'am and good teaching style, i love you ma'am 🙏🏻❤️🙏🏻🙏🏻

  • @MadheshwaranR-rs1yc
    @MadheshwaranR-rs1yc Год назад

    num1 = input ("value of a")
    num2 = input ("value of b")
    num1 = num2
    num2 = num1
    Print ("num1
    num2")

  • @nehamaurya27
    @nehamaurya27 2 года назад

    Mam you look good without glasses.... 😊😊

  • @afshannamreen5214
    @afshannamreen5214 6 месяцев назад

    thank you ma'am great explanation🙂

  • @surinder7765
    @surinder7765 Год назад

    Thanks mam god bless you 🙏

  • @SubhashSB-gsoc
    @SubhashSB-gsoc 10 месяцев назад

    a=input("enter the value of a:")
    b=input("enter the value of b:")
    print("a="+b)
    print("b="+a)
    We can use this right

  • @jagadeeshkj5561
    @jagadeeshkj5561 2 года назад +1

    Understood.

  • @techiebd_plyr_wb6246
    @techiebd_plyr_wb6246 2 года назад

    a=int(input("Enter First Number"))
    b=int(input("Enter Second Number"))
    print("two numbers are:
    ")
    print(a,b)
    c=a
    d=b
    b=c
    a=d
    print("swaped numbers are:
    ")
    print(a,b)

    • @JennyslecturesCSIT
      @JennyslecturesCSIT  2 года назад +2

      Use only one extra variable to swap

    • @techiebd_plyr_wb6246
      @techiebd_plyr_wb6246 2 года назад

      @@JennyslecturesCSIT
      done..Im sorry for late reply
      a = input("a: ")
      b = input("b: ")
      c=a
      a=b
      b=c
      print("a: " + a)
      print("b: " + b)

  • @satya1459
    @satya1459 Месяц назад

    may be this is easier try this
    a=10
    b=12
    a,b=b,a
    print(a)
    print(b)

  • @ZainNazeer-wf2gi
    @ZainNazeer-wf2gi 2 года назад

    very nice tutorials

  • @glps369
    @glps369 Год назад

    Thank You So
    Much

  • @visionstatus2231
    @visionstatus2231 7 часов назад

    A,B = B,A

  • @satyarajkumarsatiwada410
    @satyarajkumarsatiwada410 Год назад

    a=input ()
    b=input ()
    Print("a = " +b)
    Print("b = " + a)
    Out_put:
    a = 2
    b = 1
    In_put:
    1
    2
    Is it right?

  • @UttamPrakash
    @UttamPrakash 9 месяцев назад

    a=input("your value a:-")
    b=input("Your value b:-")
    print("a=" + b)
    print("b=" + a)
    it is simple why use temp?

  • @pushpindersharma4880
    @pushpindersharma4880 Год назад

    You are Good

  • @umershahzad8504
    @umershahzad8504 2 года назад

    Thanks mam making for this course

  • @parth7221
    @parth7221 2 года назад

    Nice specs u look different but still look like my Mercury ❤️

  • @harishkmurali3757
    @harishkmurali3757 2 года назад

    Thank you so much mam❣️

  • @shoaibVELO
    @shoaibVELO 2 года назад +1

    b=input("enter value of a ")
    a=input("enter value of b ")
    print("b= "+b)
    print("a= "+ a)
    please reply tell me if did anything wrong here

  • @harshaharsha6681
    @harshaharsha6681 Год назад

    Superb🎉🎉🎉🎉

  • @khushityagi5930
    @khushityagi5930 2 года назад +8

    Hello mam....can you tell me some important questions of c of chapter (arrays,pointers,strings, structures, file handling in c ) bca exams

  • @pradeepa7026
    @pradeepa7026 2 года назад

    Simply write
    a,b=b,a

  • @mnmelodious9411
    @mnmelodious9411 2 года назад

    apologize due to work I missed 1 2 lecture thanks a million.
    queen of code ❤️❤️

  • @pavanamballa255
    @pavanamballa255 2 года назад +1

    I love mam ❤️❤️❤️

  • @BrainyQuizZone
    @BrainyQuizZone 2 года назад

    Thank you so much mam🙏🙏🙂

  • @yoyogameryt1418
    @yoyogameryt1418 2 года назад +5

    Hello mam I have a question that
    We can do swaping like this but this is not swaping but like swap
    A=input("enter value of a=")
    B=input("enter value of b=")
    Print("a=",B
    "b=",A)

    • @santhoshk2722
      @santhoshk2722 Год назад

      use f-string for this

    • @muqeethurrahaman
      @muqeethurrahaman 7 месяцев назад

      @@santhoshk2722 Could you please rewrite it in f string function?

  • @harshavardhanhoogar6658
    @harshavardhanhoogar6658 Год назад

    b=input("enter the value of a=")
    a=input("enter the value of b=")
    print("a=" +a)
    print("b=" +b)
    is it correct mam?

  • @sumantaff8446
    @sumantaff8446 2 года назад

    Chashma mei achhi lag rahi mam. Superb

  • @MayankYADAV-qs1ql
    @MayankYADAV-qs1ql 2 года назад +1

    Todays exercise -
    a=input("X= ")
    b=input("Y= ")
    c=a
    a=b
    b=c
    print("X= "+a)
    print("Y= "+b)

    • @vimalkumar281
      @vimalkumar281 2 года назад

      a=input("enter value of a=")
      b=input("enter value of b=")
      a=b
      b=a
      print("a=2")
      print("b=1")
      Is it right or wrong?

  • @eswarkorada1954
    @eswarkorada1954 2 года назад

    thank you mam

  • @Arayankodesouth
    @Arayankodesouth 2 года назад

    ❤ Awesome!!!!!!!!!!!!!!!!!

  • @razeenrahuman7513
    @razeenrahuman7513 3 месяца назад +1

    Ma'am ,I think, I can use the code like this, can't I....?
    Input("enter value of a=")
    Input("enter value of b=")
    Print("a=" , b )
    Print("b=" , a )
    Ma'am am I right or wrong???

  • @thecloudterminal
    @thecloudterminal Год назад

    Thank you for this lecture mam 🙏

  • @santoshnarwad3528
    @santoshnarwad3528 2 года назад

    Temporary container

  • @maheshkasthuri5034
    @maheshkasthuri5034 Год назад

    I like ur real life examples mam 😂

  • @LingeshhvarenKA
    @LingeshhvarenKA 9 месяцев назад

    #swaping
    num_1=int(input("Enter number 1 : "))
    num_2=int(input("Enter number 2 : "))
    num_1,num_2=num_2,num_1
    print("Number 1 is ",num_1)
    print("Number 2 is ",num_2)

  • @karthisk1243
    @karthisk1243 Год назад

    ma'am, you have said that by default input will take any values as a string,but if use interger (int) function before the input,we cannot need to concatate (+) function,right. and did you get my point??

  • @adityajasud3961
    @adityajasud3961 2 года назад

    Mam ek simple aap our website ki kuch coding karke kisi koi opreting model me install ka koi video banayena

  • @a.sirishareddy6908
    @a.sirishareddy6908 Год назад

    Mam the value in input is string by default and the string in the print can concatenate

  • @Saint_Piper
    @Saint_Piper Год назад

    I did it this way
    A=input("enter value of a")
    B=input("enter value of b")
    Temp="a"
    a="b"
    b="temp"
    The result was the same thing. The value swapped.

  • @tinklingclaps2499
    @tinklingclaps2499 Месяц назад

    Can you make a video with topics like escape,traverse,

  • @BaldevPurohit
    @BaldevPurohit 2 года назад

    everything is understandable easily with help of tea & milk example. and also program is very simple to understand. but i have one query on Concatenates e.g. "coma(,), plus(+),etc.. i didn't understand why we are using (+) or (,) for this swap thing? can you please torch on that point?

    • @BaldevPurohit
      @BaldevPurohit 2 года назад

      Just watched 8th lecture again and i got my answer that it is print(string & integer) e.g. print("a=" +/, a) ✔️ 🤩

  • @devil_shot5609
    @devil_shot5609 Год назад

    Mam your explanation is well but,we want some more examples

  • @Choomu_Vlogs
    @Choomu_Vlogs 8 месяцев назад

    i got the answer 2=1

  • @harshita7802
    @harshita7802 2 года назад

    Thank you so much mam for this course 😊

  • @syedsohel9701
    @syedsohel9701 2 года назад

    Mam simply I was,
    a=input("enter value of a")
    b=input("enter value of b")
    Print(b)
    Print(a)
    And I got it , is it right??

    • @okappaw
      @okappaw 2 года назад

      i tried this but saw that, when i placed two papers in my palm, i could only swap putting one down to empty another...

    • @sandeepsandy3917
      @sandeepsandy3917 2 года назад

      U have to interchange those variables value .. not a places in console bro... Whenever u print (a) . U must be get the (b) value in console and vice versa.. that's interchange/swapping concept

  • @veerabhadrayyapmathad7491
    @veerabhadrayyapmathad7491 8 месяцев назад

    a, b=10, 20
    print("a:%d b:%d" %(a, b))
    a, b = b, a
    print("a:%d b:%d" %(a, b))
    -------------------------------------
    output:
    a:20 b:30
    a:30 b:20

  • @SimenSooz
    @SimenSooz 2 года назад

    a=input("enter value of a ")
    b=input("enter value of b ")
    c=a
    a=b
    b=c
    print("a= "+ a)
    print("b= "+ b)

  • @rajeshprasad3991
    @rajeshprasad3991 Год назад

    how to store two numbers in two different variable using one input statement
    for eg -
    if I say -
    Enter two numbers

  • @vijayramakrishnan6838
    @vijayramakrishnan6838 Год назад

    str to int

  • @amansahu1096
    @amansahu1096 2 года назад

    Thank you for this course 😊 mem

  • @nsaikumar4771
    @nsaikumar4771 2 года назад

    Why should u use +a we can use print("a=" a)

  • @goo-pro5648
    @goo-pro5648 Год назад

    a,b=b,a

  • @vaishnavwakchaure959
    @vaishnavwakchaure959 2 года назад

    Mam please remove your specs, we get distracted from it!!!!
    But I really likes your videos and content:)

  • @WbananeW
    @WbananeW 7 месяцев назад

    First I thought you could just swob a and b at the same time.

  • @MaryIheanaetu
    @MaryIheanaetu Год назад +1

    am a little bit confused in the swapping logic.