Introduction

Welcome to Programming World Prem — your one-stop guide to learning Python from scratch! This tutorial covers the essential Python concepts with examples and clear explanations so even complete beginners can follow along.

By the end of this tutorial, you’ll be able to write simple Python programs, understand how data types and loops work, and create your own functions.


Table of Contents

  1. What is Python?
  2. Installing Python
  3. Your First Python Program
  4. Python Syntax Basics
  5. Variables and Data Types
  6. Input and Output
  7. Operators
  8. Conditional Statements (if/else)
  9. Loops (for and while)
  10. Functions
  11. Lists, Tuples, and Dictionaries
  12. Practice Exercises
  13. Next Steps

1) What is Python?

Python is a high-level, interpreted programming language known for its readability and simplicity. It’s widely used in web development, data science, machine learning, automation, and more.

Key features:

  • Easy to learn and read
  • Large community support
  • Cross-platform compatibility
  • Huge library ecosystem (NumPy, Pandas, Django, etc.)

2) Installing Python

  1. Visit python.org/downloads
  2. Download the latest version for your operating system.
  3. During installation, check the box “Add Python to PATH”.
  4. After installation, open your terminal or command prompt and type:

python –version

If it shows a version number (like Python 3.12.2), you’re ready!


3) Your First Python Program

Open any text editor (VS Code, PyCharm, or even Notepad) and type:

print(“Hello, Programming World Prem!”)

Save it as hello.py and run it using:

python hello.py

Output:

Hello, Programming World Prem!


4) Python Syntax Basics

  • Indentation: Python uses indentation (spaces) instead of braces {}.
  • Comments: Use # for single-line comments.
Example:

# This is a comment

if5 > 2:

print("Five is greater than two!")

Output:

Five is greater than two!

5) Variables and Data Types

A variable stores data that can change during program execution.

Example:

name = "Prem"

age = 21

height = 5.9

is_student = True

Common Data Types:

str — string

int — integer

float — decimal

bool — boolean (True/False)

You can check a variable’s type using:

print(type(name))

6) Input and Output

Use input() to take user input.

name = input("Enter your name: ")

print("Hello,", name)

7) Operators

Python supports arithmetic, comparison, and logical operators.

Example:

a = 10

b = 5

print(a + b) # Addition

print(a > b) # Comparison

print(a == b) # Equality

print(a > 5andb < 10) # Logical

8) Conditional Statements

x = 10

ifx > 0:

print("Positive number")

elifx == 0:

print("Zero")

else:

print("Negative number")

9) Loops

For Loop

foriinrange(5):

print(i)

Output:

0

1

2

3

4

While Loop

count = 0

whilecount < 5:

print(count)

count += 1

10) Functions

Functions let you reuse code easily.

defgreet(name):

print("Hello,", name)

greet("Prem")

Output:

Hello, Prem

You can also return values:

defadd(a, b):

returna + b

print(add(5, 3))

11) Lists, Tuples, and Dictionaries

List

fruits = ["apple", "banana", "cherry"]

print(fruits[0])

Tuple

colors = ("red", "green", "blue")

print(colors[1])

Dictionary

person = {"name": "Prem", "age": 21}

print(person["name"])

12) Practice Exercises

Try these to test your skills:

  1. Write a Python program to swap two numbers.
  2. Write a program to check if a number is even or odd.
  3. Create a list of 5 fruits and print each one.
  4. Write a function to find the factorial of a number.

13) Next Steps

Congratulations! You’ve completed the Python Basics course. Here’s what you can learn next:

  • File Handling (open(), read(), write())
  • Modules and Packages
  • Object-Oriented Programming (OOP)
  • Data Structures (lists, sets, dictionaries)
  • Libraries like NumPy, Pandas, Matplotlib

Author: Programming World Prem — beginner-friendly Python tutorials for everyone!

Stay tuned for the next post: Python Advanced Course — Loops, OOP, and Projects!