Python Fundamentals: Python programming for complete beginners.
In the following blog, you will learn Python from the very beginning that is from what is python, from setting up the environment to variables.
Let's get started
Introduction.
Python is a general-purpose programming language that supports an object-oriented programming approach as well as a functional programming approach. It was developed by Guido Van Rossum in 1989.
Infinite use cases of Python.
We can find usage of Python very frequently in the software development industry. With the help of Python, we can do the following tasks:-
Web development: By using frameworks such as Django or Flask.
Machine learning: It is the most popular language for developing machine learning models.
Data analysis: With libraries such as Pandas, Numpy, and Scikit-learn python becomes a very commonly used language for data analysis.
Artificial intelligence.
Automation: Python is a popular language for automating tasks, such as web scraping, data entry, and testing.
Game development: By using pygame you can make games in Python.
Desktop application development: Python can be used to develop cross-platform desktop applications using frameworks such as PyQt or wxPython.
Now as we got to know the versatile use of Python, we will proceed with learning it.
Setting up the environment for Python development.
First, you need to download Python on your computer. You can download it from here.
Then you need to have a text editor. Pycharm and vs code are recommended.
While using vs code, install Python and coderunner extensions. It helps in increasing your productivity while writing programs
Now you are fully set to write your first program.
Writing your first Python program.
We will start with basic output.
print("Hello World")
Write the above code in your editor and save the file with the .py extension. Now run the code and you will get the output as Hello World.
For generating numerical output you need not put double inverted commas. An example of the code is given below:-
print(5)
You will get output as 5.
Comments
A comment is a part of the coding file that the programmer does not want to execute, rather the programmer uses it to either explain a block of code or to avoid the execution of a specific part of code while testing.
Single-Line Comments:
To write a comment just add a ‘#’ at the start of the line.
Example 1:-
#To print Sample.
print("Sample")
Output:
Sample
Example 2:-
print("Hello World !!!") #Printing Hello World
Output:
Hello World !!!
Multi-Line Comments:
To write multi-line comments you can use ‘#’ at each line or you can use the multiline string that is """ three double inverted commas.
Example 1**:** The use of ‘#’.
#comment line 1
#comment line 2
print("we are learning python comments")
Output:
we are learning python comments
Example 2: The use of multiline string.
"""comment line 1
comment line 2"""
print("we are learning python comments")
Output:-
we are learning python comments
Python Variables
Variables are containers that store information that can be manipulated and referenced later by the programmer within the code.
Example:
name = "Rajat" #type str
age = 18 #type int
print(name)
print(age)
Output:
Rajat
18
It is always advisable to keep variable names descriptive and to follow a set of rules while creating variables:
A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
Variable names must start with a letter or the underscore character.
Variables are case-sensitive.
Variable names cannot start with a number.
Lets wrap this blog till variables. Now you are ready to go further with loops, if-else statements and arrays.And your not an complete beginner now
Subscribe the newsletter if you liked the blog and to stay tuned.