13
What does a percent sign mean in python
** What does the percent (%) sign do in Python **
What is %?
Today we are talking about a very important programming topic which is%. We use it in all programming languages. Most programs do not run without it. Because if we put any condition in the program then the sign of% is anything. Helps to print%% play a very important role with most if else. When I went to learn programming at my institute I used it in c ++ to introduce a data type. As% d represents the integer% f, it is used to introduce float data type and represents the string% s. Also, if we want to extract the percentage of any number, we use% in which we do multiplication. Most students are worried about how to get percentage. today i will show you a very simple method which i am using very easy. for example i have to get 4% of 20 then i get 0 If I subtract ×, the answer is 4 × 2 = 8.
(%) symbol
you may think "percent" The (% )symbol in Python is called the Modulo Operator. It returns the remainder of dividing the left hand operand by right hand operand. It's used to get the remainder of a division problem.
The modulo operator is considered an arithmetic operation, along with +, -, /, , *, //.
3 % 1 will be zero (as 3 divides evenly by 1)
3 % 2 will be 1 (as dividing 3 by 2 results in a remainder of 1).
Example :
for number in range(1, 10):
if(number % 2 != 0):
print(no)
OUTPUT
1
3
5
7
9
13