-->
Wednesday, June 29, 2022
Add all the Even and Odd digits of a number | Python Program
FindError
Home
Catagories
C Programs
C Graphics
Python Programs
About
contact
Home
About
Contact
Python Programs
Swapping using 3rd variable
Swpping without using 3rd variable
Even or Odd check
Add all digits of a number
Add all Even and Odd digits of a number
Add all the Even and Odd digits separately of a number
Q. Write a Python program to add all the Even and Odd digits separately of a number
Output
Source Code
// WAP to add all the even and odd digits separately of a number n= int(input("Enter a number: ")) even=0 odd=0 while(n!=0): r=n%10 if(r%2==0): even=even+r else: odd=odd+r n=n//10 print("Sum of even digits= ",even) print("Sum of odd digits= ",odd)
Copy Code
Python Programs
Swapping using 3rd variable
Swpping without using 3rd variable
Even or Odd check
Add all digits of a number
Add all Even and Odd digits of a number
No comments:
Post a Comment
Newer Post
Older Post
Home
Contact Form
Name
Email
*
Message
*
No comments:
Post a Comment