Write a Python program to Calculate the sum of the digits of a random three-digit number and print the result.
Topic: Write a Python program to Calculate the sum of the digits of a random three-digit number and print the result.
Solution
import random n = random() * 900 + 100 n = int(n) print(n) a = n // 100 b = (n // 10) % 10 c = n % 10 print(a + b + c)
List all Python Programs