Gaheera Rhea Hannah Rowan
# Python Popcorn Hack 2: Fruit Dictionary
fruits = {
"apple": {
"color": "red",
"taste": "sweet",
"season": "fall",
"description": "Apples are crunchy and sweet. They are often used in pies and desserts."
},
"banana": {
"color": "yellow",
"taste": "sweet",
"season": "year-round",
"description": "Bananas are soft and sweet. They are great as a snack or in banana bread and smoothies. They are excellent sources of potassium."
},
"orange": {
"color": "orange",
"taste": "citrus",
"season": "winter",
"description": "Oranges are juicy and tangy. They are full of vitamin C and perfect for juice."
}
}
print(fruits["banana"]["description"])
Bananas are soft and sweet. They are great as a snack or in banana bread and smoothies. They are excellent sources of potassium.
%%js
//Popcorn Hack 3: Define variables automatically using let and const, write console.log() statements and demonstrate knowledge of accessing the console correctly, and short function that correctly calls each variable and string them together to make a sentence.
// Automatically define variables
const name = "Gaheera"; // Using const because the name will not change
let age = 17; // Using let since the age can change
const favoriteFruit = "watermelon"; // This will remain constant
let school = "Del Norte High School"; // School might change later
// Demonstrate accessing variables via console.log()
console.log("Name:", name);
console.log("Age:", age);
console.log("Favorite fruit:", favoriteFruit);
console.log("school:", school);
// Short function that combines variables into a sentence
function createSentence() {
return `Hi, my name is ${name}. I am ${age} years old, and I love ${favoriteFruit}. I currently go to ${school}.`;
}
// Call the function and log the sentence to the console
console.log(createSentence());
// Changing values of the variables declared with 'let'
age = 18;
// Call the function again with updated values
console.log(createSentence());
<IPython.core.display.Javascript object>
%%js
// Popcorn Hack 4: Create your own array using two or more diffrent data types we throughout the lesson!
let classmates = ["rowan", "gaheera", "rhea", "hannah"];//creates an array of strings (classmates) and logs it to the console
console.log("Array: ", classmates);
element.append("Array: " + classmates.join(", "));
let data = ["integer", "string", "boolean", "float"];
console.log("Array: ", data);
element.append(" Array: " + data.join(", "));
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>