American Young Coder

AYC logo
Loading Events

« All Events

  • This event has passed.

7PM Python Level 1

November 2, 2018 @ 6:00 pm - 7:00 pm

  1. We went over Homework October 19.py
  2. We went over Homework Magic8Ball.py
  3. Python Quiz next week November 10, 2018
    1. Please study Last Quiz (3 weeks) ago.
    2. Please study Homework October 19
    3. Please study Homework Magic8Ball.py
    4. Please study how to use List, how to print element inside a List.
  4. Some exercises to prepare for the test
    1. Exercise 1:
      1. Create a function called “printSomething()”
        1. Inside the function generate a random number between 1 to 4 and set/save it into variable called “randomNum”.
        2. If computer pick number 1, then print “Hi number one is cool.”
        3. If computer pick number 2, then print “Number two is cooler.”
        4. Everything else then print “<randomNum> is the best”.
        5. Call the function.
    2. Exercise 2:
      1. Create a python function name “subtractTwoNumbers” takes 2 parameters. Subtract 1st parameter with the 2nd parameter and return the value.
      2. Call the function and set/save return value to a variable call “result”.
      3. And then print “Result of subtraction is <whatever the result from the function>”
      4. For example, if I call the function like the following “subtractTwoNumbers(10,2)” , “result” variable will have a value of 8 and the print will print “Result of subtraction is 8”.
    3. Exercise 3:
      1. Create a function called “starwars”, no parameter.
        1. Create a variable with data type List of String call it “robots”.
        2. The value of this”robots” variable is: “R2-D2”, “C-3PO”, “ASN-121”.
        3. print each of these name using the list inside this function.
        4. Call this starwars function. When I call, it will print the following from inside the function.
          1. R2-D2
            C-3PO
            ASN-121
    4. Exercise 4:
      1. Create a function called “starwars2”. no parameter.
        1. Create a variable with data type List of String call it “robots”.
        2. The value of this “robots” variable is: “R2-D2”, “C-3PO”, “ASN-121”.
        3. Generate a random number between 0 to 2 and set it into a variable called “idx”.
        4. Use this “idx” variable to print one of the elements inside the List. For example, if “idx” is 0, the function will then print “R2-D2”. If “idx” is 1, then the function will print “C-3PO”.
    5. Exercise 5:
      1. Create a function called “starwars3”, one parameter.
      2. Copy the code from “starwars2” function into “starwars3” function.
      3. Instead of just printing the robot name, combine the robot name with the parameter.
      4. For example, if user call the function like the following
      5. starwars3(" is the best")
      6. And if the computer pick random number 1, then it will print
      7. C-3PO is the best

Details

Date:
November 2, 2018
Time:
6:00 pm - 7:00 pm
Event Categories:
,