4.2.9 Python Iterations

Pseduo Code and Iterations

// pseudo code variables must be in upper case

VARA = 10

VARB = 0

loop while   VARA > VARB

        VARA=VARA-1

       output "outer loop " ;

       loop while ( VARA < VARB )

                    output  "inner loop" ;

                    VARA = VARA-1

                             

       

Class Activity 

Before Running Program record your answers to questions below

Q1. What is going to be the output when a=10 and b=4?

Q2. What is going to be the output when a=4 and b=10?

Q3. What is going to be the output when a=10 and b=0?

Q4. What is going to be the output when a=10 and b=9?

Open Anaconda and Convert the above Pseudo code into Python and test your expected results

Selection Sort :

Given array sortmeplease = [3,6,9,2,7,0,8]

Create a solution in pseudo code to perform a selection sort ( set start position = 0 then compare the element the start position with the rest of the elements  ( performing  a swap ) if next is smaller than current at then end of the first iteration the smallest element should be in position 0, but you need to sort all elements.


 

Scroll to Top