- This event has passed.
7PM- Intro to Python – Joshua Widjanarko
January 30 @ 12:00 am
Today We Did
- Reviewed Star Wars Homework
- Reviewed random
- Reviewed how to make and call functions
steps to making a function review
- initialize your function
- def <function_name_here>(paramater1,paramater2):
- Write your code (“indented”)
- if you need to return the value to use outside the function use the return function
- return <insert what you are returning here>
- call your function by writing the name of the function, parentheses, and the paramaters
- function_name(paramater1,paramater2) <—- how to call a function
- 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
- create a function random_rarity with one paramater(“type”)
- have a list called rarity with the following strings “Rare”, “Super Rare”, “Legendary”, “Mythical”
- have a second list called animals with the following strings “Dog”, “Cat”, “Chicken”
- have a third list called water_animal with the following strings “Whale”,”Dolphin”,”Fish”
- get a random rarity, random animal, and random water animal
- If Aquatic print the phrase (“You Got a <rarity> <random water animals>”)
- if Land print the phrase(“You Got a <rarity> <random animals>”
- Example
- if you called your function like this
- random_rarity(“aquatic”)
- it could print
- “You got a Super Rare Whale”
- if you called your function like this
The above homework is due next week
The Below homework is due in two weeks
In the file called quiz_2_hw.py