Open Side Menu Go to the Top

06-06-2012 , 05:49 PM
If Udacity is 7 or 8 class modules compared to MIT's 24 classes, so yes, the MIT class is probably much more thorough. As for finding answers to 6.000, there are quite a few (poorly done) answers found online.

6.000 has a pretty specific goal of preparing you for 6.001 (Structure and Interpretation of Computer Programs).

The approach is, from what I can remember, pretty CS-heavy and not particularly focused on Python: in fact the professor is pretty vocal about his contempt toward the language. Some quotes I remember:

"I hate this friggin' language."
"Ooops, I thought I was writing Lisp."
"I'm a Lisp hacker, so using this language is..."
"I ~hate~ this (operation overload / whatever feature)."
"This is how Python handles lists, which isn't so bad, but (long mind-blowing dissertation in how Lisp handles lists) which is far better."

Unfortunately, he didn't teach the OO part of the class. I'm sure that would have been wildly entertaining. (OO is pretty controversial in Lisp programming and generally frowned upon)

Sounds like an awful teacher, but he was actually really really good. There were a few classes I had to watch twice to understand it. At the time of taking this course, I didn't have a job, so I finished it in one month, but with a job, it would've taken me 3 to 5 months.

So, with time constraints and stuff, Udacity's shorter format is probably a good option.

As for the problem in question: It's find the 1001st prime. I guess to weigh the speed (and perhaps quality?) of each class, figure out how far you'd have to be in Udacity before they would introduce that question.
** Python Support Thread ** Quote
** Python Support Thread **
150% up to $2,000 Welcome Bonus on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** Python Support Thread **
06-06-2012 , 06:16 PM
Putting the actual content aside, Udacity's delivery method is MUCH better. OCW has no interactivity. Udacity prompts the students to answer questions and actually write code. That's more interactivity than most students (the ones who sit in the back and don't raise their hand) get actually attending MIT lectures. Udacity actually feels like the professor is tutoring me personally. I'm a fan.
** Python Support Thread ** Quote
06-06-2012 , 07:02 PM
Sorry if I misled anybody. I was just seconding an opinion that Udacity is pretty good. I don't know anything about the MIT program.
** Python Support Thread ** Quote
06-06-2012 , 07:47 PM
Quote:
Originally Posted by daveT
I did this class. You're way over-thinking this part of the problem.

Think about this step: You simply want to print a column of numbers that are odd, right?

1
3
5
7
9
11
...

Think about the unique feature of integers that would make generating that list easy.

You have the following steps:

initialize a variable. What variable would allow you to take advantage of the unique feature alluded to?

generate the list: What would you do to that initial variable that reflects the unique feature alluded to?

See how I wrote down what you wanted to do? That class says using a pencil and paper is an important step in programming and I absolutely agree with that assertion. Writing down the output you want to see will help you see things that you may not have noticed before.

If you really do give up, then use the spoiler tag:

Try to fill in the blanks:

Spoiler:
Code:
x = ?

while x < 100:
    print x
    {{ What are you going to do to X?? }}}


Ohh, yeah, I finally got that. I wrote a code to write down the odd numbers and now I am trying to figure out how to determine if the odd number is prime or not.

I can do it on paper, and I know I probably have to use the a%b, but it just doesn't seem to be coming out. I'll keep working at it D:<!
** Python Support Thread ** Quote
06-06-2012 , 07:54 PM
So I had this to find the odd number,
Quote:
odd_number=-1
while odd_number<10:
odd_number +=2
print (odd_number)

and then i tried this to find the prime number
Quote:
odd_number=-1


while odd_number<10:

odd_number+=2

value=2

while value<10:
value+=1

if odd_number%value!=0:
print odd_number
but it gives me an output of eleven. Which baffles me because I put that odd_number<10 and value<10
** Python Support Thread ** Quote
06-06-2012 , 08:13 PM
Use <code> tags so we can see your indentation
** Python Support Thread ** Quote
06-06-2012 , 08:17 PM
You need to use code tags to format the code you are asking about. I'm not really sure if you are nesting loops or if you are writing consecutive loops. With that said:

Yes, the output should be 11 because the code did exactly what you told it to do. Did you get to the part where he is at the chalk board and charting out the looping function i/o? Do the same on a pencil and paper.
** Python Support Thread ** Quote
06-06-2012 , 08:34 PM
Code:
odd_number=-1

for x in range(1,11):
	odd_number+=2
	print odd_number
This is what i have so far. (i changed it a little) So, I'm still a little confused on the concept of loops. If I put in the range (1,11), what exactly is it computing?

Thanks for all of the help guys ! I really appreciate it!
** Python Support Thread ** Quote
06-06-2012 , 08:46 PM
Try printing the value of x inside the loop so you can see for yourself what it's doing.
** Python Support Thread ** Quote
06-06-2012 , 11:10 PM
Quote:
Originally Posted by windwakeroftime

So, I'm still a little confused on the concept of loops. If I put in the range (1,11), what exactly is it computing?
This the reason why the class introduces loops with "while" and not "for"

Does the while loop feel stupid right now? Sure, since all you're trying to do is count some numbers, but soon you will have zero options but to use the while loop and unless you can learn to generate a basic counter with it, you're not going to be able to understand why other stuff is breaking.

If you're going to make it through this class, you must learn to do two things:

