11.
Sum of Digits
Calculate the sum of all digits in a number.
num = input('Enter a number: ')
sum_digits = sum(int(d) for d in num)
print('Sum of digits:', sum_digits)
12. Product of Digits
Calculate the product of all digits in a number.
num = input('Enter a number: ')
product = 1
for d in num:
product *= int(d)
print('Product of digits:', product)
13. Reverse a Number
Reverse the digits of a number using string slicing.
num = input('Enter a number: ')
print('Reversed:', num[::-1])
14. Count Digits
Count the number of digits in a number.
num = input('Enter a number: ')
print('Number of digits:', len(num))
15. Largest and Smallest Digit
Find the largest and smallest digit in a number.
num = [int(d) for d in input('Enter a number: ')]
print('Largest:', max(num))
print('Smallest:', min(num))