python homework——the fourth week

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()

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值