Category: Python

Python Numbers

Numbers The interpreter of Python acts like a simple calculator. You can make operation like add, subtract(minus), multiply, divide. Examples Add >>> 3 + 5 8 >>> 125.5 + 2.5 128.0 >>> 134.7 + 3 137.7 Multiply >>> 3 * 5...

Python Strings

Strings Strings can be enclosed in single quotes (‘..’) or double quotes (“..”). The print() function is used to show the output of strings. Examples Single quotes >>> 'Single quotes test' 'Single quotes test' Double quotes >>> "Double quotes test" 'Double...

Python Lists

Lists The Python list, is a sequence of values, separated by commas between square brackets. Lists can have values of different data types. Example Extract all values from a list with python >>> my_list = [1, 5, 7, 21, 33] >>>...

Python IF

IF statement IF statement – with the IF statement you can use optional parts like elif or else. The keyword elif is short for else if keyword. Examples >>> c = 10 >>> if c < 0: print('Negative value') elif c...

Python FOR

FOR statement The FOR statement iterates over the items of a list or a string, in the order that they appear in the list or string. Examples >>> my_list = ['Learn', 'python', 'language'] >>> for n in my_list: print(n) Learn python...