def generate_digit_power_sequence(start,limit): # step1: Validate the provided parameter values if type(start)==int: pass else: return None if type (limit)== int: pass else: return None if not(100 <=start<=999): return None if not (limit>5): return None # step2: Generate the specified sequence # step3: return the generated sequence sequence = [] cubic = 0 start = str(start) for j in (limit): cubic = 0 for i in (start): # define a new variable value = int(i) cubic=value**3 + cubic start = str(cubic) sequence.append(cubic) return sequence generate_digit_power_sequence(213,6)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter