1 / 6

Functions

Functions. lecture04. A Couple We’ve Seen Already. range () len (). Functions. They’re like mini programs, they reduce reduce repetition. def my_sum ( array ): sum = 0 if len ( array ) == 0 : return 0 for item in array : sum += item return sum numbers = range ( 101 )

monet
Télécharger la présentation

Functions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Functions lecture04

  2. A Couple We’ve Seen Already range() len()

  3. Functions They’re like mini programs, they reduce reduce repetition. defmy_sum(array): sum = 0 iflen(array) == 0: return0 for item inarray: sum += item returnsum numbers = range(101) printmy_sum(numbers)

  4. my_sum defmy_sum(array): sum = 0 iflen(array) == 0: return0 for item inarray: sum += item returnsum numbers = range(101) printmy_sum(numbers)

  5. Which is Bigger Find the biggest of two numbers def bigger(num1, num2): if num1 >= num2: returnTrue else: returnFalse

  6. Which is Bigger Find the biggest number in an array

More Related