What other arithmetic operations can Python do?

QuestionsQuestions8 SkillsProYour First Python LabOct, 04 2025
088

Python supports several arithmetic operations. Here are the main ones:

  1. Addition (+): Adds two numbers.

    result = 2 + 3  # result is 5
  2. Subtraction (-): Subtracts the second number from the first.

    result = 5 - 2  # result is 3
  3. Multiplication (*): Multiplies two numbers.

    result = 4 * 3  # result is 12
  4. Division (/): Divides the first number by the second (returns a float).

    result = 10 / 2  # result is 5.0
  5. Floor Division (//): Divides and returns the largest whole number (integer).

    result = 10 // 3  # result is 3
  6. Modulus (%): Returns the remainder of the division.

    result = 10 % 3  # result is 1
  7. Exponentiation (**): Raises the first number to the power of the second.

    result = 2 ** 3  # result is 8

These operations can be used with integers and floats. If you want to practice these operations, consider checking out relevant labs on LabEx! Let me know if you have more questions!

0 Comments

no data
Be the first to share your comment!