7-2
num=input('How many people will have dinner here?')
if num >8:
print('There are not so many tables.')
else:
print('there are enough tables')
7-3
num=input('Please input a number.')
if num%10==0:
print('Yes')
else:
print('no')
7-5
while True:
age=input('How old are you?')
if age==-1:
break;
if age<3:
print('It's free')
elif age<=12:
print('You should pay 10 dollars')
else:
print('You should pay 15 dollars')
7-7
num=10
while num>=10:
num++
8-9
def show_magicians(magicians):
"""显示所有魔术师的名字"""
for magician in magicians:
print(magician)
magicians=['a','b','c']
show_magicians(magicians)
8-12
def sandwich(*addings):
print('The sandwich has addings as following')
for adding in addings:
print(adding)
sandwich('sugar')
sandwich('sugar','salt')
sandwich('sugar','salt','pepper')
8-14
def make_car(producer,number,**info):
print('The car is produced by '+producer+' of number '+number.')
for key ,value in info.items():
print('The '+key+' is '+value)
make_car('subaru','outback',color='blue',tow_package=True)
8-16
#a.py
def foo():
print('ok')
#b.py
(1)
import a
a.foo()
(2)
from a import foo
foo()
(3)
from a impor foo as f
f()
(4)
import a as A
A.foo()
(5)
from a import *
foo()