-
-
Save eclecticmiraclecat/7c7da763e3788ab2947e5475c5912851 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> def tensquared(): | |
... return 10 * 10 | |
... | |
>>> tensquared() | |
100 | |
>>> def ninesquared(): | |
... return 9 * 9 | |
... | |
>>> ninesquared() | |
81 | |
>>> def square_num(num): | |
... return num * num | |
... | |
>>> square_num(10) | |
100 | |
>>> square_num(9) | |
81 | |
>>> def mul_list_by_2(*args): | |
... mul2 = [] | |
... for i in args: | |
... mul2.append(i*2) | |
... return mul2 | |
... | |
>>> mul_list_by_2(1,2,3,4) | |
[2, 4, 6, 8] | |
>>> | |
>>> def mul_list_by_3(*args): | |
... mul3 = [] | |
... for i in args: | |
... mul3.append(i*3) | |
... return mul3 | |
... | |
>>> mul_list_by_3(1,2,3,4) | |
[3, 6, 9, 12] | |
>>> def multiply_by_2(num): | |
... return num * 2 | |
... | |
>>> def manipulate_list(instruction, *args): | |
... output = [] | |
... for i in args: | |
... output.append(instruction(i)) | |
... return output | |
... | |
>>> manipulate_list(multiply_by_2,1,2,3,4) | |
[2, 4, 6, 8] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment