& sign in Python


#1

https://www.codecademy.com/courses/python-beginner-BxUFN/2/3?curriculum_id=4f89dab3d788890003000096

I just have a question: What does the % sign return?

I vaguely remember the % sign returning the number of times that the second number goes into the first. (ex. 2 % 1 = 2 or 100 % 100 = 1)

Apparently bool_one is True, so I need a little help.

bool_one = False

bool_two = True

bool_three = False

bool_four = True

bool_five = False

#2

% in python is Modulo. It returns the remainder when you divide a number.

4 % 2 returns 0, because four is divisible by two so there is no remainder.
5 % 2 returns 1, because two goes into 5 twice but there is one left over.

bool_one = 8 == 8 or 'Cleese' == 'King Arthur'


#3

Thank you! I kinda just figured that out but I am thankful for the clarification, captainap.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.