How can write these fuctions differently ?

def computeVoltages(Vs, TC, tValues):
    return [Vs * (1 - e ** (-t / TC)) for t in tValues]

def computeTimeValues(TC, intervals):
    time = []
    width = 5 * TC / intervals
    for i in range(intervals + 1):
        time.append(i * width)

    return time

Recommended Answers

All 2 Replies

It looks like homework. Both functions show how to compute and return a list, each of them using a different style (list comprehension vs appending list items one by one in a loop). What you can do is rewrite computeVoltages() using the style of computeTimeValues() and vice versa.

How brother ? I am having a hard time understanding the concept. I have gone through lecture notes several times :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.