美文网首页
Python-41~45

Python-41~45

作者: AoEliauk | 来源:发表于2020-10-22 15:33 被阅读0次

---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.

Solution:


Python filter() 函数 | 菜鸟教程

Python filter() 函数 | 菜鸟教程

相关文章

  • Python-41~45

    ---41--- Question: >Write a program which can map() to ma...

  • 奇怪的45

    45²=2025 20+25=45 45³=91125 9+11+25=45 45⁴=4100625 ...

  • 九月五号马丽娅的日常

    45min +45min 数学关于充分条件 45min+45min语文成语的讲解 45Min生物真核细胞原核细胞区...

  • 大树内蒙静修营作息表

    06:45~07:45 室内:升阳运动 08:00~08:30 早餐 08:45~09:45 室外:农场劳作 10...

  • Day5-骆栢维

    数据结构 向量赋值方法 x <- c(22,32,12,45,45)x[1] 22 32 12 45 45b <-...

  • iOS 绘制虚线框

    只需要设置虚线框的四个坐标(左上( 0, 3)、右上( 45, 3)、右下( 45, 45)、左下( 0, 45))。

  • 61.早起 第71天

    睡觉:01:45 醒来:04:45

  • 我是45

    45个小时办不了,45年。

  • 一日节奏

    8:10-8:45 孩子入园 8:45-9:45 室内自由玩耍 9:45-10:00 晨圈 10:00-10:15...

  • 闪电泡芙和香草酥皮泡芙

    泡芙体配方: A部分:牛奶 45克 黄油 45克 水 45克 幼糖 5克 盐 ...

网友评论

      本文标题:Python-41~45

      本文链接:https://www.haomeiwen.com/subject/yrjsmktx.html