Hey there! Sign in to join this conversationNew here? Join for free
    • Thread Starter
    Offline

    5
    ReputationRep:
    What sign do I use to divide two numbers in python and get the remainder of the two?
    Offline

    9
    ReputationRep:
    % (modulus) I think
    • Thread Starter
    Offline

    5
    ReputationRep:
    (Original post by Ethan9133)
    % (modulus) I think
    yea thanks, do you know if there is a way to get the answer to the division at the same time and not just the remainder?
    Offline

    18
    ReputationRep:
    (Original post by Biology123ABC)
    yea thanks, do you know if there is a way to get the answer to the division at the same time and not just the remainder?
    In Visual Basic you can use the backslash (\) to do integer division (dividing the numbers but ignoring the remainder). For Python I think you have to do int(a/b) (the int bit can be used to convert anything to an integer) - I don't know of a shortcut like VB has.
    Offline

    9
    ReputationRep:
    Do you only need to print the results to the console or are you storing the divisions in variables to use in later calculations?
    Python uses / for dividing i.e. print(6/2) prints 3
    % outputs the remainder i.e. print(7%2) prints 1
    you can also use variables in place of the numbers
    you can also store the answer to the calculation in a variable too
    Offline

    18
    ReputationRep:
    (Original post by Biology123ABC)
    yea thanks, do you know if there is a way to get the answer to the division at the same time and not just the remainder?
    Come on dude...

    /
    Offline

    15
    ReputationRep:
    (Original post by Biology123ABC)
    yea thanks, do you know if there is a way to get the answer to the division at the same time and not just the remainder?
    no way i know but // returns the maximum number of times the thing can be divided

    so 1//3 gives 0 for example
    (Original post by Speckle)
    Come on dude...

    /
    wat that's just good ol regular divide % gives the remainder after diving as many times as possible
    Offline

    12
    ReputationRep:
    If you're looking to output the remainder and the division then you would have to write two separate lines of code to print out the two answers. One for using '/' and the other using '%'. I don't know if there is an operation that prints both together.
 
 
 
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • Poll
    Will you be richer or poorer than your parents?
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

    Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

    Quick reply
    Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.