The Python Champions of Coding: A Complete Book for Beginners and Kids by Arya Paarth

The Python Champions of Coding: A Complete Book for Beginners and Kids by Arya Paarth

Author:Arya, Paarth [Arya, Paarth]
Language: eng
Format: epub
Publisher: Wisdom Tree
Published: 2021-08-28T00:00:00+00:00


This is an infinite loop, which asks the user for a number and prints that number to the console. It repeats this process again and again and again (infinitely!). You will tire, Python will not!

But, for practical purposes, we can have a program which exits an infinite loop. Which statement would we use to exit the loop? Yes, the break statement.

Here, we have an infinite loop, which would only end when the user enters "no" when asked if they want to continue. If not, it will keep asking for a number, printing it, and asking if the user wants to continue, again and again and again.

Let’s Practice

Let’s start with a very basic activity to get you started. Print every even number from 4 to 24 in a single line, each separated by a space. Make sure to check your increment value in each iteration. The output should be:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.