American Young Coder (AYC)

AYC logo
Loading Events

« All Events

  • This event has passed.

7PM- Intro to Python – Joshua Widjanarko

January 30 @ 12:00 am

Today We Did

  1. Reviewed Star Wars Homework
  2. Reviewed random
  3. Reviewed how to make and call functions

steps to making a function review

  1. initialize your function
    1. def <function_name_here>(paramater1,paramater2):
  2. Write your code (“indented”)
  3. if you need to return the value to use outside the function use the return function
    1. return <insert what you are returning here>
  4. call your function by writing the name of the function, parentheses, and the paramaters
    1. function_name(paramater1,paramater2)    <—- how to call a function
    2. if you return it, you need to put it somewhere

Homework: Note I am including the homework due in two weeks so you can get a head start. If you can do the homework without looking at anything, you will do fine on the quiz

Finish starwars_weapons if you haven’t already (https://www.ayclogic.com/intro-to-python/star-wars-problem/)

Do the following problem in the file random_rarity_hw.py

  1. create a function  random_rarity with one paramater(“type”)
  2. have a list called rarity with the following strings “Rare”, “Super Rare”, “Legendary”, “Mythical”
  3. have a second list called animals  with the following strings “Dog”, “Cat”, “Chicken”
  4. have  a third list  called water_animal with the following strings “Whale”,”Dolphin”,”Fish”
  5. get a random rarity, random animal, and random water animal
  6. If Aquatic print the phrase (“You Got a <rarity> <random water animals>”)
  7. if Land print the phrase(“You Got a <rarity> <random animals>”
  8. Example
    1. if you called your function like this
      1. random_rarity(“aquatic”)
    2. it could print
      1. “You got a Super Rare Whale”

 

The above homework is due next week

The Below homework is due in two weeks

In the file called quiz_2_hw.py

Homework Link For Quiz 2

Details

Date:
January 30
Time:
12:00 am
Verified by MonsterInsights