Python
/
Language
- 1 Language 9
-
Hello World
-
Variables
-
Functions
-
Conditional
-
Operators
-
While
-
Turtle
-
Script Mode
-
Debugging
- 2 Strings 6
-
Slice
-
Raw Strings
-
Regex
-
Validation
-
Config
-
Escape
- 3 Collections 5
-
Lists
-
Dictionaries
-
Efficiency
-
Tuples
-
References
- 4 Functions 5
-
Recursion
-
Factorial
-
Modulus
-
Reassignment
-
Approximate
- 5 Storage 8
-
Files
-
Databases
-
Pipes
-
With open
-
Shelve
-
Zip
-
Csv
-
Json
- 6 Class 4
-
Definition
-
Attributes
-
Functional
-
Methods
- 7 Goodies 5
-
Conditional Expression
-
List Comprehension
-
Generator
-
Named Tuple
-
Modules
- 8 Applications 5
-
Pythagora
-
Palindrome
-
Binary Search
-
Conway Game
-
Coin Flip
- 9 Scheduler 4
-
Time
-
Multithreading
-
Subprocess
-
Logging
- 10 Packages 2
-
Clipboard
-
Ocr
/
While
➟
➟
Last update: 15-11-2021
While
p 123 You can almost read while statement as if it were English.
# While syntax:
#
# You can almost read while statement as if it were English:
# - while n is greater than 0
# - display n
# - then decrement it
#
# The syntax is similar to a function definition.
def countdown(n):
while(n > 0):
print(n)
n = n -1
countdown(5) # 5 4 3 2 1
Input
p 123 Sometimes you want to take input from user until they type quit.
while True:
line = input('> ')
if (line == 'quit'):
break
print(line)
print('Done')
➥ Questions