#7.1
car=input("Please input the car you want to rent: ")
print("Let me see if I can find a",car,"for you")
#7.2
num=int(input("Please input the num of guests: "))
if num>8:
print("no")
else:
print("yes")
#7.3
num=int(input())
if num%10==0:
print("yes")
else:
print("no")
#7.4
print("Please input a list of ingredients")
ing=input()
while ing!="quit":
print("We'll add",ing)
ing=input()
#7.7
while 2==1:
print("infinite")
#7.8
sandwich_order=['A','B','C','D']
finished_sandwiches=[]
while sandwich_order:
current=sandwich_order.pop(0)
print("I made your",current,"sandwich")
finished_sandwiches.append(current)
print("Finished list:",finished_sandwiches,sep='\n')
#7.10
responses={}
act=True
while act:
name=input("What's your name ")
responses[name]=input("If you could visit one place in the world, where would you go: ")
print()
repeat=input("If anyone else want to response (Y/N)")
print()
if repeat=="N":
break
print("\n------results------")
for name,response in responses.items():
print(name,"would like to go to",response)
#8.1
def display_message():
print("I'v learned functions")
display_message()
#8.4
def make_shirt(size='big',word='I love python'):
print(size,word)
make_shirt()
make_shirt('small','a')
#8.7
def make_album(name,album):
a={}
a['name']=name
a['album']=album
return a
print(make_album('Singer A','Album A'))
print(make_album('Singer B','Album B'))
print(make_album('Singer C','Album C'))
#8.9-8.10
magician=['A','B','C']
def show_megicians(name):
for names in name:
print(names)
show_megicians(magician)
def make_great(name):
length=len(name)
for i in range(length):
name[i]="The great "+name[i]
make_great(magician)
print(magician)
#8.12
def make_sandwich(*ingredients):
print("\nMaking a sandwich with the following ingredients:")
for ings in ingredients:
print(' -'+ings)
make_sandwich('Tuna','Tomato','sause')
make_sandwich('Steak','Tomato','sause')
make_sandwich('Bacon','sause')
SYSU Python 第四周作业
最新推荐文章于 2023-03-30 21:19:43 发布