; in python code example

Example 1: :: in python

#[start:end:step]
>>> range(10)[::2]
[0, 2, 4, 6, 8]

Example 2: ** in python

#** is the exponent symbol in Python, so:
print(2 ** 3)
#output: 8

Example 3: or in python

# Syntax for Boolean expression with or in Python
exp1 or exp2

Example 4: * in python

>>> fruits = ['lemon', 'pear', 'watermelon', 'tomato']
>>> print(fruits[0], fruits[1], fruits[2], fruits[3])
lemon pear watermelon tomato
>>> print(*fruits)
lemon pear watermelon tomato

Example 5: logical operator in python

# logical and operator
# return first operands if false otherwise second operands

0 and 3
# output = 0
3 and 0 
# output = 0
3 and 5 
# output = 5

Tags:

Cpp Example