Basics of Python Programming

Srikanth Thyagarajan
3 min readFeb 14, 2021
Photo by Chris Ried on Unsplash

Python is hot primarily because it has all the right stuff for the kind of software development that’s really driving the whole software development world these days. It is popular mainly because it already has lots of capabilities in the areas like Machine learning, robotics, artificial intelligence, and data science, while many older languages lag behind in these technologies. The main reasons cited for Python’s current popularity are

  • Python is relatively easy to learn.
  • Everything you need to learn (and do) Python is free.
  • Python offers more readymade tools for current hot technologies like data science, machine learning, artificial intelligence, and robotics than most other languages.

Understanding Python Data Types

You deal with written information all the time and probably don’t think about the difference between numbers and text (that is, letters and words). But there’s a big difference between numbers and text in a computer because with numbers, you can do arithmetic (add, subtract, multiple, divide). For example, everybody knows that 1+1 = 2. The same doesn’t apply to letters and words. The expression A+A doesn’t necessary equal B or AA or anything else because unlike numbers, letters and words aren’t quantities. You can buy 12 apples at the store, because 12 is a quantity, a number — a scalar value in programming jargon. You can’t really buy a snorkel apples because a snorkel is a thing, it’s not a quantity, number, or scalar value.

1. Numbers

Numbers in Python must start with a number digit, (0–9); a dot (period), which is a decimal point; or a hyphen (-) used as a negative sign for negative numbers.

Example of good and bad numbers in python

you may occasionally see numbers that contain the letter e or the letter j. That’s because Python actually supports three different types of numbers

Working with Arithmetic operators

Integers

An integer is any whole number, positive or negative. There is no limit to its size. Numbers like 0, -1, and 999999999999999 are all perfectly valid integers.

Floats

A floating point number, often called a float for short, is just any valid number that contains a decimal point. Again, there is no size limit, 1.1 and -1.1 and 123456.789012345 are all perfectly valid floats.

Complex numbers

Just about any kind of number can be expressed as an integer or float, so being familiar with those is sufficient for just about everyone. Though in the interest of being accurate we should point out that Python also supports complex numbers. These bizarre little charmers always end with the letter j, which is the imaginary part of the number.

2. Words (strings)

Strings are sort of the opposite of numbers. With numbers, you can add, subtract, multiply, and divide because the numbers represent quantities. Strings are for just about everything else. Names, addresses, and all other kinds of text you see every day would be a string in Python Unlike numbers, a string must always be enclosed in quotation marks. You can use either double quotation marks (“) or singles (‘). All the following are valid strings:

‘Hello world’

“123 Oak Tree Lane”

3. True/false Booleans

Boolean is a data type in Python that isn’t exactly a number, or a string it can be one of two values: either True or False.

other Links

Working with Python Operators. Arithmetic operators | by Srikanth Thyagarajan | Feb, 2021 | Medium

--

--