Chapter 4

10 试题

1.

Which Python keyword indicates the start of a function definition?

def

help

sweet

continue

2.

In Python, how do you indicate the end of the block of code that makes up the function?

You de-indent a line of code to the same indent level as the def keyword

You put the "END" keyword in column 7 of the line which is to be the last line of the function

You add the matching curly brace that was used to start the function }

You put a # character at the end of the last line of the function

3.

In Python what is the raw_input() feature best described as?

The central processing unit

A built-in function

A reserved word

A user-defined function

4.

What does the following code print out?

def thing():print 'Hello'print 'There'

There

Hello

Hello

There

thing

Hello

There

5.

In the following Python code, which of the following is an "argument" to a function?

x = 'banana'
y = max(x)
print y

print

x

y

max

6.

What will the following Python code print out?

def func(x) :print xfunc(10)
func(20)

x

10

x

20

10

20

x

20

func

func

7.

Which line of the following Python program is useless?

def stuff():print 'Hello'returnprint 'World'stuff()

def stuff():

return

stuff()

print 'Hello'

print 'World'

8.

What will the following Python program print out?

def greet(lang):if lang == 'es':return 'Hola'elif lang == 'fr':return 'Bonjour'else:return 'Hello'print greet('fr'),'Michael'

Bonjour Michael

def Michael

Hello Michael

Hola

Bonjour

Hello

9.

What does the following Python code print out? (Note that this is a bit of a trick question and the code has what many would consider to be a flaw/bug - so read carefully).

def addtwo(a, b):added = a + breturn ax = addtwo(2, 7)
print x

7

2

14

addtwo

10.

What is the most important benefit of writing your own functions?

Following the rule that whenever a program is more than 10 lines you must use a function

To avoid having more than 10 lines of sequential code without an indent or de-indent

Avoiding writing the same non-trivial code more than once in your program

Following the rule that no function can have more than 10 statements in it

Coursera课程Python for everyone:chapter4相关推荐

  1. Coursera课程Python for everyone:Quiz: Many-to-Many Relationships and Python

    Many-to-Many Relationships and Python 9 试题

  2. Coursera课程Python for everyone:Quiz: Multi-Table Relational SQL

    Multi-Table Relational SQL 10 试题 1. What is the primary added value of relational databases over fla ...

  3. Coursera课程Python for everyone:Quiz: Single-Table SQL

    Single-Table SQL 11 试题 1. Structured Query Language (SQL) is used to (check all that apply) Delete d ...

  4. Coursera课程Python for everyone:Quiz: Object Oriented Programming

    Object Oriented Programming 11 试题 1. Which came first, the instance or the class? instance class fun ...

  5. Coursera课程Python for everyone:Quiz: REST, JSON, and APIs

    REST, JSON, and APIs 10 试题 1. Who is credited with getting the JSON movement started? Pooja Sankar M ...

  6. Coursera课程Python for everyone:Quiz: eXtensible Markup Language

    eXtensible Markup Language 10 试题 1. What is "serialization" when we are talking about web ...

  7. Coursera课程Python for everyone:Quiz: Reading Web Data From Python

    Reading Web Data From Python 8 试题 1. Which of the following Python data structures is most similar t ...

  8. Coursera课程Python for everyone:Quiz: Networks and Sockets

    Networks and Sockets 10 试题 1. What do we call it when a browser uses the HTTP protocol to load a fil ...

  9. Coursera课程Python for everyone:Quiz: Regular Expressions

    Quiz: Regular Expressions 10 试题 1. Which of the following best describes "Regular Expressions&q ...

最新文章

  1. C++ OpenCV形态学操作--开闭操作,形态学梯度,顶帽,黑帽
  2. 2021江苏南通名师高考成绩查询,南通2021高考成绩排名榜单,南通各高中高考成绩喜报...
  3. C++ string线程不安全
  4. Dreamweaver8注册码
  5. 【机器学习】机器学习基础知识常见问题详解!
  6. 阿里巴巴对Java编程【代码格式】的规约
  7. 简单讲述一下Intent的传值过程
  8. php 超大整数计算,PHP int 超大溢出整数的 加减运算函数,如果有更好的方法欢迎探讨...
  9. python 监听tcp端口_创建TCP监听_创建TCP监听_功能示例_Python SDK示例_SDK 参考_开发指南_负载均衡 - 阿里云...
  10. Java接口之间的继承
  11. babel与php,javascript – Babel JS babel-preset-php错误
  12. JavaScript引入的三种方式(附实例)
  13. App裂变活动多种玩法解析
  14. 指尖轻舞桌面:Slide On Desk - 主题风格制作指南
  15. ERROR StatusLogger No log4j2 configuration file found. Using default configuration解决方式
  16. 仿真软件proteus构建七段数码管显示数字0-9实验
  17. Netron 可视化
  18. GPS周和周内秒转公历时间 以及 公历时间转GPS周和周内秒 (python版)
  19. 专升本——主从复合句
  20. 三国群英传霸业之王服务器维护,《三国群英传2网络版》掌上助手APP曝光,三国群英传霸业之王...

热门文章

  1. 谢百三:救市后股民应牢记教训?
  2. Modular Arithmetic 模算术
  3. 白话Elasticsearch14-深度探秘搜索技术之基于multi_match 使用most_fields策略进行cross-fields search弊端
  4. Spring-国际化信息03-容器级的国际化信息资源
  5. Linux-diff和diff3命令
  6. java品酒会,我学 rxjava 2(3)- 热发射
  7. python 寻找峰值
  8. ROS知识【13】:ubuntu下安装eclipse-CDT【非installor】
  9. python知识:@classmethod和@staticmethod的异同
  10. fileupload.class.php,php文件上传类