18
Lesson 2 of 44

Arithmetic operators

In this Python lesson, we will delve into the intricacies of arithmetic fundamentals and their application in programming. Through practical exercises and theoretical concepts, you will learn how to employ arithmetic operators and numeric data types in Python for accurate and efficient calculations. This lesson is suitable for both beginners and intermediate programmers looking to solidify their understanding of arithmetic operations within the Python context.

  • 7 theory articles
  • 11 practice exercises
Start lesson

Fundamentals concepts 7

Python arithmetic operators

Python can be used as a very powerful calculator. Arithmetic operators are the symbols that tell it which operation to perform on…

Theory
Read more

Reading numbers from the user

Almost every exercise in this lesson starts by asking the user for one or more numbers. There is an important detail that causes…

Theory
Read more

Division in Python: /, // and %

Python has three division-related operators, and each one answers a different question: what is the result?, how many times does…

Theory
Read more

Common arithmetic errors

Making mistakes is normal, and Python's error messages tell you exactly what happened. These are the three you will see most…

Theory
Read more

Operator precedence and parentheses

When an expression has several operators, Python does not simply evaluate them from left to right: it follows an order of…

Theory
Read more

Integers, floats and precision

Python has two types of numbers that you will use constantly: integers ( int ) and decimals ( float ). They behave almost the…

Theory
Read more

Numeric functions and the math module

Besides operators, Python includes ready-to-use functions for numbers. Some are always available and others live in the math…

Theory
Read more

Practice exercises 11

Sums squared

Write a program in Python that asks the user for an integer x and prints the result of adding it to its square.

Exercise Easy
Solve it

Multiplication of three factors

Write a program in Python that multiplies by three factors. Ask the user for three numbers and show the result of multiplying…

Exercise Easy
Solve it

Division and division module

Write a program in Python that requests two integers from the user (x, y) and print the result of the division and the rest of…

Exercise Easy
Solve it

Division by zero

Develop a Python program that prompts the user for two numbers (x and y) and displays the result of the division operation.

Exercise Easy
Solve it

Basic calculator

Write a program in Python that calculates the result of adding, subtracting, multiplying and dividing two numbers entered by the…

Exercise Easy
Solve it

Calculate the dimensions of a sphere

Create a Python program that calculates the surface area and the volume of a sphere, given its radius.

Exercise Easy
Solve it

Order of priority

Create a Python program that requests an integer x from the user and print the result of the following operations:

Exercise Easy
Solve it

Average

Write a Python program that calculates the arithmetic measurement of 4 factors entered by the user, one for each line.

Exercise Easy
Solve it

Equivalent operations

Write a Python program to ask the user for three numbers (a, b, c) and display the result of (a+b)*c and the result of a * c +…

Exercise Easy
Solve it

Convert Degrees Centigrade to Kelvin and Fahrenheit

The Celsius scale is centigrade, 100 divisions separate the freezing point from the boiling point of water. On the Fahrenheit…

Exercise Easy
Solve it

Calculate values of a function

Create a program Python to display certain values of the function y= x2 - 2x + 1 . Ask the user for the range of integers x to…

Exercise Medium
Solve it