Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import concurrent.futures #imported the concurrent library
values = [12, 34, 22, 77, 5, 69] #created the sequence
power = 3 #the value of the power
def powers (valu, power): #creating the function with the desired parameters
return valu ** power #returns the power (po) of the value (val)
def main(): #created the main function
with concurrent.futures.ProcessPoolExecutor() as executor: #executes the process with the concurrent
for valu in values: #loops through the values one by one
resultado = powers (valu, power) #res is equal to the output of the powers function
print ('%s to the power of %s is %s' % (valu, power, resultado), '\n') #prints the output of the loop replacing the %s for the values inside the variables
if __name__ == '__main__':
main()