# 8-1 消息

def display_message():

print("This chapter I will learning function.")

display_message()

# 8-2 喜欢的图书

def favorite_book(title):

print("One of my favorite books is " + title + ".")

favorite_book('Python for Data Analysis')

# 8-3 T恤

def make_shirt(size, word):

print("T-shirt's size is: " + str(size) + '.')

print("T-shirt's word is: " + str(word) + '.')

make_shirt(L, 24)

make_shirt(word='I love you', size='M')

# 8-4 大号T恤

def make_shirt(size='大号', word='I love Python.'):

print("T-shirt's size is: " + str(size) + '.')

print("T-shirt's word is: " + str(word) + '.')

make_shirt()

make_shirt(size='中号')

make_shirt(size='加大号', word="I don't care")

# 8-5 城市

def describe_city(city, nation='China'):

print("City: " + city)

print("Nation: " + nation)

describe_city('Guangzhou')

describe_city('Beijing')

describe_city('Los angels', nation='America')

# 8-6 城市名

def city_country(city, nation):

x = city + ', ' + nation

return x

city_nation1 = city_country('Guangzhou', 'China')

city_nation2 = city_country('Tokyo', 'Japan')

city_nation3 = city_country('Seoul', 'Korea')

print(city_nation1)

print(city_nation2)

print(city_nation3)

# 8-7 专辑

def make_album(singer, album, num=''):

albums = {}

if num:

albums['singer'] = singer

albums['album'] = album

albums['num'] = num

else:

albums['singer'] = singer

albums['album'] = album

return albums

u87 = make_album('陈奕迅', 'U87')

u87_num = make_album('陈奕迅', 'U87', num=12)

happy = make_album('陈奕迅', '我的快乐时代', num=15)

print(u87)

print(u87_num)

print(happy)

# 8-8 用户的专辑

album_active = True

while album_active:

singer = input("Singer: ")

album = input("Album: ")

num = input("Number: ")

you_album = make_album(singer, album, num)

print(you_album)

quit = input("Continue or quit? (y/n) ")

if quit == 'n':

album_active = False

# 8-9 魔术师

magician = ['criss', 'jason', 'cyril']

def show_magicians(magician_list):

for magician in magician_list:

print(magician.title())

show_magicians(magician)

# 8-10 了不起的魔术师

def make_great(magician_list):

for i in range(3):

magician_list[i] = 'the Great ' + magician_list[i]

return magician_list # 差点忘记return了

make_great(magician)

show_magicians(magician)

# 8-11 不变的魔术师

magician_great = make_great(magician[:])

show_magicians(magician)

show_magicians(magician_great)

# 8-12 三明治

def sandwich(*args):

for i in args:

print(i)

# 8-13 用户简介

def build_profile(first, last, **user_info):

profile = {}

profile['first_name'] = first

profile['last_name'] = last

for key, value in user_info.items():

profile[key] = value

return profile

my_profile = build_profile('Zhou', 'Kai', user_info={'age': 26, 'hobby': 'basketball', 'lover': 'Zhanglili'})

print(my_profile)

# 8-14 汽车

def car_information(maker, type1, **kw):

information = {}

information['maker'] = maker

information['type'] = type1

for i, j in kw.items():

information[i] = j

return information

