How does work in Python

0 votes
What does the % in a calculation? I can't seem to work out what it does.

Does it work out a percent of the calculation for example: 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 is apparently equal to 7. How?
Oct 10, 2018 in Python by ana1504.k
• 7,910 points
871 views

1 answer to this question.

0 votes
The % (modulo) operator yields the remainder from the division of the first argument by the second. The numeric arguments are first converted to a common type. A zero right argument raises the ZeroDivisionError exception. The arguments may be floating point numbers, e.g., 3.14%0.7 equals 0.34 (since 3.14 equals 4*0.7 + 0.34.) The modulo operator always yields a result with the same sign as its second operand (or zero); the absolute value of the result is strictly smaller than the absolute value of the second operand [2].
answered Oct 10, 2018 by SDeb
• 13,300 points

Related Questions In Python

0 votes
1 answer

How does insertion work in Python?

Or, this one: def ins_sort(k): ...READ MORE

answered Oct 8, 2018 in Python by charlie_brown
• 7,720 points
839 views
0 votes
1 answer

How does slice notation in Python work?

The Python tutorial talks about it (scroll down a ...READ MORE

answered Oct 31, 2018 in Python by Priyaj
• 58,020 points
771 views
0 votes
0 answers

How does function definition work in python?

Is it same as other programming languages ...READ MORE

Jun 13, 2019 in Python by Waseem
• 4,540 points
499 views
0 votes
0 answers

How does pillow work in opening and closing images in python?

Is there a separate library that we ...READ MORE

Jul 16, 2019 in Python by Waseem
• 4,540 points
660 views
0 votes
1 answer

difference between "*" and "**"

The "**" operator is used for 'power ...READ MORE

answered Nov 19, 2018 in Python by SDeb
• 13,300 points
3,781 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,466 views
0 votes
1 answer

How do sets work in Python?

Define the __hash__ method to return a ...READ MORE

answered Apr 12, 2019 in Python by SDeb
• 13,300 points
905 views
0 votes
1 answer

How to Reverse a list in Python

You can use the reversed function in ...READ MORE

answered Sep 29, 2018 in Python by SDeb
• 13,300 points
863 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP