American Young Coder

AYC logo
Loading Events

« All Events

  • This event has passed.

7PM Python Level 1

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

  1. We went over the Stary Night homework.
  2. We completed Stary Night project from page 90 to 96.
    1. We learned the difference between “random.randrange” and “random.randint”.
    2. We learned how to choose random element inside a list using random index and random.choice.
    3. We learned how to create star in the Stary Night project by clicking.
  3. Homeworks:
    1. Create a python file call it “MegaRandom.py”
      1. Create a variable data type is list of string call it “gospel” and the value would be “Matthew”, “Mark”, “Luke”, “John”.
      2. Create a function call it “giveMeRandomGospel1” with no parameter.
        1. In this function return a random element from list “gospel”. Use “random.randrint” to select a random element from the list.
        2. Call this function and concatenate the result with “Random gospel1 = ” and print the result to the screen.
          1. For example, the result could be something like the following if you call the function twice and print the result twice
          2. Random gospel1 = Mark
            Random gospel1 = John
      3. Create a function call it “giveMeRandomGospel2” with no parameter.
        1. In this function return a random element from list “gospel”. DO NOT use “random.randint” to select a random element from the list. Look at previous class to see which other random function you can use to select random element from list.
        2. Call this function and concatenate the result with “Random gospel2 = ” and print the result to the screen.
          1. For example, the result could be something like the following if you call the function twice and print the result twice
          2. Random gospel2 = Mark
            Random gospel2 = John
    2. Modify the previous homework file “stary_night.py” to do the following
      1. Create a new function call it “draw_planet” with 4 parameters: size, color, x, y.
      2. Look at page 97 on how to create “draw_planet” function. Inside the book the size of the circle is always 50. Modify the size of the circle to be according to parameter size.
      3. In the project, inside the loop which creates the random stars, modify the code so it will do the following
        1. IF random.randint(1,2) == 1 call “draw_planet” function  ELSE call “draw_star” function.

Details

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