网站性能优化方法,做网站爱游戏,自己来建网站,易班网站建设的意义python编程从入门到实践 第五章 if语句1.条件测试#xff1a;2.更多的条件测试#xff1a;3.外星人颜色#1#xff1a;4. 外星人颜色#2#xff1a;5. 外星人颜色#3#xff1a;6. 人生的不同阶段#xff1a;7. 喜欢的水果#xff1a;8. 以特殊方式跟管理员打招呼#xff… python编程从入门到实践 第五章 if语句1.条件测试2.更多的条件测试3.外星人颜色#14. 外星人颜色#25. 外星人颜色#36. 人生的不同阶段7. 喜欢的水果8. 以特殊方式跟管理员打招呼9. 处理没有用户的情形10.检查用户名11.序数 第六章 字典1. 人2. 喜欢的数字3. 词汇表4. 词汇表25. 河流6. 调查7. 人8. 宠物9.喜欢的地方10. 喜欢的数字11. 城市12. ~~扩展本章的示例足够复杂可以以很多方式进行扩展了。请对本章的一个示例进行扩展添加键和值、调整程序要解决的问题或改进输出的格~~ 第七章 用户输入和while循环1. 汽车租赁2. 餐馆订位3. 10的整数倍4. 比萨配料5. 电影票6. 三个出口7. 无限循环8. 熟食店9. 五香烟熏牛肉(pastrami)卖完了10.梦想的度假胜地 第八章函数1消息2. 喜欢的图书3. T恤4. 大号T恤5. 城市6. 城市名7. 专辑8. 用户的专辑9.10.11.12.13.14.1516. 第五章 if语句
1.条件测试
编写一系列条件测试将每个测试以及你对其结果的预测和实际结果都打印出来。你编写的代码应类似于下面这样
car subaru
print(Is car subaru?I predict True.)
print(car subaru)print(\nIs car audi?I predict False.)
print(car audi)·详细研究实际结果直到你明白了它为何为True或False。 ·创建至少10个测试且其中结果分别为True和False的测试都至少有5个。
car subaru
print(Is car subaru? I predict TRUE)
print(car subaru)print(\nIs car audi? I predict FALSE)
print(car audi)2.更多的条件测试
你并非只能创建10个测试。如果你想尝试做更多的比较可再编写一些测试并将它们加入到conditional_tests.py中。对于下面列出的各种测试至少编写一个结果为True和False的测试。
·检查两个字符串相等和不等。 ·使用函数lower()的测试。 ·检查两个数字相等、不等、大于、小于、大于等于和小于等于。 ·使用关键字and和or的测试。 ·测试特定的值是否包含在列表中。 ·测试特定的值是否未包含在列表中。
m1 Zoctopus
m2 nian
m3 Zoctopus
cars [audi, bmw, subaru, toyota]
# 检查两个字符串相等和不等
if m1 m3:print(m1 equal m3)
if m1 ! m2:print(m1 not equal m2)# 使用函数lower()的测试
name ADS
if name.lower() ads:print(true)# 检查两个数字相等、不等、大于、小于、大于等于和小于等于
age 23
age_1 18
if age 23:print(true)
if age 18:print(true)# 使用关键字and和or的测试
if age 10 and age_1 22:print(true)
if age 25 or age_1 25:print(true)# 测试特定的值是否包含在列表中
if audi in cars:print(in true)# 测试特定的值是否未包含在列表中
if aaaai not in cars:print(not in true)3.外星人颜色#1
假设在游戏中刚射杀了一个外星人请创建一个名为alien_color的变量并将其设置为’green’、‘yellow’或’red’。 ·编写一条if语句检查外星人是否是绿色的如果是就打印一条消息指出玩家获得了5个点。 ·编写这个程序的两个版本在一个版本中上述测试通过了而在另一个版本中未通过未通过测试时没有输出
# 通过
alien_color greenif alien_color green:print(You just earned 5 points!)# 未通过
alien_color redif alien_color green:print(You just earned 5 points!)4. 外星人颜色#2
像练习5-3那样设置外星人的颜色并编写一个if-else结构。
·如果外星人是绿色的就打印一条消息指出玩家因射杀该外星人获得了5个点。
·如果外星人不是绿色的就打印一条消息指出玩家获得了10个点。
·编写这个程序的两个版本在一个版本中执行if代码块而在另一个版本中执行else代码块。 # 版本一
alien_color greenif alien_color green:print(You just earned 5 points!)
else:print(You just earned 10 points!)# 版本二
alien_color yellowif alien_color green:print(You just earned 5 points!)
else:print(You just earned 10 points!)5. 外星人颜色#3
将练习5-4中的if-else结构改为if-elif-else结构。 ·如果外星人是绿色的就打印一条消息指出玩家获得了5个点。 ·如果外星人是黄色的就打印一条消息指出玩家获得了10个点。 ·如果外星人是红色的就打印一条消息指出玩家获得了15个点。 ·编写这个程序的三个版本它们分别在外星人为绿色、黄色和红色时打印一条消息。
alien_color redif alien_color green:print(You just earned 5 points!)
elif alien_color yellow:print(You just earned 10 points!)
else:print(You just earned 15 points!)alien_color yellowif alien_color green:print(You just earned 5 points!)
elif alien_color yellow:print(You just earned 10 points!)
else:print(You just earned 15 points!)alien_color greenif alien_color green:print(You just earned 5 points!)
elif alien_color yellow:print(You just earned 10 points!)
else:print(You just earned 15 points!)6. 人生的不同阶段
设置变量age的值再编写一个if-elif-else结构根据age的值判断处于人生的哪个阶段。 ·如果一个人的年龄小于2岁就打印一条消息指出他是婴儿。 ·如果一个人的年龄为2含4岁就打印一条消息指出他正蹒跚学步。 ·如果一个人的年龄为4含13岁就打印一条消息指出他是儿童。 ·如果一个人的年龄为13含20岁就打印一条消息指出他是青少年。 ·如果一个人的年龄为20含65岁就打印一条消息指出他是成年人。 ·如果一个人的年龄超过65含岁就打印一条消息指出他是老年人。
age 17if age 2:print(Youre a baby!)
elif age 4:print(Youre a toddler!)
elif age 13:print(Youre a kid!)
elif age 20:print(Youre a teenager!)
elif age 65:print(Youre an adult!)
else:print(Youre an elder!)7. 喜欢的水果
创建一个列表其中包含你喜欢的水果再编写一系列独立的if语句检查列表中是否包含特定的水果。 ·将该列表命名为favorite_fruits并在其中包含三种水果。 ·编写5条if语句每条都检查某种水果是否包含在列表中如果包含在列表中就打印一条消息如“You really like bananas!”。
favorite_fruits [blueberries, salmonberries, peaches]if bananas in favorite_fruits:print(You really like bananas!)
if apples in favorite_fruits:print(You really like apples!)
if blueberries in favorite_fruits:print(You really like blueberries!)
if kiwis in favorite_fruits:print(You really like kiwis!)
if peaches in favorite_fruits:print(You really like peaches!)8. 以特殊方式跟管理员打招呼
创建一个至少包含5个用户名的列表且其中一个用户名为’admin’。想象你要编写代码在每位用户登录网站后都打印一条问候消息。遍历用户名列表并向每位用户打印一条问候消息。 ·如果用户名为’admin’就打印一条特殊的问候消息如“Hello admin,would you like to see a status report?”。 ·否则打印一条普通的问候消息如“Hello Eric,thank you for logging in again”
usernames [admin, yf, sks, yl, yjy]for username in usernames:if username admin:print(Hello admin, would you like to see a status report?)else:print(Hello username , thank you for logging in again!)9. 处理没有用户的情形
在为完成练习5-8编写的程序中添加一条if语句检查用户名列表是否为空。 ·如果为空就打印消息“We need to find some users!”。 ·删除列表中的所有用户名确定将打印正确的消息。
usernames []if usernames:for username in usernames:if username admin:print(Hello admin, would you like to see a status report?)else:print(Hello username , thank you for logging in again!)else:print(We need to find some users!)
10.检查用户名
按下面的说明编写一个程序模拟网站确保每位用户的用户名都独一无二的方式。
·创建一个至少包含5个用户名的列表并将其命名为current_users。
·再创建一个包含5个用户名的列表将其命名为new_users并确保其中有一两个用户名也包含在列表current_users中。
·遍历列表new_users对于其中的每个用户名都检查它是否已被使用。如果是这样就打印一条消息指出需要输入别的用户名否则打印一条消息指出这个用户名未被使用。
·确保比较时不区分大小写换句话说如果用户名’John’已被使用应拒绝用户名’JOHN’。
current_users [eric, willie, admin, erin, Ever]
new_users [sarah, Willie, PHIL, ever, Iona]# 将current_users中的元素全都转换为小写
current_users_lower [user.lower() for user in current_users]for new_user in new_users:if new_user.lower() in current_users_lower: # 判断注册的名字是否已经存在print(Sorry new_user , that name is taken.)else:print(Great, new_user is still available.)11.序数
序数表示位置如1st和2nd。大多数序数都以th结尾只有1、2和3例外。 ·在一个列表中存储数字19。 ·遍历这个列表。·在循环中使用一个if-elif-else结构以打印每个数字对应的序数。输出内容应为1st、2nd、3rd、4th、5th、6th、7th、8th和9th但每个序数都独占一行。
numbers [1,2,3,4,5,6,7,8,9]for num in numbers:if num 1:print(1st)elif num 2:print(2nd)elif num 3:print(3rd)else:print(str(num) th)第六章 字典
1. 人
使用一个字典来存储一个熟人的信息包括名、姓、年龄和居住的城市。该字典应包含键first_name、last_name、age和city。将存储在该字典中的每项信息都打印出来。
person {first_name: shang,last_name: yang,age: 21,city: qingdao,}print(person[first_name])
print(person[last_name])
print(person[age])
print(person[city])2. 喜欢的数字
使用一个字典来存储一些人喜欢的数字。请想出5个人的名字并将这些名字用作字典中的键想出每个人喜欢的一个数字并将这些数字作为值存储在字典中。打印每个人的名字和喜欢的数字。为让这个程序更有趣通过询问朋友确保数据是真实的。
favorite_numbers {mandy: 42,micah: 23,gus: 7,hank: 1000000,maggie: 0,}num favorite_numbers[mandy]
print(Mandys favorite number is str(num) .)num favorite_numbers[micah]
print(Micahs favorite number is str(num) .)num favorite_numbers[gus]
print(Guss favorite number is str(num) .)num favorite_numbers[hank]
print(Hanks favorite number is str(num) .)num favorite_numbers[maggie]
print(Maggies favorite number is str(num) .)3. 词汇表
Python字典可用于模拟现实生活中的字典但为避免混淆我们将后者称为词汇表。
想出你在前面学过的5个编程词汇将它们用作词汇表中的键并将它们的含义作为值存储在词汇表中。以整洁的方式打印每个词汇及其含义。为此你可以先打印词汇在它后面加上一个冒号再打印词汇的含义也可在一行打印词汇再使用换行符(\n)插入一个空行然后在下一行以缩进的方式打印词汇的含义。
glossary {string: A series of characters.,comment: A note in a program that the Python interpreter ignores.,list: A collection of items in a particular order.,loop: Work through a collection of items, one at a time.,dictionary: A collection of key-value pairs.,}word string
print(\n word.title() : glossary[word])word comment
print(\n word.title() : glossary[word])word list
print(\n word.title() : glossary[word])word loop
print(\n word.title() : glossary[word])word dictionary
print(\n word.title() : glossary[word])4. 词汇表2
既然你知道了如何遍历字典现在请整理你为完成练习6-3而编写的代码将其中的一系列print语句替换为一个遍历字典中的键和值的循环。确定该循环正确无误后再在词汇表中添加5个Python术语。当你再次运行这个程序时这些新术语及其含义将自动包含在输出中。
glossary {string: A series of characters.,comment: A note in a program that the Python interpreter ignores.,list: A collection of items in a particular order.,loop: Work through a collection of items, one at a time.,dictionary: A collection of key-value pairs.,key: The first item in a key-value pair in a dictionary.,value: An item associated with a key in a dictionary.,conditional test: A comparison between two values.,float: A numerical value with a decimal component.,boolean expression: An expression that evaluates to True or False.,}for word, definition in glossary.items():print(\n word.title() : definition)5. 河流
创建一个字典在其中存储三条大河流及其流经的国家。其中一个键—值对可能是’nile’:‘egypt’。
使用循环为每条河流打印一条消息如“The Nile runs through Egypt.”。使用循环将该字典中每条河流的名字都打印出来。使用循环将该字典包含的每个国家的名字都打印出来
rivers {nile: egypt,mississippi: united states,fraser: canada,kuskokwim: alaska,yangtze: china,}for river, country in rivers.items():print(The river.title() flows through country.title() .)# 打印该字典中每条河流的名字
print(\nThe following rivers are included in this data set:)
for river in rivers.keys():print(- river.title())#打印该字典中包含的每个国家的名字
print(\nThe following countries are included in this data set:)
for country in rivers.values():print(- country.title())6. 调查
在6.3.1节编写的程序favorite_languages.py中执行以下操作。·创建一个应该会接受调查的人员名单其中有些人已包含在字典中而其他人未包含在字典中。·遍历这个人员名单对于已参与调查的人打印一条消息表示感谢。对于还未参与调查的人打印一条消息邀请他参与调查。
favorite_languages {jen: python,sarah: c,edward: ruby,phil: python,}for name, language in favorite_languages.items():print(name.title() s favorite language is language.title() .)print(\n)coders [phil, josh, david, becca, sarah, matt, danielle]
for coder in coders:if coder in favorite_languages.keys():print(Thank you for taking the poll, coder.title() !)else:print(coder.title() , whats your favorite programming language?)7. 人
在为完成练习6-1而编写的程序中再创建两个表示人的字典然后将这三个字典都存储在一个名为people的列表中。遍历这个列表将其中每个人的所有信息都打印出来。
people []# 定义一些人的信息并添加进列表
person {first_name: eric,last_name: matthes,age: 43,city: sitka,}
people.append(person)person {first_name: ever,last_name: matthes,age: 5,city: sitka,}
people.append(person)person {first_name: willie,last_name: matthes,age: 8,city: sitka,}
people.append(person)# 打印所有信息
for person in people:name person[first_name].title() person[last_name].title()age str(person[age])city person[city].title()print(name , of city , is age years old.)8. 宠物
创建多个字典对于每个字典都使用一个宠物的名称来给它命名在每个字典中包含宠物的类型及其主人的名字。将这些字典存储在一个名为pets的列表中再遍历该列表并将宠物的所有信息都打印出来。
pets []pet {type: fish,name: john,owner: guido,}
pets.append(pet)pet {type: chicken,name: clarence,owner: tiffany,}
pets.append(pet)pet {type: dog,name: peso,owner: eric,}
pets.append(pet)for pet in pets:print(\nHeres what I know about pet[name].title() :)for key, value in pet.items():print(\t key : str(value))9.喜欢的地方
创建一个名为favorite_places的字典。在这个字典中将三个人的名字用作键对于其中的每个人都存储他喜欢的13个地方。为让这个练习更有趣些可让一些朋友指出他们喜欢的几个地方。遍历这个字典并将其中每个人的名字及其喜欢的地方打印出来。
favorite_places {znn: [chengdu, shanghai, hangzhou],yl: [chengdu, huang montains],other: [xi-an, xinjiang, nanji]}for name, places in favorite_places.items():print(\n name.title() likes the following places:)for place in places:print(- place.title())
10. 喜欢的数字
修改为完成练习6-2而编写的程序让每个人都可以有多个喜欢的数字然后将每个人的名字及其喜欢的数字打印出来。
favorite_numbers {mandy: [42, 17],micah: [42, 39, 56],gus: [7, 12],}for name, numbers in favorite_numbers.items():print(\n name.title() likes the following numbers:)for number in numbers:print( str(number))11. 城市
创建一个名为cities的字典其中将三个城市名用作键对于每座城市都创建一个字典并在其中包含该城市所属的国家、人口约数以及一个有关该城市的事实。在表示每座城市的字典中应包含country、population和fact等键。将每座城市的名字以及有关它们的信息都打印出来
cities {santiago: {country: chile,population: 6158080,nearby mountains: andes,},talkeetna: {country: alaska,population: 876,nearby mountains: alaska range,},kathmandu: {country: nepal,population: 1003285,nearby mountains: himilaya,}}for city, city_info in cities.items():country city_info[country].title()population city_info[population]mountains city_info[nearby mountains].title()print(\n city.title() is in country .)print( It has a population of about str(population) .)print( The mountains mountains are nearby.)12. 扩展本章的示例足够复杂可以以很多方式进行扩展了。请对本章的一个示例进行扩展添加键和值、调整程序要解决的问题或改进输出的格 aliens []alien {name: A,color: green,point: 5,speed: slow,}
aliens.append(alien)alien {name: B,color: yellow,point: 10,speed: med,}
aliens.append(alien)alien {name: C,color: red,point: 10,speed: fast,}
aliens.append(alien)print(aliens)# for循环打印
for alien_info in aliens:print(\nHeres what I know about alien_info[name].title() :)for key, value in alien_info.items():print(\t key : str(value))第七章 用户输入和while循环
1. 汽车租赁
编写一个程序询问用户要租赁什么样的汽车并打印一条消息如“Let me see if I can find you a Subaru”
car input(What kind of car would you like? )print(Let me see if I can find you a car.title() .)2. 餐馆订位
编写一个程序询问用户有多少人用餐。如果超过8人就打印一条消息指出没有空桌否则指出有空桌。
number input(how many people eat? )
number int(number)
if number 8:print(no empty table.)
else:print(have empty table.)3. 10的整数倍
让用户输入一个数字并指出这个数字是否是10的整数倍。
number input(input a number: )
number int(number)
if number % 10 0:print(yes)
else:print(no)4. 比萨配料
编写一个循环提示用户输入一系列的比萨配料并在用户输入’quit’时结束循环。每当用户输入一种配料后都打印一条消息说我们会在比萨中添加这种配料。
prompt \nTell me Pizza Toppings
prompt \nEnter quit to end the program.active True
while active:message raw_input(prompt)if message quit:active Falseelse:print(Add message .)5. 电影票
有家电影院根据观众的年龄收取不同的票价不到3岁的观众免费312岁的观众为10美元超过12岁的观众为15美元。请编写一个循环在其中询问用户的年龄并指出其票价。
prompt How old are you?
prompt \nEnter quit when you are finished. while True:age input(prompt)if age quit:breakage int(age)if age 3:print( You get in free!)elif age 13:print( Your ticket is $10.)else:print( Your ticket is $15.)6. 三个出口
以另一种方式完成练习7-4或练习7-5在程序中采取如下所有做法。·在while循环中使用条件测试来结束循环。·使用变量active来控制循环结束的时机。·使用break语句在用户输入’quit’时退出循环。
在这里插入代码片7. 无限循环
编写一个没完没了的循环并运行它要结束该循环可按CtrlC也可关闭显示输出的窗口。
signal True
x 2
while signal:print(x)8. 熟食店
创建一个名为sandwich_orders的列表在其中包含各种三明治的名字再创建一个名为finished_sandwiches的空列表。遍历列表sandwich_orders对于其中的每种三明治都打印一条消息如I made your tuna sandwich并将其移到列表finished_sandwiches。所有三明治都制作好后打印一条消息将这些三明治列出来。
sandwich_orders [veggie, grilled cheese, turkey, roast beef]
finished_sandwiches []while sandwich_orders:finish_sandwich sandwich_orders.pop()print(I made your finish_sandwich)finished_sandwiches.append(finish_sandwich)print(\nThe sandwiches have been finished !)
for finish in finished_sandwiches:print(finish)9. 五香烟熏牛肉(pastrami)卖完了
使用为完成练习7-8而创建的列表sandwich_orders并确保’pastrami’在其中至少出现了三次。在程序开头附近添加这样的代码打印一条消息指出熟食店的五香烟熏牛肉卖完了再使用一个while循环将列表sandwich_orders中的’pastrami’都删除。确认最终的列表finished_sandwiches中不包含’pastrami’。
sandwich_orders [pastrami, veggie, grilled cheese, pastrami,turkey, roast beef, pastrami]
finished_sandwiches []print(Im sorry, were all out of pastrami today.)
while pastrami in sandwich_orders:sandwich_orders.remove(pastrami)print(\n)
while sandwich_orders:finish_sandwich sandwich_orders.pop()print(Im working on your finish_sandwich sandwich.)finished_sandwiches.append(finish_sandwich)print(\n)
for sandwich in finished_sandwiches:print(I made a sandwich sandwich.)10.梦想的度假胜地
编写一个程序调查用户梦想的度假胜地。使用类似于“If you could visit one place in the world,where would you go?”的提示并编写一个打印调查结果的代码块。
name_prompt \nWhats your name?
place_prompt If you could visit one place in the world, where would it be?
continue_prompt \nWould you like to let someone else respond? (yes/no) responses {}while True:name input(name_prompt)place input(place_prompt)responses[name] placerepeat raw_input(continue_prompt)if repeat ! yes:breakprint(\n--- Results ---)
for name, place in responses.items():print(name.title() would like to visit place.title() .)第八章函数
1消息
编写一个名为display_message()的函数它打印一个句子指出你在本章学的是什么。调用这个函数确认显示的消息正确无误。
def display_message():print(Study Function.)display_message()2. 喜欢的图书
编写一个名为favorite_book()的函数其中包含一个名为title的形参。这个函数打印一条消息如One of my favorite books is Alice in Wonderland。调用这个函数并将一本图书的名称作为实参传递给它。
def favorite_book(title):print(One of my favorite book is title .)favorite_book(CSAPP)3. T恤
编写一个名为make_shirt()的函数它接受一个尺码以及要印到T恤上的字样。这个函数应打印一个句子概要地说明T恤的尺码和字样。使用位置实参调用这个函数来制作一件T恤再使用关键字实参来调用这个函数。
def make_shirt(size, message):print(\nIm going to make a size t-shirt.)print(It will say, message )make_shirt(large, I love Python!)
make_shirt(messageReadability counts., sizemedium)4. 大号T恤
修改函数make_shirt()使其在默认情况下制作一件印有字样“I love Python”的大号T恤。调用这个函数来制作如下T恤一件印有默认字样的大号T恤、一件印有默认字样的中号T恤和一件印有其他字样的T恤尺码无关紧要。
def make_shirt(sizelarge, messageI love Python!):print(\nIm going to make a size t-shirt.)print(It will say, message )make_shirt()
make_shirt(sizemedium)
make_shirt(small, Happy Every Day.)5. 城市
编写一个名为describe_city()的函数它接受一座城市的名字以及该城市所属的国家。这个函数应打印一个简单的句子如Reykjavik is in Iceland。给用于存储国家的形参指定默认值。为三座不同的城市调用这个函数且其中至少有一座城市不属于默认国家。
def describe_city(cityname,conturychina):print(cityname.title is in contury.title .)describe_city(beijing)
describe_city(NewYork,American)
describe_city(qingdao)6. 城市名
编写一个名为city_country()的函数它接受城市的名称及其所属的国家。这个函数应返回一个格式类似于下面这样的字符串
Santiago,Chile至少使用三个城市-国家对调用这个函数并打印它返回的值。
def city_country(city,country):return (city.title() , country.title())city city_country(shanghai, china)
print(city)city city_country(ushuaia, argentina)
print(city)city city_country(longyearbyen, svalbard)
print(city)7. 专辑
编写一个名为make_album()的函数它创建一个描述音乐专辑的字典。这个函数应接受歌手的名字和专辑名并返回一个包含这两项信息的字典。使用这个函数创建三个表示不同专辑的字典并打印每个返回的值以核实字典正确地存储了专辑的信息。 给函数make_album()添加一个可选形参以便能够存储专辑包含的歌曲数。如果调用这个函数时指定了歌曲数就将这个值添加到表示专辑的字典中。调用这个函数并至少在一次调用中指定专辑包含的歌曲数。
def make_album(artist, title):album_dict {artist: artist.title(),title: title.title(),}return album_dictalbum make_album(metallica, ride the lightning)
print(album)album make_album(beethoven, ninth symphony)
print(album)album make_album(willie nelson, red-headed stranger)
print(album)
8. 用户的专辑
在为完成练习8-7编写的程序中编写一个while循环让用户输入一个专辑的歌手和名称。获取这些信息后使用它们来调用函数make_album()并将创建的字典打印出来。在这个while循环中务必要提供退出途径。
def make_album(artist, title, tracks0):Build a dictionary containing information about an album.album_dict {artist: artist.title(),title: title.title(),}if tracks:album_dict[tracks] tracksreturn album_dicttitle_prompt \nWhat album are you thinking of?
artist_prompt Whos the artist? print(Enter quit at any time to stop.)while True:title input(title_prompt)if title quit:breakartist rinput(artist_prompt)if artist quit:breakalbum make_album(artist, title)print(album)print(\nThanks for responding!)9.
def show_magicians(names):for name in names:print(name.title())magicians [znn,david,amy]
show_magicians(magicians)10.
11.
12.
13.
14.
15
16.