第四周作业

7-1
a = input('what car do you want to buy!\n')
print('let me check if I can find you a subaru\n')

7-2

a = (int)(input('how many customers will go for dining\n'))
if a > 8:
	print('no empty table for it')
else:
	print('empty table is aviliable')
7-3
b = int(input('please enter a real number\n'))
if(b%10 == 0):
	print('the number you have entered can be divided by 10\n')
else:
	print('the number you have entered can\'t be divided by 10\n')

7-4

x = ' '
while  1:
	x = input('please enter the ingredients you want,ended by "quit"\n')
	if(x != 'quit'):
		print('we would add '+x +' to your pizza\n')
	else:
		break

7-7

while 1 != 2:

print('cycling\n')

8-1

def display_message():
	print('now ,we are going to learn the function in python\n')
display_message()

8-2

def favorite_book():
	return 'One Hundred Years of Solitude';
print('my favorit book is ' + favorite_book())

8-5

x = {'beijing':'china','tokey':'japan','newyork':'america'}
def describe_city(k):
	print(k + ' is in '+x[k])
k = input('please enter a city\n')
describe_city(k)

8-6

x = {'beijing':'china','tokey':'japan','newyork':'america'}
def city_country(k):
	print('"'+k + ', '+x[k]+'"')
k = input('please enter a city\n')
city_country(k)

8-9

def show_magicans(*x):
	x = list(x)
	for k in x:
		print(k)
l = ['mike','Alice','john','hh']
show_magicans(l)


扫描二维码关注公众号,回复: 1035449 查看本文章

猜你喜欢

转载自blog.csdn.net/qq_36401790/article/details/79778644