---41---
Question:
>Write a program which can map() to make a list whose elements are square of elements in [1,2,3,4,5,6,7,8,9,10].
Hints:
>Use map() to generate a list.Use lambda to define anonymous functions.
Solution:
---42---
Question:
>Write a program which can map() and filter() to make a list whose elements are square of even number in [1,2,3,4,5,6,7,8,9,10].
Hints:
>Use map() to generate a list.Use filter() to filter elements of a list.Use lambda to define anonymous functions.
Solution:
解法一
解法二
---43---
Question:
>Write a program which can filter() to make a list whose elements are even number between 1 and 20 (both included).
Hints:
>Use filter() to filter elements of a list.Use lambda to define anonymous functions.
Solution:
解法一
解法二
---44---
Question:
>Write a program which can map() to make a list whose elements are square of numbers between 1 and 20 (both included).
Hints:
>Use map() to generate a list. Use lambda to define anonymous functions.
Solution:
解法一
解法二
---45---
Question:
>Define a class named American which has a static method called printNationality.
Hints:
>Use @staticmethod decorator to defineclass static method.
网友评论