I really didn't get lecture 2 or specifically, later part of lecture 2. Can anyone clear this out?
I also . but now I may be clear about some of it ? which part you don't understand ? indentation, Boolean or loop ?
boolean, the loop and the format of the sample programs from the lecture.
what has you puzzled about the boolean stuff? what has you puzzled about the formats? have you done the readings??
You should do further reading on programming basics and on the python language on the python.org website The boolean data type is just a classification of the True and False values. Loops are basically blocks of code which may be written once in the program but are executed multiple times through control flow statements such as LBL and GOTO commands, conditional WHILE statements, iterative FOR statements, function calls/ recursion, and other similar control flow instructions or hacks. The text editor you see in the lecture is just the standard Python text editor/shell (dynamic, interactive command line interface to test programs). The writing is in the Python programming language, so once you study the primitive data types and control flow statements of the Python language on the python website or on youtube or in a book, it will be very understandable especially if you follow Dr. Grimson.
OK. The boolean I get and the idle is very clear to me. However, the loops are little bit confusing. I've done the programming and the only part I don't get is the loop.
The loops you will often be working with are the while and the for loops. while loops look like this, where condition evaluates to True: while condition: do_something() do_this() do_that() the while loop executes the instructions inside it, and when it reaches the end of the block (after it executes the do_that() instruction) it tests the condition again. If the condition still evaluates to True it executes the block again (starting from the top, which is 'do something' in my example). The while loop is used to repeat a sequence of instructions until a certain condition is satisfied. for loops look like this: for item in List: do_something() do_this() do_that List can be a sequence of items like a list, tuple, string, etc. item is an individual item in the List, and the for statement begins by taking the first item in the List. The program proceeds through the for loop block until the end, just like in the while loop, but instead of testing for anything once it executes the last statement the for loop assigns the next thing in the List to item and repeats the whole thing. It does this over and over, until the for loop iterates over the last element in the List. The for loop is used to repeat a sequence of instructions for a determined amount of time (the programmer wants to control the loop according to a count). For example: for number in xrange(10): print number, would print out 0 1 2 3 4 5 6 7 8 9 and then the loop ends since 9 is the last item in the sequence 'xrange(10)'
Thank You So Much. Now I can get the problem #1 solved by using the loops.
Lecture 3 may help you, too. He shows you several ways to think about loops (flow chart, simulating the code) which will probably clear it up quickly.
Join our real-time social learning platform and learn together with your friends!