|

Introduction to Python Programming – Getting Started for Beginners

Python is one of the most popular programming languages in the world today. It is widely used in web development, data science, artificial intelligence, automation, cybersecurity, and even game development. The reason for its popularity is simple: Python is easy to learn, powerful, and readable.

If you are completely new to programming, Python is the best place to start. Its syntax is simple and looks almost like English. As a beginner, your main focus should be understanding how programming works rather than worrying about complex syntax rules. Python helps you do exactly that.

In this post, we will cover:

  • What Python is
  • How to install Python
  • How to write your first program
  • Understanding variables
  • Basic input and output
  • Comments in Python

By the end of this lesson, you will have written your first working Python programs.


What is Python?

Python is a high-level, interpreted programming language created by Guido van Rossum in 1991. It is:

  • Easy to read and write
  • Platform-independent
  • Open-source
  • Used by companies like Google, Netflix, Instagram

Python is interpreted, meaning it runs line by line. You don’t need to compile it like C or Java.


Installing Python

  1. Go to python.org
  2. Download the latest version.
  3. Install it.
  4. Make sure to check “Add Python to PATH” during installation.

To verify installation:

Open Command Prompt (Windows) or Terminal (Mac/Linux) and type:

python --version

If Python is installed, it will show something like:

Python 3.12.0

Your First Python Program

Let’s write the famous “Hello World” program.

Open a text editor or VS Code and create a file named:

hello.py

Write this code:

print("Hello, World!")

Save the file.

Now run it in terminal:

python hello.py

Output:

Hello, World!

Congratulations 🎉
You just wrote your first Python program!


Understanding the print() Function

The print() function displays output on the screen.

Example:

print("Welcome to Python")
print("I am learning programming")

Output:

Welcome to Python
I am learning programming

You can also print numbers:

print(10)
print(5 + 3)

Output:

10
8

Variables in Python

Variables are used to store data.

Think of a variable as a container that holds information.

Example:

name = "Ozone"
age = 22

Here:

  • name stores text
  • age stores a number

Now print them:

print(name)
print(age)

Output:

Ozone
22

Rules for Naming Variables

✔ Can contain letters, numbers, underscore
✔ Must start with a letter or underscore
❌ Cannot start with number
❌ Cannot use keywords (like print, if, else)

Good examples:

student_name = "Ram"
total_marks = 95

Bad example:

2name = "Hari"   # Wrong

Taking User Input

You can take input from the user using input().

Example:

name = input("Enter your name: ")
print("Hello", name)

If user types:

Ozone

Output:

Hello Ozone

Important: input() always returns a string.


Converting Input Data Type

If you want numbers:

age = int(input("Enter your age: "))
print(age + 5)

If user enters 20:

Output:

25

Comments in Python

Comments are used to explain code.

Single-line comment:

# This is a comment
print("Hello")

Multi-line comment:

"""
This is
a multi-line
comment
"""

Comments are ignored by Python.


Mini Practice Program

Let’s create a simple student information program:

name = input("Enter your name: ")
age = int(input("Enter your age: "))
college = input("Enter your college: ")print("----- Student Info -----")
print("Name:", name)
print("Age:", age)
print("College:", college)

Common Beginner Mistakes

  1. Forgetting quotes around text
  2. Not converting input to int
  3. Wrong indentation
  4. Misspelling variable names

Conclusion

In this lesson, you learned:

  • What Python is
  • How to install it
  • How to write your first program
  • Variables
  • Input and output
  • Comments

This is your foundation. In the next post, we will learn about data types and operators.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *