Python编程从入门到实践-第八章动手试一试

本章节通过一系列的示例介绍了Python编程中的函数使用,包括定义函数、传递参数、默认参数值、可变参数、关键字参数以及字典作为参数的应用。读者将学习如何创建并调用函数,如`display_message()`, `favorite_book()`, `make_shirt()`, `describe_city()`等,同时了解函数中变量的作用和返回值。此外,还涉及到列表操作和字典的创建,例如`make_great()`函数和`make_car()`函数,展示了如何通过函数处理和操作数据结构。" 82677213,7899858,RocketMQ实战:1机多Broker端口冲突问题解析,"['运维', 'Java', 'Netty']
摘要由CSDN通过智能技术生成

#8-1
def display_message(chapter):
    print("You are learning about "+str(chapter)+" now!")
display_message('function')
#8-2
def favorite_book(title):
    print("One of my favorite books is "+title)
favorite_book('Python')
#8-3
def make_shirt(size,word):
    print("T-shirt's size is "+size+" and word is "+word)
make_shirt('43','haha')
make_shirt(word='abc',size='44')
#8-4
def make_shirt(size,word="I love Python"):
    print("T-shirt's size is "+size+" and word is "+word)
make_shirt('big')
make_shirt(size='default')
make_shirt(size='default',word='HAHA')
#8-5
def describe_city(city,country='China'):
    print(city+" is in "+

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值