正在加载图片...
上游充通大 ParisTech SHANGHAI JIAO TONG UNIVERSITY INSTITUT DES SCIENCES ET TECHNOLOGIES PARIS INSTITUTE OF TECHNOLOGY A simple Searching Problem Here is the specification of a simple searching function: def search(x,nums): nums is a list of numbers and x is a number Returns the position in the list where x occurs or -1 if x is not in the list. Here are some sample interactions: >>>search(4,[3,1,4,2,5]) 2 >>>search(7,[3,1,4,2,5]) -1 Python Programming,2/e 5Python Programming, 2/e 5 A simple Searching Problem • Here is the specification of a simple searching function: def search(x, nums): # nums is a list of numbers and x is a number # Returns the position in the list where x occurs # or -1 if x is not in the list. • Here are some sample interactions: >>> search(4, [3, 1, 4, 2, 5]) 2 >>> search(7, [3, 1, 4, 2, 5]) -1
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有