高级编程技术 第四周作业

第七章:input与while

本章主要是介绍了input的输入函数以及while循环控制函数。

7-3

a = int(input('Please input a integer:'))
if (a % 10 == 0):
    print('Yes')
else:
    print('No')

7-10

survey = {}
i = 0
a = ''
while (a != 'None'):
    a = input('Hey #' + str(i) + ', Where?(Input "None" to see result)')
    if (a != 'None'):
        survey[i] = a
    i += 1
for key, item in survey.items():
    print(str(key) + ' want to ' + item)

第八章:函数

本章主要讲述了如何定义并使用函数,从而提高代码的可重复利用性。

8-5

def describe_city(cityname, nation='The Sol'):
    print(cityname + ' is in ' + nation)
describe_city('Montana', 'USA')
describe_city('Nürnberg', 'Germany')
describe_city('Kuiper belt')

8-13

def build_profile(firstname, lastname, **charis):
    print("I'm " + firstname + ' ' + lastname + '.')
    for key, item in charis.items():
        print('My ' + key + ' is ' + item + '.')
build_profile('A', 'Man', phone_number='never tell you', email_address='something you can guess', something_else='no more')

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值