Skip to main content

About loop statements

Well this is a very basic thing.

This is about loop statements on a few programming language.

First one is the language Java.

That can't be easier than that.

Second, C++.

Absolutely not a copy of Java one

Looks extremely same.

On the next, python

This is a lot different from other languages.

Its mostly because of python's special language syntax, not much different from the logic.

And more about python's loop, at the first line, it says for i in range(0, 6): .
It seems logically, it should be in range(0, 5) to make it repeat to 5.
But in python, range(x, y) counts from x to y + 1, so keep this in mind.

And python, doesn't have do {} while () statement.
So instead, from this stackoverflow answer, there is a somewhat similar code in python.

See the line 10, the while loop is infinite loop and it will run the code print k for the first time of the loop.
And then, it checks the statement if k>= 5: and determines whether break the loop or repeat.
So it just works like the do-while loop in python.

seriously python what is wrong with you

Popular posts from this blog

Presentation about Big Data

Presentation about Technology of Search Engine

The slides won't be able to read easily because of the animation objects.

Book Report about Justice (by Michael J. Sandel)

Name: Justice: What's The Right Thing To Do? Author: Michael J. Sandel "Endless thoughts, endless choices. About Justice." Based on the Harvard college's lecture by Sandel, which is well known lecture for all students in the college. So, what is this book about? Its written on the book cover. Its about the justice. Then what is justice? And that is what this book is talking about. Different from other books talking about justice, this talks much understandable and interesting than other. Starting from the well known moral story "Workers on the railway", this book explains how justice is implemented in our society. I read nearly a few books in a year, this was the most interesting book I have read this year. This book let me know the happiness of reading something with deep thinking. The most unanswerable topic was related to the human being, it was "How much does a human cost?". I think this topic, the value of a human, shouldn't be calcu...