AI学习笔记——Python的几个练习题
上一篇文章中提到了学习编程练习的重要性,今天就通过几个练习题,来巩固一下Python中几个重要的技能。 将字典中大于2的值过滤掉。 #Filter out values of equal or greater than 2 #Note that for Python 2 you will have to use iteritems d = {"a": 1, "b": 2, "c": 3} 读取输入的一句话中的单词数。 a,b 中的对应数字想加并输出结果。 #Print out in each line the sum of homologous items from the two sequences a = [1, 2, 3] b = (4, 5, 6) 发现下面代码中的错误。 #Please fix the script so that it returns the user submited first name for the first %s #and the second name for the second %s firstname = input("Enter fir...