Тёмный

3. String Manipulation, Guess and Check, Approximations, Bisection 

MIT OpenCourseWare
Подписаться 5 млн
Просмотров 370 тыс.
50% 1

MIT 6.0001 Introduction to Computer Science and Programming in Python, Fall 2016
View the complete course: ocw.mit.edu/6-0001F16
Instructor: Dr. Ana Bell
In this lecture, Dr. Bell discusses string manipulation, guess-and-check algorithms, approximate solution methods, and bisection search.
License: Creative Commons BY-NC-SA
More information at ocw.mit.edu/terms
More courses at ocw.mit.edu

Опубликовано:

 

19 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 290   
@vibhumaheshwari2826
@vibhumaheshwari2826 3 года назад
Dr. Bell really does deserve an applause. Nice to see that the students actually did that in the end of the lecture. An amazing lecture with such articulate explanation of concepts. Thank to MIT OCW and also to the course staff!
@Mahdi62822
@Mahdi62822 9 месяцев назад
👍👍👍
@user-fl7vs4ed6l
@user-fl7vs4ed6l 3 года назад
0:01:54​ Strings 0:03:32 Strings indexing 0:05:34 (Coding) 0:06:49 Strings slicing 0:08:37 Strings slicing example 0:10:05 Strings slice inversly 0:11:18 ​Strings was fixed in memory 0:13:20​ For loops recap 0:16:31 Coding example : robot cheer leaders 0:18:00 Coding example : robot cheer leaders(Coding) 0:20:36 Coding example : robot cheer leaders 0:22:00 Coding example : robot cheer leaders 0:23:37 ​Guess and check cube root1.0 0:26:00 Guess and check cube root2.0 0:28:30​ Linear Search for cube root approximation 0:31:22 Linear Search for cube root approximation examples 0:32:53 Linear Search for cube root approximation of 10000 0:34:33 ​Linear Search preventing going to far 0:36:48 Bisection Search ​ 0:38:00​ Bisection Search @3rd iteration 0:39:52 Bisection Search summary 0:42:47 O(n) (Complexity)
@user-nm9fk7cb4b
@user-nm9fk7cb4b 3 года назад
The true hero here
@calmdown1665
@calmdown1665 2 года назад
Thanks a lot, it is handy.
@maar2001
@maar2001 Год назад
I rlly appreciate Gigachads like you who make our life easy
@michaeladdisu8043
@michaeladdisu8043 Год назад
tnx
@farmcat3198
@farmcat3198 Год назад
I love Dr. Bell's enthusiasm for this. Makes learning it so much more fun!
@johnrubio5660
@johnrubio5660 5 лет назад
Cannot exaggerate how helpful this content is. Thank you MIT OCW. I know hindsight is 20/20, but I wish I would’ve watched these videos (and the Walter Lewis videos) when I was in high school. I would’ve been so much more motivated to work hard and try to get into MIT.
@johnrubio5660
@johnrubio5660 5 лет назад
Edit: Walter Lewin
@stevemilo6935
@stevemilo6935 2 месяца назад
You live a sad life of regret.
@user-nm9fk7cb4b
@user-nm9fk7cb4b 3 года назад
This series of lectures and this lecturer are both so insightful that I often have to take long breaks between views because of the amount of complex and hidden/misunderstood information they make so accessible can make life overwhelmingly easy to understand Thank you Dr. Ana Bell, MIT and everyone involved with all of this! You are all amazing! (no angry text here :)
@rustycanofbeans1009
@rustycanofbeans1009 2 года назад
Im watching these lectures and practicing the course works from the website (the assignments and problem sets, also playing around with each thing I've learned). I've learned more in 3 days watching these than I have with a month of watching how-to tutorials (which is not surprising at all, just what I was trying before) and I am so glad I found this. I've made a very simple calculator that can add 2 numbers together that the user inputs! Very simple, but it's a victory to me! I'm starting college soon and majoring in computer science, so I can't wait to look back and see how far I've come. Really thanks to these kind people and this great teacher, I am understanding concepts that were constantly foreign to me no matter how much I tried to understand on my own. Although I haven't attended a class, I'll remember Dr. Bell as one of my favorite teachers because I have learned so much.
@12mohdyasirfaridi75
@12mohdyasirfaridi75 6 лет назад
It was very useful. HUGE THANKS TO MIT.
@sp4557
@sp4557 3 года назад
cube = float(input("Enter a no whose cube root is to be calculated: ")) epsilon = 0.01 num_guesses = 0 if cube > 1: low = 0 high = cube guess = (low + high)/2.0 while abs(guess**3 - cube) >= epsilon: if guess**3 < cube: low = guess else: high = guess guess = (low + high)/2.0 num_guesses += 1 elif 0 < cube < 1: low = cube high = 1 guess = (low + high)/2.0 while abs(guess**3 - cube) >= epsilon: if guess**3 < cube: low = guess else: high = guess guess = (low + high)/2.0 num_guesses += 1 elif -1 < cube < 0: low = cube high = 1 guess = (abs(low) + high)/2.0 while abs(guess**3 - abs(cube)) >= epsilon: if guess**3 < abs(cube): low = guess else: high = guess guess = (low + high)/2.0 num_guesses += 1 else: low = cube high = 0 guess = (abs(low) + high)/2.0 while abs(guess**3 - abs(cube)) >= epsilon: if guess**3 < abs(cube): low = guess else: high = guess guess = (low + high)/2.0 num_guesses += 1 print('num_guesses = ', num_guesses) if cube < 0 : guess = -guess print(guess, "is close to the cube root of", cube) I guess this covers all possible cases?
@canpeanionut
@canpeanionut Год назад
Thanks a bunch! I'm a MD trying to learn python. This helped a lot, couldn't really wrap my head around the class challenges.
@jasmeetxxx9
@jasmeetxxx9 Год назад
appreciated.
@Haganenno121
@Haganenno121 4 месяца назад
I suppose it should be >=1, otherwise else: applies
@protoype123
@protoype123 Год назад
Thank you for these videos MIT and Professor Bell, I've learned so much from watching these videos and this has accelerated the career change I'm beginning now at 27. Much love, -Sam :)
@Helpmesubswithoutanyvideos
@Helpmesubswithoutanyvideos Год назад
I'm 27 years old and me to
@spyinsecret0075
@spyinsecret0075 3 года назад
She is an amazing teacher! Explain it so clearly and fun. Thank you so much!
@onemilee
@onemilee 3 года назад
Hi guys. I'm going to thank the MIT team. Thank you, for these awsome courses.
@bighomietone195
@bighomietone195 6 лет назад
Ana Bell you’re the best 🙏🏽
@user-ll7wq2ow8w
@user-ll7wq2ow8w 3 года назад
first sorry about my miserable English. All I want to say is thank you very very much You gave me a new start and a new goal in my life with python.
@roshanshanbhag3489
@roshanshanbhag3489 2 года назад
In Metrology, the Approximate solution or Guess and check is analogous to Linear search and the bi-sectIon search that Dr. Bell used is called Binary search. We use it comprehensively to find the levels and timing parameters of an integrated circuit.
@bkpickell
@bkpickell 3 года назад
Thank you for these courses. I took programming 17 years ago and wanted to brush up and learn Python. Since that seems to be the go to language now. I learned on VB. I've written a couple programs in VB for my current employer to connect to, manipulate, and retrieve data from a database. Mainly to make my job easier. LOL... I thought I would try and learn to do it in a more current language. Granted I have to get through this 6.0001 course first so I can get to 6.0002 where I need to be for database programming. I'm just hoping to learn something I didn't know. So far it's just refresher, which is fine. I already know pretty much everything being discussed. It's just slightly different syntax such as the double =, that's not a thing in VB. Or the single quote vs double quote. Yeah that's not a thing in VB either double quote only for strings.
@aumkaarpranav8765
@aumkaarpranav8765 2 года назад
Wow! They clapped at the end. Can't remember ever being so much into the class that I end up clapping.
@mathlearning5331
@mathlearning5331 4 года назад
This video literally answered all of my remaining questions
@nasserghajarafshar762
@nasserghajarafshar762 5 лет назад
prof. Anna Bel your lectures are very helpful thanks
@qcislander
@qcislander 5 лет назад
Love it. Dr. Bell, I hope you're still at this: you do it *really* well, and as I've watched from the first lecture, you're losing (or taming?) what seems to be a little stage-fright. I've never lost mine, but I did tame it enough to teach by interactive lectures way back when. Good onya. :-) One question: the "bisection" method seems just like (electronics engineering technology 35 years ago) what we called "successive approximation by halves"... and we did it with logic-gate constructs and not code... but is that the same idea?
@jasonbarr5176
@jasonbarr5176 5 лет назад
Yes, it's the same idea. In fact, I just Googled it out of curiosity (electronics are not my area, though I'd like to get more into it) and several articles on successive approximation by halves make reference to binary search (another name for bisection search) explicitly.
@markmahathey690
@markmahathey690 4 года назад
this was a good lecture. I hope I watch them all.
@kuuz1134
@kuuz1134 4 года назад
college drop out learning python for free from MIT, who would have ever thought...
@LubulaAfritech
@LubulaAfritech 4 года назад
kuuz am here in disbelief too
@PotatoSauc3
@PotatoSauc3 3 года назад
Here!
@demolazer
@demolazer 3 года назад
Same here. I dropped out years into a CS degree ten years ago. Am learning it all from MIT now. Better lecturers than I ever had.
@superfreiheit1
@superfreiheit1 3 года назад
There also good python courses outside
@655tern
@655tern 2 года назад
Same here
@leonardoagostini6743
@leonardoagostini6743 5 лет назад
Code at 35:33 does not work for negative cubes. Here some changes in order to let it work also for negative numbers. Hope it will be useful :). ___________________________________________________________________________________ cube = 27 epsilon = 0.01 guess = 0.0 increment = 0.0001 num_guesses = 0 while abs(guess**3 - cube) >= epsilon and abs(guess**3) = epsilon: print('Failed on cube root of', cube) else: print(guess, 'is close to the cube root of', cube)
@george6709
@george6709 2 года назад
#this works too 👍🏾 cube = float(input(" enter your preferred number: ")) guess = 0.0 epsilon = 0.1 increment = 0.01 if cube >= 1: while abs(guess**3 - cube) >= epsilon: guess += increment print(guess, "is close to the cube root of", cube) else: while abs(guess**3 + cube) >= epsilon: guess += increment print(-guess, "is close to the cube root of", cube)
@Underdoge_
@Underdoge_ Год назад
nice!
@harmainarif4302
@harmainarif4302 5 лет назад
thnks alot prof Ana Bell ,,its very helpful for me
@jalapenohiway
@jalapenohiway 4 года назад
I really love this course and had to donate! Between MIT OCW & Free Code Camp, I'm definitely learning a lot of valuable information! Thank you! You guys are absolutely amazing!
@Billyxiao
@Billyxiao 2 года назад
Yes definitely this is more informative
@PedramNG
@PedramNG 3 года назад
The final algorithm that she explained is actually called Successive Approximation which there is also circuits for that which is called Successive Approximation Register (SAR) Analog to Digital Converter (ADC). Looking at these algorithms being in both computer science and electronic engineering is so cool.
@bobanmilisavljevic7857
@bobanmilisavljevic7857 6 месяцев назад
You get a little extra bang for your buck at MIT 💪🥳
@itsjose666
@itsjose666 3 года назад
Amazing content. Thank you MIT.❤
@gxa5986
@gxa5986 3 года назад
Thanks for sharing knowledge in free Actually Approximations were a headache for me which u guys solved.
@alienlan
@alienlan 4 года назад
I absolutely love these courses! Learning so much! Both lecturers I've seen are outstanding, and much appreciation to everyone involved in this amazing gift to mankind! I do have one, small suggestion, though. It would be great to leave the camera on the slides for longer periods of time. In a classroom, as I'm taking notes, I am focused more on the slides and what the teacher is saying, than on how they look (even though these teachers are very pleasant to watch). Because there is so much video of the instructors, it leads to a lot of pausing on slides and interrupting their wonderful lectures. :(
@ghaithghazi6748
@ghaithghazi6748 4 года назад
Brother you can find the slide on the course website alongside with the code and most importantly there are some challenging assignments.....I highly recommend you to check those.
@felzebub1762
@felzebub1762 3 года назад
Excellent videos!! Thanks MIT
@TenMinuteKQL
@TenMinuteKQL 10 месяцев назад
Great session! Thank you for contributing to the coding community.
@brainstormingsharing1309
@brainstormingsharing1309 3 года назад
Absolutely well done and definitely keep it up!!! 👍👍👍👍👍
@daizhao4874
@daizhao4874 3 года назад
What a helpful and interesting class!
@akbarrauf2741
@akbarrauf2741 7 лет назад
thank you ,mit
@88bjjmichael
@88bjjmichael 7 лет назад
akbar rauf and Dr Ana Bell
@pranaymishra9696
@pranaymishra9696 3 года назад
@@88bjjmichael f
@mikhailskalyga9386
@mikhailskalyga9386 4 года назад
Great lecture, thank you!
@thomasgarman6353
@thomasgarman6353 3 года назад
picking up python, I know absolutely nothing but I am 3 lectures in. Anybody else actually following along with the whole series and doing the problems the course gives ?
@goswamivibhor
@goswamivibhor 2 года назад
You may check on internet by searching the topics names and basic problems regarding them
@jamaldangelo4227
@jamaldangelo4227 Год назад
Im the same, how did it go pal?
@thomasgarman6353
@thomasgarman6353 Год назад
@@jamaldangelo4227 oh wow it’s been a year, it went so well lol, I am much more confident in my programming abilities and have done a lot of really cool projects. Coding has been a very rewarding journey
@jamaldangelo4227
@jamaldangelo4227 Год назад
@@thomasgarman6353 Good to hear pal, I'm currently just starting now, trying to find a coding job in the next 6-9 months...
@yukeyang5735
@yukeyang5735 5 лет назад
bisection,very insightful
@aymensekhri2133
@aymensekhri2133 4 года назад
thanks a lot Dr. Ana Bell
@semtex6412
@semtex6412 3 года назад
lol. thank MIT. she's being paid to teach whilst being filmed. nothing glorious there. if anything, she stutters so much it feels like her mind keeps wandering off somewhere. Prof. Eric Grimson was way better!
@Unknowledgeable1
@Unknowledgeable1 2 года назад
13:00 On for loops #pre 14:20 #14:39 It seems that you don't need to use the word range() when u are binding characters to the iteration variable 16:27 more complicated example of assigning characters to iteration variable #pre 19:32 explanation of 'in' keyword 19:50 20:14
@TrangNguyen-cs6wv
@TrangNguyen-cs6wv 6 лет назад
21:58 Start of Basic Algorithms
@uetianeinsteins204
@uetianeinsteins204 4 года назад
nice work by DR. ANNA BELL and MIT as well..
@matthiastakele
@matthiastakele 4 года назад
43:51 She meant to say it only works for cubes greater than or equal to 1
@jh0720
@jh0720 5 лет назад
13:21 loop variable that iterates over a collection, not a set?
@kumarjalaj1222
@kumarjalaj1222 6 лет назад
nice lecture
@Mokhtartba
@Mokhtartba 8 месяцев назад
Her Voice is Good and the Explaining is perfect ! thanks M-I-T the game of guess was Fun :D .
@jimkennedy4509
@jimkennedy4509 Год назад
Great. I was hoping she would use Newton-Raphson or secant method for the cube root calculation.
@FaizAther
@FaizAther 6 лет назад
# cube root calc cube = input("Please input a number: ") cube = int(cube) for guess in range(abs(cube) + 1): if guess**3 == abs(cube): if cube > 0: print("The cube root of", cube, "is", guess) break elif cube < 0: guess = -guess print("The cube root of", cube, "is", guess) break if guess**3 > abs(cube): print("Not a perfect cube")
@tsuba666
@tsuba666 Год назад
38:00 the fact Sophie chosed 76 makes me wonder if she had an inkling as to what the teacher was aiming at. I mean a middle guess +1 is the hardest to find in a bisectional search. So either Sophie was lucky, or she's a sly fox >:)
@Mahdi62822
@Mahdi62822 9 месяцев назад
lol right
@DatascienceConcepts
@DatascienceConcepts 4 года назад
Very useful
@pfever
@pfever 6 лет назад
Correct me if I'm wrong but in 43:50 when the professor says the code works only for positive cubes, she makes an example of 0.5 not working, but that is the positive cube of 0.79... So I guess the correct statement to make is that this algorithm works only for positive cubes "bigger or equal to 1".
@wenjucui9272
@wenjucui9272 5 лет назад
My understanding is that her code does not work for 2 situations: 1) negative cubes 2) x
@Adam-bq2us
@Adam-bq2us 5 лет назад
@@wenjucui9272 I know she said it is a simple if statement but I can't figure it out. What did you do to make it work? My thought is: if cube < 0: guess = -guess
@wenjucui9272
@wenjucui9272 5 лет назад
@@Adam-bq2us I considered two situations: if cube >=0: low=0 high=cube guess = (high + low)/2.0 then do the while loop comparing epsilon; else: low=cube high=0 guess = (high + low)/2.0 then do the while loop again to compare with epsilon. hope this helps. I haven't worked out the between 0, 1 situation.
@bkpickell
@bkpickell 3 года назад
@@Adam-bq2us Before running the code listed just state If cube is >= 1 then {insert code from course} that's all that is needed
@rohineeroy7860
@rohineeroy7860 2 года назад
@@bkpickell can you please give the full solution? I cannot find any
@niteshmodi5468
@niteshmodi5468 3 года назад
I am sending a packet of thanks to mit for this clear explanation And sorry I can't afford a Google product so only thank you
@davidanamunda6766
@davidanamunda6766 3 года назад
this is very helpful
@ashley_harwood
@ashley_harwood 6 лет назад
# This might be of help to someone as I had trouble following along due to this misconception # Assign the string "MIT" to variable "i" i = 'MIT' # Print the elements of variable "i" starting from index 0 and ending at index 3 but not including index 3 - "[0:3]" print(i[0:3]) # When working with an index remember that it starts at 0 "[0:]" # when specifying where you would like to end the index "[:3]" it's up to the index value 3 but not including it # So in this example - "M" is located at index 0 # "I" is located at index 1 # "T" is located at index 2 # >>> MIT # If we were to print the elements of variable "i" at index "[0:2]" it would be print(i[0:2]) # >>> MI # "M" is located at index 0 # "I" is located at index 1 # "T" is located at index 2 # Rember it's up to the index value 2 but not including it
@longvo1426
@longvo1426 4 года назад
You're a saviour.
@ir8487
@ir8487 2 года назад
Are there any recommended videos to watch on RU-vid following this course to build more upon Python knowledge? Thanks!
@gachle
@gachle Год назад
Dammnnn what an experience should be studying at MIT!!!
@diegogimbernat9253
@diegogimbernat9253 6 лет назад
I love her.
@Rolandas3K
@Rolandas3K Год назад
Nice tutorial and lesson. Just a small note, IMHO, on ~35:00 Anna made a small "mistake" when added "and guess
@darkpikachu_.
@darkpikachu_. 4 года назад
can''t believe sophie didn't pick 69
@bee_irl
@bee_irl 4 года назад
I can't believe Bell pronounces gif "jif"
@user-nm9fk7cb4b
@user-nm9fk7cb4b 3 года назад
Creep
@frantzwidnyjoseph3571
@frantzwidnyjoseph3571 3 года назад
The idea of creating something to cheer oneself up is just funny
@Underdoge_
@Underdoge_ Год назад
0:34:43 I would add 'and abs(guess**3)
@lukem8420
@lukem8420 Год назад
I’ve watched this twice, and it’s still hard as hell for me to grasp
@kshitijsingh5728
@kshitijsingh5728 3 года назад
Why aren't we getting cube root of 27 and 8120601 in form of x.xx as we always increment guess by second decimal place.
@bucksera475
@bucksera475 Год назад
God bless you.
@joesparlin4268
@joesparlin4268 5 лет назад
Thanks
@curiousss4960
@curiousss4960 5 лет назад
Who edited this? Every time she's pointing and talking about something on the board the camera is on her for some reason. Really bad practice.
@ashen1970
@ashen1970 5 лет назад
yup that is so dumb edition
@Caspian917
@Caspian917 6 месяцев назад
Here's what I have for bisection search that accounts for negative numbers and abs (numbers) < 1: cube = -0.027 epsilon = 0.0001 num_guesses = 0 if cube >= 1: low = 0 high = cube elif cube >= 0 and cube < 1: low = cube high = 1 elif cube < 0 and cube > -1: low = -1 high = cube else: low = cube high = 0 if abs(cube) == 1: guess = cube else: guess = (high + low) / 2.0 while abs(guess**3 - cube) >= epsilon: if guess**3 < cube: low = guess else: high = guess guess = (high + low) / 2.0 num_guesses += 1 print('num_guess is', num_guesses) print(guess, 'is close to cube root of', cube)
@nicktucker3437
@nicktucker3437 9 месяцев назад
37:00 that's exactly how one should play the clock game on the price is right.
@venom_21332
@venom_21332 3 года назад
thanks!
@oiciruamlau4795
@oiciruamlau4795 4 года назад
What I get from the approximation algorithm is that it will only give you an answer if the difference between guess**3 and cube is equal to epsilon, if it manages to jump above epsilon, guess will increase in value until it is
@Divyansh-Tiwari
@Divyansh-Tiwari 4 года назад
cube = 10000 epsilon = 0.1 guess = 0.0 increment = 0.01 num_guesses= 0 while abs(guess**3 -cube) >= epsilon: # and guess = epsilon and guess**3 > cube: # new inserted line print("sorry the the epsilon jumped up and the cube is not found the last guess was",c) # new inserted line break # new inserted line print('num_guesses=', num_guesses) if abs(guess**3 -cube) >= epsilon: print('Failed on cube root of', cube) else: print(guess, 'is close to the cube root of', cube)
@eduardorodriguez1897
@eduardorodriguez1897 3 года назад
What does she mean with we can use for loops to iterate ANY SEQUENCE OF VALUES?? Im learning coding from scratch and some terms and concepts are quite sneaky to comprenhend, dont be to harsh pleas, and thanks
@anubhabganguly7579
@anubhabganguly7579 3 года назад
Very helpful resources 💙
@khico5463
@khico5463 5 лет назад
my teacher is beautyfull
@muhammadzubair5310
@muhammadzubair5310 2 года назад
Thanks, now i can learn python in high school
@dsee777
@dsee777 7 месяцев назад
At 10:05, a typo in screen slides ...evaluates to "hgfedbca", should be "hgfedcba".
@theviper8652
@theviper8652 6 лет назад
when should we start doing those given assissgnment
@daveyjones9699
@daveyjones9699 4 года назад
Is there a typo at 6:56? s[: : -1] -> "hgfed'BC'a" doesn't make sense, unless it's supposed to be "...cba"
@mussabsaleem7625
@mussabsaleem7625 4 года назад
Yes it is cba or BCa
@aghaaslam9575
@aghaaslam9575 3 года назад
true, there is a mistake. this comment should have a lot of like !!!
@zvisnjicyt
@zvisnjicyt 2 года назад
MIT one and only!👍🇷🇸
@shubhankarsingh4065
@shubhankarsingh4065 3 года назад
18:00 nice example
@santanacasas1
@santanacasas1 6 лет назад
What is the answer of cube = 27 on the exercise. I rewrote the code on the IDE but the execution never ended, why? Help, please
@AnilKumar-un6jn
@AnilKumar-un6jn 6 лет назад
LOL Happens, Your increment is may be too small, so that it is maybe taking too much time.
@androtech7885
@androtech7885 4 года назад
Dude the same thing happened for me. I never got an answer even after changing the 27 to some other value.
@DSimonJones
@DSimonJones 3 года назад
Try.......If you copied and pasted from slides the last three lines may be indented. they should start at beginning of each line.
@utkarshmishra1302
@utkarshmishra1302 2 года назад
My teacher in INDIA taught me in same way, iam studing in class 11th feeling too good after watching this, that i have same access to learning as any other brilliant student have 💛💛😇😇🇮🇳🇺🇸
@iitasperiant6102
@iitasperiant6102 Год назад
Hello bro I am indian
@saucymiri
@saucymiri 4 месяца назад
Are these videos outdated or are they still a good place to start learning Python?
@abhilashc2965
@abhilashc2965 4 года назад
@21:20 Clean and peaceful
@joybreegaming8781
@joybreegaming8781 Год назад
38:50 why was my first thought before she even explained the method to choose e as my number
@doanduytrung651
@doanduytrung651 6 лет назад
Could you please tell me which programming environment python do you use in the lecture?
@ghostprime2993
@ghostprime2993 6 лет назад
they use anaconda but you can use geany also. I prefer geany
@rayyanhussain2356
@rayyanhussain2356 6 лет назад
It's called Spyder, it comes with anaconda. Link to website --> anaconda.org/anaconda/spyder
@debkumarbiswas9927
@debkumarbiswas9927 2 года назад
Guess & Check: cube = -27 # only guess the first natural number for which guess**3 >= cube for guess in range(abs(cube)+1): if guess**3 >= abs(cube): break # return perfect cube, if exists if guess**3 == abs(cube): if cube < 0: print("Cube root of " + str(cube) + " is " + str(-guess)) else: print("Cube root of " + str(cube) + " is " + str(guess)) # if there exists no perfect cube else: print(str(cube) + " is not a perfect cube")
@rakuou2578
@rakuou2578 7 месяцев назад
In the approximate way of finding cube root codes: the guesses is increasing by guess += increment. I may think the output of guess should be multiply of increment, why the final output is something like .999999999998
@cerberusrap
@cerberusrap 3 месяца назад
An "all possible inputs" approach for cheer loop (Eric taught me 😐): an_letters = "aefhilmnorsxAEFHILMNORSX" word = input("I will cheer for you!. Enter a word: ") times = int(input("Enthusiasm level (1 - 10): ")) if times > 10: while times > 10: times = int(input("Please ensure an enthusiasm level between 1-10 ")) for char in word: if char == ' ': continue if char in an_letters: print("Give me an " + char + "! " + char) else: print("Give me a " + char + "! " + char) print("What does that spell?") print((word + "!!! ")*times)
@carterash2588
@carterash2588 6 лет назад
when the robots are cheering, can you index word[1,3] in the for loop? for char in word[1,3]:
@Phagocytosis
@Phagocytosis 4 года назад
The index notation uses colons, not commas, so it would be word[1:3]. But other than that, yes, you could do that, and then you would loop over only the characters that are in that substring. So if the original string word is "ROBOTS", the substring word[1:3] would be "OB".
@TheTruthFadeswithTime28
@TheTruthFadeswithTime28 6 лет назад
How do you do a bisection search for a cuberoot when x is a decimal? I can’t be find an answer anywhere.
@rysknet
@rysknet 5 лет назад
if abs(cube) < 1.0: high = 1.0 This worked for me. Logic is that if 1 is less than 0 we just need to change the higher bound and a good number to change it to is 1 because the answer won't be greater than one anyway.
@temtamyassine2292
@temtamyassine2292 3 года назад
@@rysknet if cube < 1: high = 1 low = guess And even with that you may have an infinite loop because doing comparison for float numbers is tricky, see the style guide pdf
@gaiuszeno1331
@gaiuszeno1331 6 лет назад
The professor mentioned that a previously assigned string stays in memory after the variable is reassigned. Does this mean the programmer has to free memory allocates to the string manually?
@eymongaming7217
@eymongaming7217 5 лет назад
Not in Python, since there is the garbage collector.
@DB-sf1hy
@DB-sf1hy 4 года назад
Eymon Gaming which language does need to free memory manually?
@Mr123fairlane
@Mr123fairlane 4 года назад
I wonder what test are like in these programming courses at mit
@bkpickell
@bkpickell 3 года назад
Probably the same as any other school. The lectures are pretty much the same. I took programming 17 years ago, but that did not cover any Python. I wanted to learn Python so here I am. She's going over all of this stuff and it's almost exactly the same just slightly different syntax.
@-Mohamed_bayan
@-Mohamed_bayan 3 года назад
27:39 what if the cube is not perfect and negative? ,
@neelnagarajan514
@neelnagarajan514 4 года назад
when I try to run the code at 32:07, my cell just says In[*] instead if In[a number] and the cell doesn't even run. Anyone know what's going on? Note: the rest of my notebook until this point is running perfectly.
@simersingh9239
@simersingh9239 4 года назад
go to the kernel tab, click on interrupt. then try again
@kasiviswanathboddeti9085
@kasiviswanathboddeti9085 3 года назад
Cube root simple guess. Why does that code keeps running?
@leb-chip3268
@leb-chip3268 3 года назад
Can someone help me out - surely the code at 29:55 is wrong? The While loop should not run because the condition is not true i.e. guess**3 - cube is NOT greater than or equal to 0.1. Rather 0x0x0 - 27 is LESS than 0.1? So surely the While loop would not run in the first place?
@TTYounga
@TTYounga 3 года назад
The abs is a function that returns the absolute value of the argument, so in this case abs(-27) returns 27, which in turn is greater than (or equal) to 0.01 (epsilon)
@nutcracke16
@nutcracke16 3 года назад
Am I stupid? In Approximations code we set guess=0.0 and increment=0.01. How can our answer be different than increment times number of guesses??
@saurabhietlucknowstudent8072
@saurabhietlucknowstudent8072 3 года назад
and guess**3
3 года назад
39:37 bisection search code
@deekshitherukulla240
@deekshitherukulla240 8 месяцев назад
How to get the notes which mam is showing on board?
@mitocw
@mitocw 8 месяцев назад
The course materials are available on MIT OpenCourseWare at: ocw.mit.edu/6-0001F16. Best wishes on your studies!
@EgeOnatDoguslu
@EgeOnatDoguslu 6 лет назад
Assignment 2.3 Bisectional Search: salary = [] def optimal_savings_rate(): current_savings = 0.00 semi_annual_salary_raise = 7.00 down_payment = 250000.00 epsilon = 100 high = 1.00 low = 0.00 count = 0 portion_saved = (high + low) / 2 annual_salary = float(input("What is your annual salary?")) salary.append(annual_salary) """Lets's check for sufficiency of the person's annual salary.""" """Take portion saved as %100. Would it be enough to save for down payment?""" """With a for loop we save each semi years salary to salary list.""" """Then check if sum of them is enough to pay down payment.""" for i in range(6): annual_salary += (annual_salary * semi_annual_salary_raise * 0.01) salary.append(annual_salary) if (salary[1] + salary[2] + salary[3]+ salary[4] + salary[5] + salary[6]) / 2 < down_payment: print("Not enough income to have a saving equivalent to down payment in three years") return "Sorry." """After being sure about the sufficiency of the annual salary, we can begin to make a research bisectionally.""" while abs(current_savings - down_payment) > epsilon: current_savings = 0 annual_salary = salary[0] for i in range(0, 36): """Raise the salary each six month. Don't take first month.""" if i % 6 == 0 and i != 0: annual_salary += (annual_salary * semi_annual_salary_raise * 0.01) monthly_salary = annual_salary / 12 monthly_savings_income = current_savings * 0.04 / 12 monthly_savings = (monthly_salary * portion_saved) + monthly_savings_income current_savings += monthly_savings if current_savings < down_payment: low = portion_saved if current_savings > down_payment: high = portion_saved portion_saved = (high + low) / 2 count += 1 print("The proper saving portion would be really close to {}.Binary " "step count = {}".format(round(portion_saved,4), count)) optimal_savings_rate()
@webapplicationguide3798
@webapplicationguide3798 4 года назад
10:10, single line to reverse a string !! :)
@saumyasahu1426
@saumyasahu1426 3 года назад
could please tell why does the output not start with 'a' cause the default of start is 0
@jasmeetxxx9
@jasmeetxxx9 Год назад
when the step stated is -1, it cannot start with 0 because there is no letter present physically before position 0 i.e. letter 'a' in this case. alternatively u can read -1 as [len(string) -1] position. string would be s in this case.
Далее
String Manipulations
3:05
Просмотров 59 тыс.
2. Branching and Iteration
43:31
Просмотров 564 тыс.
ИСПОЛНЯЮ МЕЧТУ Анастасиз
34:51
Просмотров 929 тыс.
2023 MIT Integration Bee - Finals
28:09
Просмотров 1,9 млн
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
8. Object Oriented Programming
41:44
Просмотров 609 тыс.
All Rust string types explained
22:13
Просмотров 149 тыс.
Python Sudoku Solver - Computerphile
10:53
Просмотров 1,1 млн
4. Assembly Language & Computer Architecture
1:17:35
Просмотров 695 тыс.
7. Testing, Debugging, Exceptions, and Assertions
41:33
Rust and RAII Memory Management - Computerphile
24:22
Просмотров 216 тыс.
ИСПОЛНЯЮ МЕЧТУ Анастасиз
34:51
Просмотров 929 тыс.