python快速编程入门课后简答题答案-Python编程:从入门到实践(课后习题8)相关推荐

  1. python核心教程第二版答案_python核心编程第二版第4章习题答案.docx

    python核心编程第二版第4章习题答案.docx 4-1.Python 对象.与所有 Python 对象有关的三个属性是什么?请简单的描述一下. 答案: 所有的 Python 对象都拥有三个特性:身 ...

  2. python快速编程入门课后简答题答案-编程python入门 编程python入门课后习题

    编程python入门 编程python入门课后习题 米粒妈咪课堂小编整理了填空.选择.判断等一些课后习题答案,供大家参考学习. 第一章 一.填空题 Python是一种面向对象的高级语言. Python ...

  3. 大学计算机基础课后题答案中国铁道出版社,大学计算机基础 铁道出版社 2015年第1版 第7章 习题答案...

    习题7答案 一.单项选择题 1.D 2.A 3.B 4.A 5.B 二.多项选择题 1.A.B.C.D 2.B.C.D 3.A.B.C.D 4.A.B.C.E 5.A.B.D.E 三.判断题 1. 2 ...

  4. Java2实用教程第五版+第六章习题答案

    这是<Java2实用教程第五版>的试题答案,需要的同学评论关注加点赞 有问题可以在评论区提出 1.问答题 (1)接口中能声明变量吗? 不能 (2)接口中能定义非抽象方法吗? 不能 可以把实 ...

  5. python快速编程入门课后简答题答案-Python编程:从入门到实践(第2版)第1章习题答案...

    <Python编程:从入门到实践>是一本不错的书.第2版已经公开预售,预计会在10月份正式上市. 动手试一试 本章的练习都是探索性的,但从第2章开始将要求你用那一章学到的知识来解决问题. ...

  6. 《Python编程从入门到实践》(第2版)第二章 习题答案

    练习2-1:简单消息 将一条消息赋给变量,并将其打印出来. message = "Hello World!" print(message) Hello World! 练习2-2:多 ...

  7. 算法导论第三版 第15章习题答案

    2020/11/18:初稿,增加Python代码实现,修订参考文献部分错误(如15.1的第4题) 参考文献: https://walkccc.github.io/CLRS/Chap15/ https: ...

  8. Java2实用教程第五版+第五章习题答案

    这是<Java2实用教程第五版>的试题答案,需要的同学评论关注加点赞 有问题可以在评论区提出 1.问答题 (1)子类可以有多个父类吗? 不可以.Java是单继承的,只能继承一个父类. (2 ...

  9. Java2实用教程第五版+第四章习题答案

    这是<Java2实用教程第五版>的试题答案,需要的同学评论关注加点赞 有问题可以在评论区提出 1.问答题 (1)面向对象语言有哪三个特性? 封装.继承和多态 (2)类名应当遵守怎样的编程风 ...

最新文章

  1. sql 两个表字段不一样合并查询_数据分析进阶--SQL多表查询
  2. 关系数据库是如何工作的
  3. 末端物流 | 快递驿站的产品逻辑
  4. C# 使用 Lotus notes 公共邮箱发送邮件
  5. spring导入约束
  6. ajax 实时进度_如何做好项目进度管理
  7. Android 隐藏环形进度条,Android环形进度条
  8. LLDB使用详解以及断点调试教程
  9. android自动清理内存不足,安卓手机越用越卡,清理内存也没用?原因其实是这个!...
  10. java自动化高频面试题
  11. 分享15款堪称神器却鲜为人知的软件和网站
  12. 基于scrapy框架爬取新浪体育部分板块内容
  13. django之 将字典数据导入数据库以及解决insert自动增长的id不是从1开始或不连续
  14. 【python】在图片上绘画
  15. 关于软件测试你必须知道的名词
  16. Android开发 期末复习
  17. 硬盘 测试软件 临界值,怕文件丢失?你该如何检测硬盘寿命状态呢?
  18. 字符串长度 与数组长度
  19. 关于腾讯云服务器使用FTP详细配置教程
  20. 1m=1000ms(1秒等于一千毫秒)

热门文章

  1. 谁的bug? 正则 拷贝和粘贴 regulator工具
  2. Java-笔记16-复习
  3. AngularJS Select(选择框)
  4. Luogu P4782 【模板】2-SAT 问题(2-SAT)
  5. 软件测试基础知识——适合初学者
  6. beego 注解路由无效问题分析
  7. c# 多态实现_虚方法
  8. Javascript社区是时候接受async/await语法了
  9. (数据挖掘-入门-1)基于用户的协同过滤之最近邻
  10. php+sqlrelay+mysql实现连接池及读写负载均衡