Computing for Data Science
Computing for Data Science
  • Home
  • Unit 1
  • Unit 2
  • Unit 3

3rd August 2023

Center character of a string and sum of the digits of a number when a digit is a prime number



Dynamic List and Ceasar Cipher

03 Aug 2023
Share

Recent Comments

Nigel Fernandes says:

n = int(input("Enter a large number: "))
digits = [int(d) for d in str(n)]
prime_sum = 0

for digit in digits:
if digit <= 1:
continue

is_prime = True
for i in range(2, digit):
if digit % i == 0:
is_prime = False
break

if is_prime:
prime_sum += digit

print(prime_sum)

Leave a Comment

Leave a Comment

person
exit_to_app

or

Back to Login