Exercise 03

Record videos of your programs running by using MS Stream and save the video into the videos folder. Make the view appear at the bottom of this page.




Processing by Looping and Selecting

Use the Cards dictionary for this set of exercises

  1. Write a function called calclateValueofEvenCards() that takes the following parameters:
    • cards dictionary
    • either 1 for odd or 0 even
    and then does the following:
    1. loops through the all the cards
    2. If the card has an index value that is EVEN AND the second paramter passed is 1 then the subroutine should take a note of the value of each card selected and add it to a running total
    3. The subroutine should then return the total to the main routine


    After the function calclateValueofEvenCards() is called from the main routine it should print out the total that has been returned, to the console.

  2. Write a function called calclateValueofOddCards() that takes the following parameters:
    • cards dictionary
    • either 1 for odd or 0 even
    and then does the following:
    1. loops through the all the cards
    2. If the card has an index value that is ODD AND the second parameter passed is 0 then the subroutine should take a note of the value of each card selected and add it to a running total
    3. The subroutine should then return the total to the main routine


    After the function calclateValueofOddCards() is called from the main routine it should print out the total that has been returned, to the console.

  3. Write a function called calclateValueofCards() that takes the following parameters:
    • cards dictionary
    • the number of cards to deal
    and the does the following:
    1. loops through the cards the specified number of times selecting a random card on each loop.
    2. The subroutine should take a note of the value of each card selected and add it to a running total
    3. The subroutine should then return the total to the main routine


    After the function calclateValueofCards() is called from the main routine it should print out the total that has been returned, to the console.



Put your evidence here: