jagomart
digital resources
picture1_Unit03 Algorithm 1


 139x       Filetype PDF       File size 0.65 MB       Source: www.cs.cmu.edu


File: Unit03 Algorithm 1
algorithmic thinking loops and conditionals last time a control flow structure for loop range n range start end range start end step assignments that modify variables x x y iteration ...

icon picture PDF Filetype PDF | Posted on 04 Feb 2023 | 2 years ago
Partial capture of text on file.
          Algorithmic Thinking: 
         Loops and Conditionals 
      Last Time 
       A control flow structure: for loop 
       range(n)  
        range(start, end)  
        range(start, end, step) 
       
       Assignments that modify variables: 
            x = x + y 
         Iteration with for loops 
     def test1():                 What determines how many 
          for i in range(1,6):   times “Woof” is printed is  the 
              print("Woof")       number of elements in the 
                                  range.   
     >>> test1()                   
     Woof                         Any expression that gives 5 
     Woof                         elements in the range would 
     Woof                         give the same output.   
     Woof                          
     Woof                         For example,  
                                  range(5), range(0,5), …  
                                   
         Iteration with for loops 
      def test2():                      range(5)         ? 
          for i in range(1,6):          range(0, 5)      ? 
              print(i, end='-')         range(1, 6)      ? 
                                         
       >>> test2()                      range(1, 10, 2)  ? 
       1-2-3-4-5-                       range(2, 10, 2)  ? 
                                         
                                        range(10, 1, -1) ? 
                                        range(10, 2, -4) ? 
                                         
                                         
The words contained in this file might help you see if this file matches what you are looking for:

...Algorithmic thinking loops and conditionals last time a control flow structure for loop range n start end step assignments that modify variables x y iteration with def test what determines how many i in times woof is printed the print number of elements any expression gives would give same output example...

no reviews yet
Please Login to review.