Skip to content

Instantly share code, notes, and snippets.

View fchikwekwe's full-sized avatar
🏝️

Faith Chikwekwe fchikwekwe

🏝️
View GitHub Profile
/*
I am writing a class called GenericCar and trying to create a new car object
that should be blue. I got stuck when trying to pass in the car color, but
I'm not sure how to solve the issue. I tried looking at the p5.js reference
section for help, but I'm not sure how to use it yet.
*/
function setup(){
createCanvas(400, 400);
}
function setup(){
createCanvas(400, 400);
}
function draw(){
var fastCar = new GenericCar(100, 55, "blueu");
fastCar.drawCar()
}
class GenericCar {
def length(self):
"""Return the length of this linked list by traversing its nodes."""
node_count = 0 # initial count is zero
current = self.head # start at the head
# Loop through all nodes
while current is not None:
current = current.next
# add one to the counter each time
node_count += 1
for name in name_list: # we go over every name in the list
name = name.title() # we change every name
counter += 1 # each time, we add 1 more to the counter
all_students_stuff = {
"bob": {
"clothing": ["sneakers", "hat"],
"storage": ["backpack"],
"food": ["apple sauce", "sandwich"]
},
"marie": {
"clothing": ["gloves", "cleats"],
"hair stuff": ["hair brush"]
},
all_students_stuff = {
"bob": ["backpack", "sneakers", "hat"],
"elena": ["gloves", "hair brush", "cleats"],
"piper": ["backpack", "sneakers", "hat"]
}
list2.insert(0, 1) # inserting number 1 at index 0
list2.pop() # removing the last value
list1 = [1, 2, 3]
list2 = [1, 2, 3]
# oh no! which value will we get?
dictionary = {
# list1 = [1, 2, 3]
list1: "a_value",
# list 2 = [1, 2, 3]
list2.insert(0, 1) # inserting number 1 at index 0
list2.pop() # removing the last value
list1 = [1, 2, 3]
list2 = [1, 2, 3]
# oh no! which value will we get?
dictionary = {
# list1 = [1, 2, 3]
list1: "a_value",
# list 2 = [1, 2, 3]
list1 = [1, 2, 3]
list2 = [2, 3, 4] # different
# luckily the keys are unique here
dictionary = {
# list1 = [1, 2, 3]
list1: "a_value",
# list 2 = [2, 3, 4]
list2: "another_value"
}
# this dictionary only has one entry
example_dictionary = {"key": "value"}
# this dictionary has multiple entries
another_dictionary = {
"first_key": "cool_value",
"second_key": "awesome_value",
"lots_of_keys": "cool_value"
}