Introduction to Python
  • 1. Introduction
  • 2. Numbers in Python
  • 3. Text in Python
  • 4. Making Comparisons
  • 5. Making Choices
  • 6. Exercise: Paper, Scissors, Stone game
  • 7. Lists
  • 8. Loops
  • 9. Simple Web Crawler
Powered by GitBook
On this page

Was this helpful?

2. Numbers in Python

There are two major types of numbers in python: integer (whole numbers) and float (decimal numbers). You can play with the two data types In a Python, as follow:

23+54
>> 77

1.3+3.5
>> 4.8

1/2
>> 0.5

Python ignore blank spaces when dealing with numbers. e.g. 23+54 and 23 + 54 are both OK.

You can also put numbers into variables (or placeholder of values), and perform operations on them.

X=4
X-3
>> 1

Note that upper case and lower case matters in Python variable names (case-sensitive). e.g. Yandyare two different variables, and so areMyVariable and myvariable

Previous1. IntroductionNext3. Text in Python

Last updated 5 years ago

Was this helpful?