bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
Learn/Python/Files, Modules, and the Standard Library
Python•Files, Modules, and the Standard Library

How to Add Two Numbers in Python

Learn how to add two numbers in Python.

Use the + operator to add two numbers:

Example

x = 5
y = 10
print(x + y)

Add Two Numbers with User Input

In this example, the user must input two numbers. Then we print the sum by calculating (adding) the two numbers:

Example

x = input("Type a number: ")
y = input("Type another number: ")
sum
= int(x) + int(y)
print("The sum is: ", sum)

Previous

Python Requests Module

Next

Python Delete File

This chapter

Overview
13

Lessons

39m

Read time

1. Python File Open2. Python Python Built-in Modules3. How to Remove Duplicates From a Python List4. Python File Open5. Python Random Module6. How to Reverse a String in Python7. Python File Write8. Python Requests Module9. How to Add Two Numbers in Python10. Python Delete File11. Python statistics Module12. Python math Module13. Python cmath Module