Lecture 6

Feb. 7th, 2010 09:28 pm
winterthunder: (Default)
[personal profile] winterthunder posting in [community profile] intro_to_cs
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

Date: 2010-02-09 12:25 am (UTC)
jbanana: Badly drawn banana (Default)
From: [personal profile] jbanana
Those 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.

Date: 2010-02-10 07:49 pm (UTC)
jbanana: Badly drawn banana (Default)
From: [personal profile] jbanana
I've been having a go at the problem sets. It's quite good fun, particularly as I'd forgotten lots about python.

VRiTjGxGuwj

Date: 2012-05-03 08:49 am (UTC)
From: (Anonymous)
Please feel free to moderate my cnmemot. My goal is to just the attention of the author. I don't intend to hurt anyone's feelings. Thanks. Btw I was not able to edit my cnmemot. Thought this would help.

QImETheFBbqMnovNHp

Date: 2012-01-07 10:45 am (UTC)
From: (Anonymous)
If you're reidnag this, you're all set, pardner!

Date: 2010-02-15 03:45 pm (UTC)
From: [personal profile] aranthe
I finally watched 6 and 7 yesterday and discovered that I probably need to update my solution to the last problem in PS4 to use NR instead of bisection. Which is kind of annoying, but not nearly as annoying as his remark about both being a possible problem under certain conditions but we're going to drop it for now...

JcUolZKXcrKozMsPoyL

Date: 2012-01-07 09:58 am (UTC)
From: (Anonymous)
I don't even know what to say, this made things so much easeir!

AEvQgqDzbKQvy

Date: 2012-05-03 09:37 am (UTC)
From: (Anonymous)
Bravo, istinski ghosert reportaj ot mqstoto na sabitieto, dokumentiran s aktualni snimki (nqmam predvid bombandirovkite v Belgad, razbira se, a protestite sreshtu NATO vav Freiburg)! Silno me valnuva kakvo biha predprieli s tezi tankoobrazni mashini chengetata

Profile

Introduction to Computer Science

July 2010

S M T W T F S
    123
45678910
11121314151617
18192021222324
2526272829 3031

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 9th, 2025 01:33 am
Powered by Dreamwidth Studios