tuple DEMO
来源:互联网 发布:数控车床编程自学网 编辑:程序博客网 时间:2024/05/23 01:21
#quote from MIT 'introduction to computation and programming using python, Revised'def findDivisors(n1, n2): """Assumes that n1 and n2 are positive ints Returns a tuple containing all common divisors of n1 & n2""" divisors = () #the empty tuple for i in range(1, min(n1, n2) + 1): if n1%i == 0 and n2%i == 0: divisors += (i,) return divisors divisors = findDivisors(20, 100)print divisorstotal = 0for d in divisors: total += dprint total
%run "C:\Users\Administrator\test.py"
(1, 2, 4, 5, 10, 20)
42
0 0
- tuple demo
- tuple DEMO
- python tuple demo
- sequence DEMO(tuple or string)
- tuple
- Tuple
- tuple
- Tuple
- Tuple补遗
- boost tuple
- Boost::tuple
- c++ tuple
- 数据类型-Tuple
- Tuple用例
- Python---tuple
- python tuple
- C++ tuple
- Python:tuple
- 新浪微博授权步骤
- 【猪猪-前端】收集了30个div+css后台模板,方便大家日常开发使用,简洁易用一贯原则。
- CUDA介绍
- mysql表结构查询
- 极光推送 使用实例 (一)服务端
- tuple DEMO
- iOS中滤镜的使用(一) 马赛克滤镜
- IIS express 7.5 配置和多站点运行
- PCB拼板和工艺边教程
- 调用百度定位API接口例子
- android 定位的4种方式介绍
- 分析C语言的声明
- iOS7.1及以后版本企业应用发布过程中的问题及解决方案
- U-boot-2014.10移植到TQ2416开发板之NandFlash启动探究