Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
Tech C**P
Write a function, which takes a non-negative integer (seconds) as input and returns the time in a human-readable format (HH:MM:SS) HH = hours, padded to 2 digits, range: 00 - 99 MM = minutes, padded to 2 digits, range: 00 - 59 SS = seconds, padded to…
راه حل دوست خوبمون Mehrshad:

toh = lambda n: "{}:{}:{}".format(str(n//3600).zfill(2), str((n%3600)//60).zfill(2), str((n%3600)%60))
نکته ای که هست میشود با string formatter بجای zfill پیش رفت:

return '{:02}:{:02}:{:02}'.format(s / 3600, s / 60 % 60, s % 60)

#python #solution
Tech C**P
A Narcissistic Number is a number which is the sum of its own digits, each raised to the power of the number of digits in a given base. Here we will restrict ourselves to decimal (base 10). For example, take 153 (3 digits): 1^3 + 5^3 + 3^3 = 1 + 125…
from math import pow

def narcissistic(value):
digits = map(int, list(str(value)))
power = len(digits)
final_res = 0
for digit in digits:
final_res += pow(digit, power)
return int(value) == int(final_res)

#python #solution