Lec 7 | MIT 6.00 Introduction to Computer Science and Programming, Fall 2008

Поделиться
HTML-код
  • Опубликовано: 18 дек 2024

Комментарии • 89

  • @Ali_Alhajji
    @Ali_Alhajji 4 года назад +7

    "Some programs won't stop until I'm old and gray. Some programs won't stop until YOU'RE old and gray"
    Brilliant

  • @xiaofeiluo7463
    @xiaofeiluo7463 10 лет назад +8

    Prof Grimson is such a great teacher! it's hard for me to get distracted while following him.

  • @Seya02
    @Seya02 3 года назад

    I was recommended this so frequently by RUclips that I finally decided to watch this.

  • @matrixnaz
    @matrixnaz 12 лет назад +2

    @yurijzagrebnoy You might well be right. However, this is what I keep telling my students: We are not here to learn Python. We are trying to learn programming, we are trying to learn how to build computational models. So basically these two teachers are using Python as a tool to teach students how to program; to get into the habit of thinking algorithimically; and to get into the habit of building computational models for solving problems. Cheerz

  • @bnsonline5099
    @bnsonline5099 3 года назад +1

    Finally a very good method. It got me crazy "show dics" at 13:05.

  • @barack.obama.official
    @barack.obama.official 12 лет назад +11

    I admittedly got a bit excited when he said "show dics here".

  • @stanb5448
    @stanb5448 9 лет назад +7

    with Python 3.4.3it becomes :
    def getFloat(requestMasg, errorMsg):
    inputOK = False
    while not inputOK:
    val = float(input(requestMsg)) # accept float value as input instead of a string #
    if type(val)= type(1.0): inputOK = True
    else: print(errorMsg)
    return val

    • @vaibhavsingh1049
      @vaibhavsingh1049 7 лет назад +1

      Edit: if type(val) == type(1.0):
      OR
      if isinstance(val, float): inputOK = True

  • @babyyoda6715
    @babyyoda6715 8 лет назад +2

    wow prof grimson is such a great teacher! i wish i have a prof like him when i get to university :)

  • @gids522
    @gids522 8 лет назад +6

    Aw! The girl never got her candy for asking the question at 4:06 :'(
    She didn't want the "a very good question" ...

  • @Tuchewy11
    @Tuchewy11 2 года назад

    . learning so much so quickly

  • @jehugaleahsa
    @jehugaleahsa 13 лет назад

    @Nisstyre56 I would say premature optimization is worse than needless exception handling. Exception handling as a "flow of control" is becoming popular in interpreted languages because it really doesn't take much time as compared to the actual "interpretation" process. In static languages, if performance is crucial, then, yes, exception handling should be used with care. As for intepreted languages, I'd say bad input is exceptional, wouldn't you?

  • @warzix
    @warzix 13 лет назад

    @Mrxb0x Thank you for this very sagacious comment. It really makes a lot of sense.

  • @yumyum999zz
    @yumyum999zz 15 лет назад

    Maybe he means that when related to lists, "=" means a different thing or has additional meaning (is overload) then "=" in the case of x = -15. Not the ivys binding changes but that the bindings of ivys elements change.

  • @joelmuriuki6076
    @joelmuriuki6076 4 года назад

    Feels like I'm revising for a first year quiz alongside the professor

  • @SolidSnyder
    @SolidSnyder 13 лет назад

    I love how Prof Grimson took out the toys and the first thing that came to mind was THE TOWER OF HANOI C:

  • @brainstormingsharing1309
    @brainstormingsharing1309 3 года назад +1

    Absolutely well done and definitely keep it up!!! 👍👍👍👍👍👍

  • @Maeda_Toshiie
    @Maeda_Toshiie 8 лет назад +2

    Tower of Hanoi props at the end

  • @sgdrifter
    @sgdrifter 7 лет назад +2

    go to 13:04, i don't understand why the students weren't laughing...

  • @cityvoyage
    @cityvoyage 10 лет назад +1

    professor grimsom, glad you're back.

  • @peakwriters35
    @peakwriters35 12 лет назад +2

    Where is prof. fudge knuckle today?

  • @adiflorense1477
    @adiflorense1477 4 года назад

    32:44 is there really a computer program that doesn't stop until we are old?

    • @yoyoclockEbay
      @yoyoclockEbay 3 года назад +1

      There is, I have discovered a truly remarkable piece of code which this margin is too small to contain.

  • @jehugaleahsa
    @jehugaleahsa 14 лет назад

    raw_input and input grab strings, not floats, in modern Python versions. Python must have changed raw_input since then. Python now relies heavily on exception handling:
    try:
    x = float(raw_input('Enter a number:' ))
    floatFound = True
    except:
    pass

  • @TheDancelow
    @TheDancelow 10 лет назад +29

    it's bizarre that Americans call football soccer sir

    • @vicarious7358
      @vicarious7358 10 лет назад +5

      ***** America is the greatest country in world, all other countries are run by little girls.

    • @guhardos
      @guhardos 10 лет назад +1

      Tsvetan Dimoff From what I heard about that sport is that the ball is just one foot long. That's why football. However, balls for other sports are not one basket nor one volley long. Which is pazzling.

    • @danielcaligiuri5382
      @danielcaligiuri5382 9 лет назад

      +Serge Balaga I'm pretty sure he means that it's weird the French call soccer football because football is an English word. As opposed to something like piedballe.

    • @vaibhavsingh1049
      @vaibhavsingh1049 7 лет назад

      lol

    • @dschoene57
      @dschoene57 3 года назад

      Exactly, they call a sport football, that is not played with a ball, but an egg and not with the foot, but the hands. So it should be called hand-egg.

  • @gxg92
    @gxg92 13 лет назад

    John Guttag is a far better lecturer than Eric Grimson!!
    Eric Grimson is a far better lecturer than the rest!! :D

  • @Nisstyre56
    @Nisstyre56 13 лет назад

    @jehugaleahsa You should NEVER simply ignore errors using something like "except: pass". Also, wrapping code in try:, except: clauses needlessly slows down your programs.

  • @gids522
    @gids522 8 лет назад +6

    Is anyone else here learning in Python 3.x in order to be up to date and just translating the few differences over from 2.x?

  • @Maeda_Toshiie
    @Maeda_Toshiie 8 лет назад +1

    So we can think of the name of the list as a pointer (coming from a C background)

    • @inelpandzic
      @inelpandzic 8 лет назад +1

      Yes, list name is the reference variable type which is essentially a reference, address or a pointer to the object in memory.

  • @aydinjalilov2328
    @aydinjalilov2328 5 лет назад

    for some reason the type check did not work on my computer and I tried it with try/except/else method and it worked charms

  • @alonsosa8272
    @alonsosa8272 8 лет назад

    Ok. So when you declare L1 = [1,2,3], are you actually creating a list object or just a variable pointing to an already existing object?
    How about nmbr = 1? Are you creating an object with the value of 1 or is there a sort of universal 1 object to which you just point every time you want a variable to have that value?

    • @nicolasortiz2638
      @nicolasortiz2638 7 лет назад +2

      Alonso Serrano You're creating both, the list is the object, and the variable is the pointer. The value '1' is immutable, so when you define a = 2, you are not changing the value '1', you are just pointing it to a new value 'two'. Those 'objects' where the values are defined are spaces of memory which will be overwritten when no variable is pointing at them. It's a interesting topic, but Python is a high-level programming language, so I guess that you are not going to hear them talking about memory pointers. But, if you want to learn about them you could look for an explanation in the C programming language, it is a 'mid-level' lenguage and makes use of them.

    • @alonsosa8272
      @alonsosa8272 7 лет назад

      Nicolas Ortiz Very interesting! Thanks for the reply!

  • @으라챠챠-w1i
    @으라챠챠-w1i 6 лет назад

    thank you! ~ Good!!!~감사합니다. 건강하십시요.

  • @killtomorrow123
    @killtomorrow123 8 лет назад

    Why does the base, height and hyp are converted to str in printing? What difference does it make in just printing out the values?

    • @nicolasortiz2638
      @nicolasortiz2638 7 лет назад +2

      Mang Juan I guess that Python is a strong typed lenguage, so you can't concatenate two different types of values (integers and strings) and you must convert them to the same type of data. Also there are other 'weak type' lenguages that allows you to make operations in differents type of data like JavaScript

  • @JeffreyConcerto
    @JeffreyConcerto Год назад

    12:55 Anybody else laugh here? Can’t believe none of the students reacted 😂

  • @gpjapan
    @gpjapan 7 лет назад

    Thank you for the lecture.

  • @sunner008
    @sunner008 7 лет назад +1

    inputOK = False
    while not inputOK:
    base = input('Enter base:')
    if type(base) == type(1.0): inputOK = True
    else: print('Enter, Base must be a floating point number.')
    I can't get a correct answer as above code. I always get Enter, Base must be a floating point number. whatever I input. Who knows the problem?

    • @sunner008
      @sunner008 7 лет назад +1

      it return str in python 3x, so you need to convert str to float as follows code.
      Float(input('Enter base:'))

    • @maheryagub
      @maheryagub 7 лет назад

      base = input('Enter base: ')
      print(type(base))
      Run this and you will understand.

  • @smileychess
    @smileychess 14 лет назад +2

    lol "showDicts" sounded funny when he said it.

  • @junior1984able
    @junior1984able 13 лет назад

    @Mrxb0x soccer is called futbol, not soccer, and its the game that most of the world's population watches

  • @bassbrothaUG
    @bassbrothaUG 8 лет назад +4

    19:20 Omg I loled so hard!

  • @kdiggity1
    @kdiggity1 5 лет назад

    Does anyone know if we can get the actual handout?

    • @mitocw
      @mitocw  5 лет назад

      Course materials are available on MIT OpenCourseWare at: ocw.mit.edu/6-00F08. The handouts are under the 'Related Resources' tab for each video. Best wishes on your studies!

  • @acko741
    @acko741 13 лет назад

    @warzix no, only ppl from US, all the rest of america call their own language.

  • @سندسفرجالصغير
    @سندسفرجالصغير 4 года назад

    Thanks mit

  • @tarkandikmen8777
    @tarkandikmen8777 13 лет назад

    @omkarv Are you sure you didn't mixed them ? Eric Grimson is the funny one.

  • @shizzlefoo7
    @shizzlefoo7 14 лет назад +1

    Warzix it's not that crazy that we call it soccer after the British came up with name. And we already have another more popular sport in America by the name of football

  • @danime1941
    @danime1941 4 месяца назад

    2 gigs 🥲 my laptop now have 16 gigs

  • @Nisstyre56
    @Nisstyre56 13 лет назад

    @jehugaleahsa Yes premature optimization is bad. However imo, you can intelligently handle different inputs without resorting to exception handling in most cases where you know the source of input. e.g. pure vs. impure functions, if a function's output depends totally on the inputs, and not some random source of data, then I say let the interpreter output an error instead of letting it silently pass.

  • @he6453
    @he6453 5 лет назад

    How did we end up here...0@

  • @iateyourgranny
    @iateyourgranny 13 лет назад

    @Mrxb0x you call handegg football and football soccer

  • @bnsonline5099
    @bnsonline5099 3 года назад

    #Code Python 3.8.5
    import math
    #Get Base
    inputOK = False
    while not inputOK:
    base = float(input("Enter base: "))
    if type(base) == type(1.0): inputOK = True
    else: print("Error. Base must be a floating point number.")
    #Get Height
    inputOK = False
    while not inputOK:
    height = float(input("Enter height: "))
    if type(height) == type(1.0): inputOK = True
    else: print("Error. Height must be floating point number.")
    hyp = math.sqrt(base*base + height * height)
    print("Base: " + str(base) + ", height: " + str(height) + ", hyp: " + str(hyp))

  • @alejandrogracia1560
    @alejandrogracia1560 5 лет назад

    wow, is football a french word?

  • @kazifaiad6537
    @kazifaiad6537 4 года назад

    "looks like tag team wrestling" --lol

  • @eduardos.delarosa1654
    @eduardos.delarosa1654 2 месяца назад

    13:35 sure like the rest of the world except for your weirdos, just joking, I love you guys. Is very funny to realize than we call your "football" as "American football"

  • @bnsonline5099
    @bnsonline5099 3 года назад

    #Code Python 3.8.5
    import math
    def getFloat(requestMsg, errorMsg):
    inputOK = False
    while not inputOK:
    val = float(input(requestMsg))
    if type(val) == type(1.0): inputOK = True
    else: print(errorMsg)
    return val
    base = getFloat("Enter base: ", "Error: base must be a float")
    height = getFloat("Enter height: ", "Error: base must be a float")
    hyp = math.sqrt(base*base + height * height)
    print("Base: " + str(base) + ", height: " + str(height) + ", hyp: " + str(hyp))

  • @ILOVEANIMEHOPECARD
    @ILOVEANIMEHOPECARD 13 лет назад

    @jillybooty so that if one makes a mistake, the other corrects

  • @johnjackson5576
    @johnjackson5576 11 лет назад

    You realize that its just over a half of one hundred thousand right?

  • @TheReolus
    @TheReolus 13 лет назад

    @TheMartingull That's pretty stupid imo, America is a continent. Someone from Canada or Mexico is American too, as you already now. I understand what you mean but if I were American (from Mexico, for example) I wouldn't like you to say that at all. The U.S doesn't own all the American continent.

  • @nastrimarcello
    @nastrimarcello 3 года назад

    It's kinda bizzare, but the north Americans call football soccer.
    There. Fixed it for you

  • @kernel2006
    @kernel2006 14 лет назад

    @carlosdude1991
    He was making those jokes before you or I were born.

  • @Chiavaccio
    @Chiavaccio 2 года назад

    👏👏👏👍

  • @ntwiles
    @ntwiles 14 лет назад

    I laugh at both showDicts and sqrt.

  • @acko741
    @acko741 13 лет назад

    @TheMartingull from brazil :D

  • @shohamsen8986
    @shohamsen8986 5 лет назад +1

    The rest of the world calls Soccer football.

    • @code_explorations
      @code_explorations 5 лет назад

      False.

    • @shohamsen8986
      @shohamsen8986 5 лет назад

      @@code_explorations, would you settle for " a majority of the countries in the world calls soccer football"? Also, could you give some example of countries which call it soccer apart from America??

    • @code_explorations
      @code_explorations 5 лет назад

      Shoham Sen Sure. See here: www.businessinsider.com.au/football-vs-soccer-map-2013-12

  • @MrMurtaX
    @MrMurtaX 11 лет назад

    Is not my desire to be offensive, but it's even more bizarre the fact they call football a sport that people play using their hands, except during few moments, when the ball which is not really a ball must be kicked.

  • @skinke280
    @skinke280 13 лет назад

    lol it's not odd its called football.... it is football. American football should be named American rugby. Or just eggball. Handball is in use.... sorry.

  • @warzix
    @warzix 14 лет назад

    it is kinda bizarre, but americans call football: "soccer".

  • @felixcantournet
    @felixcantournet 13 лет назад

    @Mrxb0x
    No you call Football soccer and some weird game that is a poor copy of rugby and is mainly played with hands Football "for some reason".
    Calling American Football, football is about as stupid as calling basketball football.
    Also you are alone in this non-sense.

  • @MikeLane1976
    @MikeLane1976 5 лет назад

    Egads this is some fugly Python code.

  • @yurij_zp
    @yurij_zp 12 лет назад

    I'm I the only one who sees that these guys are quite unfamiliar with the programming language they are trying to teach others?..