python exercises:

Problem 1: If a 3-digit numbers equal to the cube and you said to this number is the number of daffodils.  

    For example: 153 = 1 ^ 3 ^ 3 + 5 + 3 ^ 3, 153 is thus a narcissistic number

    So the question is, find a few daffodils less than 1000 (3 digits)

I in Range for (100,1000): 
    A = int (I / 100) # hundreds digit
    b = int ((i - a * 100) / 10) # tens digit
    c = i% 10 # digits

    if ** **. 3 B + A + C. 3 == I **. 3:
        Print ( "% D is the number of Narcissus"% i)

 

 

Guess you like

Origin www.cnblogs.com/ajianhaha/p/12083789.html