please explain this to me 😭(θ‿θ) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

please explain this to me 😭(θ‿θ)

uses of this signs and their meanings ** // %

24th Mar 2023, 12:34 PM
SÃM
SÃM - avatar
3 Answers
+ 6
3**2 = 3*3 = 9 (exponentiation) 5//2 = 5/2 = 2.5 = 2 (integer division) 5%2 = 5 - 2*2 = 1 (modulo division)
24th Mar 2023, 1:04 PM
Solo
Solo - avatar
+ 1
x ** y, raises x to the exponent, y. x // y, performs floor division. x % y, returns the remainder of dividing x by y.
24th Mar 2023, 7:54 PM
William Mabotja
William Mabotja - avatar
+ 1
** is exponential operator example 2 ** 2 = 4 this is easy to remember. 2 ** (how many times you want to multiply 2 by itself) // is floor/integer division operator the result of division in Python is float by default. if you use division 5 / 2 the result is 2.5. but using //, the result is 2. it always drops the numbers after decimal point. % is the remainder/modulo operator. it returns the remainder result. if you divide 5 by 2, theres remainder 1. to get the remainder, we use %. 5 % 2 = 1
25th Mar 2023, 12:44 AM
Hyperjones
Hyperjones - avatar