Python Variables | Python Variables & Data Types | Python Tutorial | Python Programming |Simplilearn

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

ความคิดเห็น • 47

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

    "🔥Caltech Post Graduate Program In AI And Machine Learning - www.simplilearn.com/artificial-intelligence-masters-program-training-course?H5OneJb-U&Comments&TH-cam
    🔥IITK - Professional Certificate Course in Generative AI and Machine Learning (India Only) - www.simplilearn.com/iitk-professional-certificate-course-ai-machine-learning?H5OneJb-U&Comments&TH-cam
    🔥Purdue - Post Graduate Program in AI and Machine Learning - www.simplilearn.com/pgp-ai-machine-learning-certification-training-course?H5OneJb-U&Comments&TH-cam
    🔥IITG - Professional Certificate Program in Generative AI and Machine Learning (India Only) - www.simplilearn.com/iitg-generative-ai-machine-learning-program?H5OneJb-U&Comments&TH-cam
    🔥Caltech - AI & Machine Learning Bootcamp (US Only) - www.simplilearn.com/ai-machine-learning-bootcamp?H5OneJb-U&Comments&TH-cam"

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

    1. x,y = 5,10
    2. x,y = y,x
    3. print (x)
    4. print (y)
    # result will be 10,5

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

      Hi Nawaz, this code is perfect and correct!. Kudos!

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

    a=100
    b=200
    print("before swap",a,b)
    temp=a
    temp2=b
    b=temp
    a=temp2
    print("after swap",a,b)

  • @Rohit-te9dr
    @Rohit-te9dr 6 ปีที่แล้ว +3

    A=100
    B=200
    Print("before swap" A, B)
    A=A+B
    B=A-B
    A=A-B
    Print("after swap" A, B)

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

    a,b=100,200
    a,b=b,a
    print("This A value",a)
    print("This B value",b)
    Ans:
    This A value 200
    This B value 100

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

      Thanks for watching our video and sharing your thoughts. Do subscribe to our channel and stay tuned for more. Cheers!

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

    a = 100
    b = 200
    a,b = b,a
    print(a,b)
    To make a quick swap:)

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

    x=100
    y=200
    print('before swap',x,y)
    temp=x
    x=y
    y=temp
    print('after swap',x,y)

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

      Wow! you got the right answer! kudos! Do check out our other tutorial videos and subscribe to us to stay connected. Cheers :)

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

    x,y=1,2
    x,y=y,x
    Print(x,y)

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

    Using third variable
    Temp=x
    X=y
    Y=Temp
    Without using third variable
    X=X*y
    Y=x-y
    X=x_-y

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

      Bro pls can u send me exact definetions for float string integer...

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

      Float - It represents real numbers like 3.14159 or -2.5
      String - Text which is denoted by single or double quotes
      Integer -It represents positive or negative whole numbers like 3 or -512

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

    Before swapping
    A=100
    B=200
    After swapping
    A,B=200,100

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

      Hi Santosh, this code is perfect and correct!. Kudos!

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

    a=100
    b=100
    (b,a)=(a,b)
    print(a,b)

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

    a = 100
    b = 200
    print(a, b)
    c = 200
    b = a
    a = c
    print(a, b)

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

      Hi Steve, thanks for replying. We have made a small correction in the code. The mistake is if you are assigning a new value to c, then that means you haven't swapped the values. Check the corrected code below:
      a = 100
      b = 200
      print(a, b)
      c = b
      b = a
      a = c
      print(a, b)

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

    A,B= (b,a)
    Print(A,B)

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

      It's wrong. You need to swap the values of the variables not create new variables. Hope that helps!

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

    a=100
    b=200
    a,b=b,a
    print(a,b)

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

    A=100
    B=100
    A,B = B,A
    Print (A)
    Print (B)

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

      Hi Bharath, you found the right answer. Kudos!
      Do show your love by subscribing our channel using this link: th-cam.com/users/Simplilearn and don't forget to hit the like button as well. Cheers!

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

    why do not use pycharm

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

    M=("g")..it's showing string not tuple why

    • @e-hr5314
      @e-hr5314 5 ปีที่แล้ว

      Python recognizes this as a string. because it only stores one value inside it. If you want to turn it into Tuple type, you should type it this way: ("g",)

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

    A=100
    B=200
    C=A
    A=B
    B=C

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

    A=100
    B=200
    C=A
    B=C
    print(B)

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

      Sorry, wrong answer! In this process, you have lost the original value of B.The right answer is below:
      a=100
      b=200
      c=a
      a=b
      b=a

  • @SahilKhan-qu5tb
    @SahilKhan-qu5tb 6 ปีที่แล้ว +1

    a=100
    b=200
    c=a
    b=c
    c=b
    a=c

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

      Wow! you got the answer right. Kudos!

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

      Initially, A holds 100, B holds 200. To swap values, in Python a simple code would be A,B=200,100. Now A would hold 200 and B, 100

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

      >>> a,b=100,500
      >>> a,b=b,a
      >>> print(a,b)
      500 100
      >>>

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

      That's right as well.