Q:

* in python

>>> numbers = [2, 1, 3, 4, 7]
>>> more_numbers = [*numbers, 11, 18]
>>> print(*more_numbers, sep=', ')
2, 1, 3, 4, 7, 11, 18
0
>>> fruits = ['lemon', 'pear', 'watermelon', 'tomato']
>>> print(fruits[0], fruits[1], fruits[2], fruits[3])
lemon pear watermelon tomato
>>> print(*fruits)
lemon pear watermelon tomato
1
#** is the exponent symbol in Python, so:
print(2 ** 3)
#output: 8
4
# Syntax for Boolean expression with or in Python
exp1 or exp2
6
quotient = 3 * 4
print(quotient)  #Answer=12
1
% : Modulus - remainder of the division of left operand by the right
  	x % y (remainder of x/y)
2
//	'a' // 'b'	(Floor Division) Quotient when 'a' is divided by 'b', rounded to the next smallest whole number
5
#Performs floor-division on the values on either side. Then assigns it to the expression on the left.
>>> a=6
>>> a//=3
>>> print(a)
2
0
# ** means modulus. or exponent
x = 6
y = 2
print(x**y) # will print 6 raised to power 2
0
select * from pg_stat_activity
0
When it iterating over a dictionary you are only able to iterate over 
the keys not the values. The ** when placed before a variable will allow
you to iterate and unpack both key and value pairs. Because you are 
unpacking both key and value this will return the result as a dictionary.
0

New to Communities?

Join the community