unit 3 lesson 1-2!
lesson 1-2 stuff
NOTES
PYTHON
variables
represent a value with a variable- strings, lists, booleans, numbers determine the value of a variable by using an assignment
use equal sign to define a variable (with number, string, list, boolean) strings need quotations and lists need square brackets
you can use append for lists. mathematical functions can be performed on variables w numerical value
curly brackets and equal sign defines a dictionary
interchange variables by using a temporary variable
even function- can determine if variable is even or add- use variables with functions. use def to define function.
JAVASCRIPT
use var to assign variables using numbers can help with algabraic functions can also use const _ = value let __ = _
can also use string (letters that form words) list contains multiple data points
console log connects to data abstraction- data points can be pulled from lists
- toc: true
- comments: true
- categories: [Week-13,Big-Idea-3]
DATA ABSTRACTION
provides seperation between abstract proprerties of a data type and the concrete details of its representation. manages complexity in programs by giving collection of data a name. makes it easier to implement, develop, maintain code. lists allow multiple related values to be treated as one value.
PYTHON
lists can be used to organize, maintain, develop related data
a list of students in a class would be under one variable- helps organize data and make less mistakes
you can further segregate a list using similar characteristics. you can also use this to organize data from apis and other resources. you can call and seperate and organize individual elements of a list by using a for loop split() splits a string into a list (default seperator is a white space) join() method takes all items iterable and joins them into a string.
albums = [
("Welcome to my Nightmare", "Alice Cooper", 1975, # First album list
[
(1, "Welcome to my Nightmare"),
(2, "Devil's Food"),
(3, "The Black Widow"),
(4, "Some Folks"),
(5, "Only Women Bleed"),
]
),
("Bad Company", "Bad Company", 1974, # Second album list
[
(1, "Can't Get Enough"),
(2, "Rock Steady"),
(3, "Ready for Love"),
(4, "Don't Let Me Down"),
(5, "Bad Company"),
(6, "The Way I Choose"),
(7, "Movin' On"),
(8, "Seagull"),
]
),
("Nightflight", "Budgie", 1981,
[
(1, "I Turned to Stone"),
(2, "Keeping a Rendezvous"),
(3, "Reaper of the Glory"),
(4, "She Used Me Up"),
]
),
("More Mayhem", "Imelda May", 2011,
[
(1, "Pulling the Rug"),
(2, "Psycho"),
(3, "Mayhem"),
(4, "Kentish Town Waltz"),
]
),
]
album_id = int(input("album?"))
song_id = int(input("song?"))
print("playing \"{0}\" from album \"{1}\"".format(albums[album_id-1][3][song_id-1][1],albums[album_id-1][0]))
n = input() print("playing...." + albums[int(n)][0])
index = 0 while index < len(albums): print(albums[index][0][int(n)], albums[index][3][int(n)]) index += 0