jagomart
digital resources
picture1_Python Pdf 182860 | 8 Aandds Lists


 156x       Filetype PDF       File size 1.63 MB       Source: www.eletel.p.lodz.pl


File: Python Pdf 182860 | 8 Aandds Lists
algorithms and data structures 8 lists od 2012 lists exercise sieve of eratosthenes the sieve of eratosthenes is an old algorithm that makes a list of primes list the integers ...

icon picture PDF Filetype PDF | Posted on 31 Jan 2023 | 2 years ago
Partial capture of text on file.
          Algorithms and Data Structures 
                       8. Lists 
                      Łódź 2012 
                                                                                                                                                                                   Lists 
                                    Exercise – Sieve of Eratosthenes 
        The Sieve of Eratosthenes is an old algorithm that makes a list of primes: 
        - List the integers begining with 2. 
        - Circle 2 (it must be prime) and cross out all its multiples (they can not be prime). 
        - Circle the next integer that is not crossed out (3) and cross out its multiples. 
        - Repeat. 
         
         
         
         
         
           Nesting 
         
         
        A Materka & M Kociński, Algorithms & Data Structures, TUL IFE, Łódź 2012                                                                                                             2 
                                                                                                    Lists 
                                             Python lists 
      A Python list is a data type that stores a sequence of items. They are 
      similar to strings. But while every item in a string is a single character, list 
      elements may be of any type, e.g. 
       
      >>> a_list = [10, False, „Hello”, 3.14159].  
       
      A pair of empty brackets [] denotes an empty list. 
       
                                                                     0      10 
                                                                     1      False 
       
      Pointers (references to memory location)                       2      „Hello” 
                                                                     3      „3.14159 
       
       
       
     A Materka & M Kociński, Algorithms & Data Structures, TUL IFE, Łódź 2012                            3 
                                                                                                  Lists 
                                             Python lists 
      The following operations all work the same for lists as they do for strings: 
      - Indexing using [] 
      - Slicing using [i:j:k] 
      - Concatenation using + 
      - Repeated concatenation using *n 
      - for loops 
      - Accumulation loops 
      - in and not in 
       
      Caution: Concatenation only works between objects of the same type. 
      For example, 
      >>> items = [1, 4, 7] + „abc” 
      will cause an error because the type of [1, 4, 7] (list) does not match the 
      type of „abc” (string). 
       
     A Materka & M Kociński, Algorithms & Data Structures, TUL IFE, Łódź 2012                          4 
The words contained in this file might help you see if this file matches what you are looking for:

...Algorithms and data structures lists od exercise sieve of eratosthenes the is an old algorithm that makes a list primes integers begining with circle it must be prime cross out all its multiples they can not next integer crossed repeat nesting materka m kociski tul ife python type stores sequence items are similar to strings but while every item in string single character elements may any e g pair empty brackets denotes false pointers references memory location hello following operations work same for as do indexing using slicing concatenation repeated n loops accumulation caution only works between objects example abc will cause error because does match...

no reviews yet
Please Login to review.