Lec 2 | MIT 6.00SC Introduction to Computer Science and Programming, Spring 2011



Lecture 2: Core Elements of a Program
Instructor: John Guttag
View the complete course: http://ocw.mit.edu/6-00SCS11

License: Creative Commons BY-NC-SA
More information at http://ocw.mit.edu/terms
More courses at http://ocw.mit.edu

source

49 thoughts on “Lec 2 | MIT 6.00SC Introduction to Computer Science and Programming, Spring 2011

  • January 20, 2022 at 11:07 pm
    Permalink

    Very good instruction. But I think that a significant flaw is the failure to explore the non-intuitive notion that a scalar is "indivisible". I'm just guessing that later we will learn that it's not 'indivisible' numerically but in the compiler inability to parse it.

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    how can True and False lead to give False. I am a beginner please help if anyone can

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    Why can't int ('0.0') be converted into int while
    Just
    int(0.0)
    Can
    Output Simulation Results
    Int('0.0')
    Error
    Int(0.0)
    0

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    Wait That's python 2.5.1. But version 3.0 and newer are different. Should i watch 6.00SC ? Is it going to help me now(2018)? Or instead should i independently learn python and develop programming skills?

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    I have installed python 3.7 but I can't find the text editor. The IDLE is there, so where will the text editor be? Should I install a normal text editor like notepad++?

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    I wonder what is ans times ans times ass equal to?!
    But really thanks MIT and thanks to this wonderful prof for being awesome

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    is this python 2 or 3?
    i'm assuming 2, because "raw_input" doesn't work with 3.

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    I've tried to run the cube root code (48:20) on Python and it gives me syntax, is it because I'm using 3.0? If it is what should I change to make the program run? ( I already know that raw_input is input )

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    For those who didn't get the 22:37 to 24:18
    open notepad and write any expression or integer, like write 3, or 'abc' and then click on file, then save as. In save as, write the name of file as script1.py
    .py is essential part since then computer thinks of that original notepad file as a python script.
    then change file type to all types. You have now a separate script.

    Ok, now what? Open the Python IDLE Shell, or you might already have opened it like in the video. Now click on Files and then click Open, then select script1.py which now opens in another shell. For version 3 of Python, when you write print, do not give any space and use parentheses like print(type('a')) and then save it from file corner then hit F5.
    Your IDLE will give you results.

    I am very new to this programming concept and thus it took me a lot to figure this out, which would have been an obvious thing for a CS student. Its for those who were like me and didn't get it.

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    At 20:00, When he enters int('.0'), he uses quotation marks, but while entering int(2.1), he doesn't.
    I get no error without quotes and an error with quotes in both cases.(Using Python 2.5.4)

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    In Phyton 3.x it is
    x=int (input('Enter an intenger: '))
    if x%2 == 0:
    print ('Even')
    else:
    print ('Odd')
    if (x%3 != 0):
    print ('And not divisible by 3')

    So, not ; sign, : sign

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    Thought it was a graduate student with nothing to do with very steady arms to hold it up for close to an hour.

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    Are those remote control cameras on a tripod recording the lecture?!

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    I was trying to run his script for the 'Enter a number' thing, but every time I try, it gives me a syntax error at the 'print y' part in the second line.

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    I love these lectures but I have already made a lot of progress learning Ruby. I know Python and Ruby are very similar but I wish he was using Ruby because I want to stick with that instead of having to learn python for this course. Oh well, he had to choose some language to use as an example I guess. It is what it is…

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    for those of you using python 3.0 or newer raw_input() was renamed to input()

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    I'm so confused.. I have the python shell program but how do I run it like he did at about 29:04?

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    This Comment Made by PrestigeSeattle really helped. For understanding 35:49
    if x%2 == 0;
    print 'Even'
    else;
    print 'Odd'
    if x%3 != 0;
    print 'And not divisible by 3'

    This "%" symbol is asking you for a remainder, so any odd number divided by 2 is going to have a remainder of one.
    The "==" is checking if it's equal
    The "!=" is checking if it's not equal

    The code in english would say: "If x divided by 2 has a remainder of 0, print "Even". Otherwise print "Odd." Also, if x divided by 3 has a remainder that isn't 0, print "And not divisible by 3"

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    i was working in Python IDL version 3.5.0 and comparing with the Prof's explanations. I noticed that at 14.04, the professor, says that >>> 3/2 gives 1 but 3.0/2.0 gives 1.5. In this version i am using ( 3.5.0), typing 3/2 gives me 1.5 and not 1. Why the difference? is it because of this version being better that used in lesson?

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    I honestly disagree that forcing indentation of Python is a good design. I am not sure if the prof has ever ran into the situation that Python shouts at you because you are using tabs to indent and not space.

    Good intention but very bad implementation.

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    more great stuff from MIT – thank you for posting these lectures, it's great to have the 2008 and 2011 classes available – I'm especially looking forward to the recitations in the 2011 classes. Lots of great examples and challenging problems to solve in the supplemental material from the classes, also thank you for all the references to reading material for the course!!!

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    Ans, ans, ans, ans, ass….now stop, and let that program run in IDLE now.

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    Actually in Python 3 there's only "input" but it behaves like "raw_input" from Python 2.

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    He says that Java doesn't allow something similar to int(2.1)?
    I think I can do (in Java):
    int a = (int) 3.2/1.5;
    or
    int b = (int) 2.1;
    can someone explain?

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    40:49 what is that character …if x%3 ?= 0:
                                                           print 'And not divisible by 3'
    damn 480p res. 1 doesn't make sense and is giving me a syntax err…
    else conditional is giving me errors too… maybe wrong Python version?
    I DL'ed it from the Courseware site's link – 2.7.3…. wtf…

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    "The problem with languages like C and Java is that you can indent things and fool the reader of the program." You mean like "goto fail; goto fail;"?

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    i'm trying to get a grasp of computer science and as of now know next to nothing on the subject… i'm watching these lecture videos and taking notes and everything… should i be concerned that some of the things he says just doesn't make sense to me?  

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    when he threw the candy it reminded me of micheal scott n then i thought i wish micheal scott was teaching the lecture and then i went to netflix and put on the office

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    script is a text that changed the option "view" to python (add-on).
    How to create a new text is to go to destop or any where, right-click and choose new -> new text.

    Reply
  • January 20, 2022 at 11:07 pm
    Permalink

    are we supposed to open 2 IDLE (Python GUI) or 1 IDLE (Python GUI) and 1 Python (command line) ?

    I open the Python (command line) which doesnt seem to work as shown in the video, doesnt have colour, its black and I cant copy and paste

    I download the corrrect version but not sure if downloaded the correct format since there are so many under Windows and I dont know which to choose

    Reply

Leave a Reply

Your email address will not be published.