mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
16 lines
249 B
Python
16 lines
249 B
Python
|
power = int(raw_input("Enter the power of 2: "))
|
||
|
num = 2**power
|
||
|
|
||
|
string_num = str(num)
|
||
|
|
||
|
list_num = list(string_num)
|
||
|
|
||
|
sum_of_num = 0
|
||
|
|
||
|
print("2 ^",power,"=",num)
|
||
|
|
||
|
for i in list_num:
|
||
|
sum_of_num += int(i)
|
||
|
|
||
|
print("Sum of the digits are:",sum_of_num)
|