1- Pencil and Paper. I know, sounds primitive, so if you prefer: "back of the envelope computations."

2- Create toy programs. Trying to create a fully functioning program, as you are now hopefully discovering, isn't at all possible until you understand the components of each piece you are writing. To gain insight, you must create toy programs.

Copy / paste these into your IDLE, then type each one (these won't work due to indent errors) and see what they output, and try to understand why they work. Once you ~think~ you understand the codes, try creating your own toy codes and see if the output you expected to see is what you get. If not, try to find out why:

Code:
x = 1


while x < 9:
    print x
     x += 2

  
while x <= 9:
     print x
     x += 2


 while x < 9:
     x += 2
    print x
 
 while x <= 9:
     x += 2
    print x

 while x < 9:
     x += 2
print x
You absolutely positively must get this understood. Programming in just about all of its essence is flow control and loops, and not being able to conquer the while loop is inexcusable.

If at this point of the class, you have not been introduced to for loop, then you should probably try to do this hw in while loops only. I think it's worth the effort.
** Python Support Thread ** Quote
06-06-2012 , 11:16 PM
Quote:
Originally Posted by daveT
If at this point of the class, you have not been introduced to for loop, then you should probably try to do this hw in while loops only. I think it's worth the effort.
This is good advice imo. But if you want a hint as to what the for loop is doing, try:

Code:
print range(1,11)
** Python Support Thread ** Quote
06-09-2012 , 11:47 PM
i am using python and sqlite3 to make a database and analyze the information. can i get some tips on database design please? the data is there are 21 turtles and there are measurements taken on their shell length, width, and weight, and these measurements were all taken 5 different times one week apart. how do i structure this data?
** Python Support Thread ** Quote
06-09-2012 , 11:58 PM
Would probably just do a couple tables like:

Code:
Table Turtles:
ID, Name, Age, Sex, Location

Table Measurements:
MeasureID, TurtleID, MeasuredDateTime, Length, Width, Weight
** Python Support Thread ** Quote
06-10-2012 , 12:00 AM
Sounds like all you need is one table with these fields:

TurtleID, MeasurementDate, Length, Width, Weight

Edit: Neko is correct. Add the second table for the turtle info.

Last edited by Jbrochu; 06-10-2012 at 12:09 AM.
** Python Support Thread ** Quote
06-10-2012 , 12:04 AM
lol thanks for some reason i was thinking need a new table for each measurement date. it seems like database work could get complex though if you have a lot of data
** Python Support Thread ** Quote
06-10-2012 , 12:06 AM
well as long as im here, here is another question. so i have this table in sqlite with a column of data type REAL, yet when i run a SELECT command and get the data and do c.fetchall() or c.fetchone() it returns me the correct number but as data type "none type" so i cant manipulate the number. how do i get the data as a REAL
** Python Support Thread ** Quote
06-10-2012 , 12:08 AM
It's more likely returning it as a string then untyped. You should be able to change to a float/real by doing:

Code:
x = "123.4"
x = float(x)
** Python Support Thread ** Quote
06-10-2012 , 12:15 AM
oh i see it is returning it as a list so i just have to get first element of list. sorry kind of dumb question i am just burning out now and i'm a newbie programmer
** Python Support Thread ** Quote
06-10-2012 , 10:57 PM
do you guys use gspread or gdata library?
** Python Support Thread ** Quote
06-10-2012 , 11:12 PM
kind of annoying if i do gspread.range it returns numbers turned into text strings with the cell number in text.

found this it helps, sales_data = [float(c.value) for c in worksheet.range('E1:E17')]

Last edited by unluckyboy; 06-10-2012 at 11:29 PM.
** Python Support Thread ** Quote
06-11-2012 , 10:32 PM
Code:
q=1
while q == 1:

    x=int(raw_input('what is yo numba'))
    counter=0
    for pn in range (2,x+1):
        if x%pn==0:
                counter=counter+1
    if counter==1:
        print x, 'is a prime numba.'
    else:
        print x, 'is not a prime numba. srry betch yo numba aint prime'
I've got how to determine whether a number is prime or not, but now I'm trying to figure out how to find out what "number" prime number it is.

So 2 is the first prime number
3 is the second
etc.

HALP.
** Python Support Thread ** Quote
06-11-2012 , 10:36 PM
Excuse my french. Just having a little fun with the program.
** Python Support Thread ** Quote
06-11-2012 , 10:54 PM
It doesn't seem to work:

Code:
>>> 
what is yo numba3.4
Traceback (most recent call last):
  File "C:/Documents and Settings/d/Desktop/prim.py", line 4, in <module>
    x=int(input('what is yo numba'))
ValueError: invalid literal for int() with base 10: '3.4'
>>>
Two questions:

1- Do really need to divide by every single number up to the candidate?

2- Do you know how to find the 1001st prime yet? If not, then try that first, then do this one.
** Python Support Thread ** Quote
06-14-2012 , 12:42 PM
what do you use for parsing HTMl with python? beautiful soup, elementtree, just regex?
** Python Support Thread ** Quote
06-14-2012 , 02:01 PM
I've never used beautiful soup or elementtree, but the answer is not regex.
** Python Support Thread ** Quote
** Python Support Thread **
150% up to $2,000 Welcome Bonus on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
** Python Support Thread **

      
m