第七/八章编程练习

第七、八章编程练习

7-1

message = input("What kind of cars do you like?")
print("Let me see if I could find you a " + message)

7-2

num = input("How much people?")
mum = int(num)
if (num > 8):
    print("There's no empty table!")
else:
    print("There's a table booked for you!")

7-3

num = input("Please input an integar:")
num = int(num)
rest = num % 10
if (rest == 0):
    print("Number you entered is a multiply of 10")
else:
    print("Number you entered isn't a multiply of 10")

7-4

message = input("Please enter an entity:")
while message != 'quit':
    print("We'll add " + message + " in pizza!")
    message = input("Please enter an entity:")

7-5

age = input("Please enter your age: ")
age = int(age)
while 1:
    if age < 3:
        print("You are free!")
    elif age >= 3 and age <  12:
        print("The price is 10 dollars!")
    else:
        print("The price is 15 dollars!")
    age = input("Please enter your age: ")
    age = int(age)

8-1

def playMessage():
    print("I learned about functions in this chapter!")
playMessage();

8-2

def playMessage():
    print("I learned about functions in this chapter!")
playMessage();

8-3

def make_shirt(size,style):
    print("This T-shirt is " + size + " size and has a " + style + " on it.")
make_shirt("XXL","Never Settle")

8-4

def make_shirt(size,style = "I Love Python"):
    print("This T-shirt is " + size + " size and has a " + style + " on it.")
make_shirt("XXL","Never Settle")
make_shirt("XXL")
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值