What is Python?
The languages we use to interact with computers are called programming languages. We write commands with programming languages and computers work according to those commands. Python is a fourth generation high-level Programming language. It appeared on 20 February 1991. It was created by Guido Van Rossum. Now it is the most popular programming language among the tech-enthusiasts.
Why is Python so popular?
The reasons behind the popularity of Python are multiple. User friendliness, readability, and being a general-purpose language are some of the great reasons of Python’s popularity. As Python is very easy to learn, people nowadays choose Python as their first programming.
Getting started with Python
Almost every programmer start their programming journey by printing “Hello World” in the console or in other Python IDE. IDEs are development environments where we can write and run codes. We will use a Python IDE today to run our first Python code but we will not print “HELLO WORLD” instead we will print “Hello there!”. To print something in python you just need to open your Python IDE, write print and give a pair of parentheses and put your statement inside the parentheses with a pair or double or single quotes.
Here print() is a function and the text we are passing through the function is being printed on the terminal. Don’t be scared of the word “Terminal” and other terminologies we are gonna use next , we'll learn about them later.
Basic Python Data structures
The data or values we work with in Python are usually stored in a variable. In programming languages a variable is a named place in the program where we store a value/values. The texts we store in a variable are called strings. The numerical values are classified as whether integers or floats.
Logical statements in Python
We use if-else keywords for working with logical statements. If the condition written in the if statement is true then the commands written inside the if block gets executed otherwise the commands inside the else block are executed.
In the picture above, the value of the variable a is 5 which is greater than 7 so the print statement inside the if block gets executed and prints “smaller” and the else statement gets ignored.
Comments in Python
Python ignores the statements starting with a “#” sign(without the double quotes) or statements written inside three double or single quotes while code execution. Which means whatever you have written inside the three quotes or after the # sign will not get executed. In Python these statements are called “Comments”. Comments help us to understand code written by someone else.
Top comments (0)