Amazing Little Ecosystem (
winterthunder) wrote in
intro_to_cs2010-02-07 09:28 pm
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
![[community profile]](https://www.dreamwidth.org/img/silk/identity/community.png)
Entry tags:
Lecture 6
So, who thinks the other professor was better? I'm finding this guy harder to follow, though I did catch that computers can be wrong and paranoia is good.
Paranoia, paranoia everybody's coming to get me...
Er.
I have to say, I understand the whole lists, appending lists, concatenating lists idea, but I'm not following the code. For the universities bit, what are all the raw_inputs there for? Is the for loop just there to show that appending lists is messy? And which line is the concatenate? Is it "Univs = Techs + Ivys"?
(Class handout is here, and I've pasted the relevant code section under the cut.)
Techs = ['MIT', 'Cal Tech']
print Techs
Ivys = ['Harvard', 'Yale', 'Brown']
print Ivys
Univs = []
Univs.append(Techs)
print Univs
Univs.append(Ivys)
raw_input()
print Univs
raw_input()
for e in Univs:
> print e
> for c in e: print c
raw_input()
Univs = Techs + Ivys
print Univs
raw_input()
Ivys.remove('Harvard')
print Univs
Ivys[1] = -1
print Ivys
Paranoia, paranoia everybody's coming to get me...
Er.
I have to say, I understand the whole lists, appending lists, concatenating lists idea, but I'm not following the code. For the universities bit, what are all the raw_inputs there for? Is the for loop just there to show that appending lists is messy? And which line is the concatenate? Is it "Univs = Techs + Ivys"?
(Class handout is here, and I've pasted the relevant code section under the cut.)
Techs = ['MIT', 'Cal Tech']
print Techs
Ivys = ['Harvard', 'Yale', 'Brown']
print Ivys
Univs = []
Univs.append(Techs)
print Univs
Univs.append(Ivys)
raw_input()
print Univs
raw_input()
for e in Univs:
> print e
> for c in e: print c
raw_input()
Univs = Techs + Ivys
print Univs
raw_input()
Ivys.remove('Harvard')
print Univs
Ivys[1] = -1
print Ivys
no subject
raw_input()
calls are just there to pause the output so that he could talk about what happened.The
for
loop is to show what's in the outermost list: some more lists, which you can iterate over with a nested loop.You're right about which line is the concatenation.
Hope you don't mind the drive-by comment. I saw this community and couldn't resist watching one of the lectures. I didn't learn much about computing (luckily - it's my job!) but I learned how to approximate a square root.
no subject
And I don't mind drive-by comments at all, especially not when they're helpful! Welcome, and feel free to stick around. :)
no subject
VRiTjGxGuwj
(Anonymous) 2012-05-03 08:49 am (UTC)(link)QImETheFBbqMnovNHp
(Anonymous) 2012-01-07 10:45 am (UTC)(link)no subject
JcUolZKXcrKozMsPoyL
(Anonymous) 2012-01-07 09:58 am (UTC)(link)AEvQgqDzbKQvy
(Anonymous) 2012-05-03 09:37 am (UTC)(link)