Python Tutorials - Program To Print Sum Of Digits Of Positive Integer Number

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ก.ค. 2024
  • In this Python programming video tutorial we will learn about the program to print the sum of all the digits in entered input.
    To write the program we need to follow three steps.
    1. Take input
    2. get the digit from the number and add them
    3. Print the sum
    Here we are using simple mathematic operations.
    #PythonProgramming #Python
    For more free tutorials on computer programming
    / amulsacademy
    / amulsacademy

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

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

    Thank you @amuls academy for clear explanation it's helps a lot to us to improve programming skills
    I went through almost all videos.

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

    Today I am searching my doughts coming your videos it's really helpful to me i am watching all videos of python

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

    You are very intelligent and can explain in a very simple way

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

    Awesome explanation loved it :)

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

    Excellent
    This is the first tym I have seen ur video
    Expecting more programs like this

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

    Please could you upload writing of programs using function. It’s very important

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

    Thanks, well explained.

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

    Why do we use 10 when performing floor and modulo division?

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

    My favourite python channel! Thank you for efforts!

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

    Thank you so much for help!

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

    I need to compute a column of integers with python. I have some of the code but need the other code.

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

    Is there video for cgi program with xampp apache in python

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

    what about
    if we have input as 2
    and out put as
    24
    2+22

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

    Thank you vey much madam....

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

    Mam do a video for sum of digits without loops

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

    Good job keep it up 👍🏻

  • @srinithi.s7344
    @srinithi.s7344 หลายเดือนก่อน

    Tq mam🎉🎉
    clear explanation❤❤

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

    Why is it necessary to take result =0 or 1 pls reply. Tommorow is my practical.

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

    Thank you

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

    Thank you so much

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

    THANK YOU SO MUCH

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

    Thank you, you saved my grade

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

    Thanks a lot

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

    Thank you so much! This was really helpful.

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

    Such an awesome explanation 🤗

  • @JOSHUA.24
    @JOSHUA.24 2 ปีที่แล้ว

    what if you input a number 5 then the result = 15?
    thank you :)

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

    Thank you for helping us out with so well explained and easily understandable manner.👍

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

    Thanks a lot you explain in details so this is the methodology of algorithms

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

      Glad it was helpful!

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

      @@AmulsAcademy mam y cant you use len method on integer when you can use len method in list which can contain integer.
      I.e len( list1)

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

      You can use len on it era less and integer number is not an iterable :)

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

      @@AmulsAcademy but you can use it on a list containing integers.
      So how is it possible not to use in integers

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

    Thanks a lot Sister. Could you please help me to do this module with function?

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

    Very nice voice ❤️ and nice explaination

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

    Thank you so much for this video..

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

    I need only a single digit sum... what to do?

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

    Good Effort...keep on

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

    Very good

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

    Mam I am Your True Fan..I am Following Your Every Single Video.Mam I have a request It,s very urgent..For My Campusing purpose i need to learn data struture ..Please Mam Make video series on data structure using python.plz mam plz

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

      Thank you so much:)
      Sure i will do:)
      I will already uploaded videos on list tuple dictionary sets.
      Stack queue will do it soon:)

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

    Best channel I have ever seen. Thank you for existing

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

    Sisy.. plz put video for representing grey code...It will be very useful as no one has revealed the video in this topic

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

    I have a doubt in the programme please help
    Str="ABCD"
    Str[0:3]
    Output- 'ABC'
    But why
    Str[3] is 'D'
    In case of [0:3] and only [3] both are the end values according to [start:stop:step] start and step are optional but in case of [3] why it wont do 3-1 but in [0:3] or [:3] it will do 3-1
    Please reply...

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

      Because slicing strings is different from accessing single character.
      in slice method end is exclusive that's why str[0:3] is "ABC"
      in the case str[3] you are accessing single character from the string using its positve index.
      It will give you the character present in that index.
      we will use slice when we want to get sub string from the string.
      Both are different.
      :)

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

      Amuls Academy :)

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

      Both are different str[3] is indexing which starts from 0 and when we use : it slice it excluding last digit which is D

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

    Thankyou

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

    if i give num as 178 in same code i am getting 16 but answer should be 7
    how to do?

  • @Rahulkumar_791
    @Rahulkumar_791 11 หลายเดือนก่อน

    How to do sum in any base?

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

    good explanation

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

    thank you amulya

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

    Can you upload a video on insertion sort

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

    when i giving num = 1234
    the result is 10
    i need answer 1
    0 + 1
    how to add result a;so

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

      Try this:
      num = 12345
      n = num
      while len(str(num))>1:
      result=0
      for i in str(num):
      result = result+int(i)
      num=result
      print(result)

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

    could you please tell me how to separate a value input= 123 output=1 2 3
    I have seen your video its a detailed explanation of python thank you

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

      You can use loop to print value separately 😊

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

    sum of every three integer put one vedio mam

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

    Thank you so much ❤️

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

      Welcome :)

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

      @@AmulsAcademy Mam can u pls help me with these questions...1. Write a program to enter marks obtained by a student in 5 subject. Then find average of marks.
      2. Repeat the above program for n students.
      3. Write a program to enter a number. Find sum of digits and then find factors of the sum of digits.
      Eg if number is 564 then sum is 15 and factors are 1,3,5,15

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

    How will I count no of note from given amount
    Pls reply 🥺

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

    Thank a lot....I got clear explanation

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

      How to print this sequence:
      Input : 1 2 3 4 5
      Output: 3 6 10 15

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

      Thank you :)

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

      can you explain more about the sequence :)

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

      @@AmulsAcademy To print the consecutive sum of numbers in an array
      Input : 1,2,3,4,5
      Output: 3,6,10,15

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

      @@AmulsAcademy Thanks

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

    can` we do this with while loop???

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

    Amulya mam is the best :)

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

    -123 I/p lete he to o/p kya hoga ? Aor kese?

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

    Is there a loop ? 🤨

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

    Mam what is the use of )) instead cant we just use ) ??

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

    helpful

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

    How to slove only sum of even digit and odd digit ,what type condition use

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

    in the above out put you give 1234 then 1+2+3+4 = 10 but i want output in single digit like 1+2+3+4=10 =1+0=1 how to execute it to get single digit output can u help me.

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

      n = int(input("enter the number:"))
      while True:
      result=0
      for i in str(n):
      result = result+int(i)
      if result>9:
      n=result
      else:
      print("sum in single digit is:",result)
      break
      :)

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

      @@AmulsAcademy how do do this using functions?

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

    The data is from a file. Yes, I can open and read the file.

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

    def add_num(n):
    num = [int(x) for x in str(n)]
    result = sum(num)
    return result

    • @jpeg.600x2
      @jpeg.600x2 3 ปีที่แล้ว

      i fucking love you

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

    Beautiful voice

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

    Tq so much

  • @PrasannaKumar-zx7gr
    @PrasannaKumar-zx7gr 4 ปีที่แล้ว +2

    👍👍 .....

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

    Madam plz do more programs on lists

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

    best ever👍🇵🇰❤

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

    In last line why are u write result...plz tell me.. ...in your last videos you write input value as num

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

      Because we stored our result(sum) in the variable "result" .
      :)

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

    Thanku..

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

    11:45 find outing😅

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

    Could you please tell me program to get out put as5+6+7=13=1+3=4 mam.

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

      Use a loop, until the length of final result becomes 1, add its digits 😊

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

    MAAM IT WAS A GREAT VEDIO THANKS

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

    Num=int(input("Please Enter the Numbers))
    Res=0
    For I in str(Num) :
    Res=Res+int(Num)
    Print (Res)
    Without the help of str function do we have any other method

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

      Yes
      def reversenum(num):
      ans = 0
      leng = len(str(num))
      for i in range(leng):
      a = num % 10
      ans = ans + (a * (10 ** (leng - i - 1)))
      num = num // 10
      return ans
      a=11222211
      print(reversenum(a))

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

    Ma'am you do explain very nicely and in an understandable and simple way.
    Ma'am please can you help me execute this program in python:
    A program which repeatedly print for a sentence (string) or for 'q' to quit.
    Upon input of a sentence s, print the string produced from s by converting each lower case letter to upper case and each upper case to lower case.
    All other characters are left unchanged.
    Ma'am I will be really glad if u help me. This is from Sumita Arora book of class 11.
    Ma'am please make a video on this or post the full program. Please ma'am ! Please !

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

      You can try this:
      while True:
      str1 = input("enter the string:")
      str2 = str1.swapcase()
      print(str2)
      n = input("want to quit press q else press any button:")
      if n=="q":
      break
      :)

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

      Thank you very much ma'am !

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

    Congratulation I like u voice so cute🖤

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

    I love u

  • @RohanSingh-xr8ty
    @RohanSingh-xr8ty 5 ปีที่แล้ว

    what if I want to add 10 +12 +13 (basically double or triple digit numbers?)

  • @SriRam-ce3hi
    @SriRam-ce3hi 3 ปีที่แล้ว +1

    num=input ("enter the num")
    sums=0
    for i in num:
    sums=sums+int(i)
    print(sums)
    It is working for me. Is it a efficient or wrong code reply plz

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

    input 12 13 14 15
    output 3 4 5 6
    how to implement this mam

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

      Use a loop and you can write the program :)

  • @KIRANKUMAR-vp3jr
    @KIRANKUMAR-vp3jr 5 ปีที่แล้ว

    Get the result large number to single digit

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

    How I can get 6 from 15?

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

    please someone help me on my question

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

    100th commend😁😁

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

    Try:
    a=input ("entr no.")
    sm=0
    for i in range (0, len (a)):
    sm=sm+int (a [i])
    print (sm)

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

    I need program 123 product is 6

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

      You can modify this program :)

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

    n=input('Enter number: ')
    sum=0
    for i in n:
    sum+=int(i)
    print(sum)

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

    How to find no.of letters and numbers for given string
    Like this
    If user enters irfan123666
    Output
    Letters =5
    Numbers = 6

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

      Try this:
      string = input("enter the string:")
      numbers = 0
      letters = 0
      for i in string:
      if i.isdigit():
      numbers = numbers+1
      else:
      letters = letters+1
      print("letters:",letters)
      print("numbers:",numbers)
      #Space will be treated as letters.

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

      @@AmulsAcademy thank you ☺️

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

    f=int(input("Number:"))
    h=str(f)
    summ=0
    for i in range(len(h)):
    s=summ+int(h[i])
    summ=s
    print(summ)

  • @abhigoyal-bv9yf
    @abhigoyal-bv9yf ปีที่แล้ว

    why are people giving good replies i didn't even understand a thing

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

    This result can be achieved by recursion
    def SumDigit(number):
    if number == 0:
    return 0
    else:
    return number%10+SumDigit(number//10)
    print(SumDigit(int(input('Enter a positive #: '))))

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

    Thanks mam.
    I have don't.
    I will give one value "120".
    I want print "1+2+3+4+5" or "1*2*3*4*5". like this type how.

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

      You can try this:
      Inverse factorial function:
      def factorial_cap(num):
      n = 1
      i = 1
      while n < num:
      i = i + 1
      n = n * i
      return i
      num = int(input("enter the factorial of any value:"))
      n = factorial_cap(num)
      print(num,"=",end=" ")
      for i in range(n,0,-1):
      print(i,end=" ")
      if i==1:
      break
      print("*",end=" ")
      :)

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

    def sumofdigit(n):
    S=0
    for i in str(n):
    S+=int(i)
    return S

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

    is this chintu from whitehat jr ????

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

      No :)

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

      @@AmulsAcademy i know i was just joking 😂.....by the way your content is very good

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

    code :-
    num = int(input("enter the string:-"))
    print(sum([ i for i in range(num+1)]))

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

      This doesn't work, please check...

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

    This code is also works:
    def sum(num):
    sum=0
    for i in num:
    sum=int (i)+sum
    print("the sum of num is",sum)
    num=input("please enter a number")
    sum(num)

  • @BSMheybem
    @BSMheybem 13 วันที่ผ่านมา

    !!!!!!!!!!!!!!6

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

    Finding sum of digits of a number until sum becomes single digit
    def singledig(n) :

    if n == 0 :
    return 0

    elif n % 9 == 0 :
    return 9

    else :
    return n % 9
    a = int(input("enter number :"))
    print(singledig(a))

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

    madam are you speak telugu

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

    You're in the wrong business, you should be making $50,000k per episode doing voice work lol

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

    R u male or female?

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

      Female :)

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

      Amuls Academy I thought you are a little boy 😅😅. How old are u mam?

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

      I am not little boy, i am a graduate :)

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

      Ohh then u got a very cute voice😃

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

      Thank you :)

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

    Useless

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

    Thank you