worksheet4

PHOTO EMBED

Thu Jan 19 2023 07:37:18 GMT+0000 (Coordinated Universal Time)

Saved by @Shaghaf_2000 #python

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)
content_copyCOPY