Beginner's Guide

Python Basics of Programming

Learn Python with simple examples: variables, data types, input, output, and operators explained in easy language.

🚀

Introduction

Have you ever wondered how apps, websites, or even simple calculators work? Everything starts with programming. And if you're just beginning your journey, Python is one of the easiest and most powerful languages to learn.

Think of programming like giving instructions to a robot. If your instructions are clear, the robot works perfectly. If not, things go wrong. Python helps you give those instructions in a simple and readable way—almost like writing English!

📋 Table of Contents

01What is Python Programming?
02Understanding Variables
03Data Types in Python
04Integer Data Type
05Float Data Type
06String Data Type
07Boolean Data Type
08Input and Output in Python
09Using print() Function
10Using input() Function
11Arithmetic Operators
12Comparison Operators
13Logical Operators
14Real-Life Examples in Python
15Complete Beginner Program
1

What is Python Programming?

Python is a programming language used to create software, websites, games, and even AI systems. The best part? It's simple and easy to read.

👉 EXAMPLE
print("Hello, World!")
OUTPUT
Hello, World!

This single line tells the computer to display a message.

2

Understanding Variables

📦 What is a Variable?

A variable is like a container that stores data. Think of it like a box where you keep things. You can label the box and store something inside.

👉 EXAMPLE
name = "John"
age = 25
📝
name

stores text

🔢
age

stores a number

3

Data Types in Python

Data types define what kind of value a variable holds.

🔢
Integer
Whole Numbers
💧
Float
Decimal Numbers
💬
String
Text in Quotes
Boolean
True / False
4

Integer Data Type

What is Integer? An integer is a whole number (no decimal).

👉 QUICK EXAMPLE
age = 20
📝 PROGRAM EXAMPLE
a = 10
b = 5
print(a + b)
OUTPUT
15
a and b are integers
+ adds them
5

Float Data Type

What is Float? A float is a number with decimals.

👉 QUICK EXAMPLE
price = 99.99
📝 PROGRAM EXAMPLE
x = 5.5
y = 2.5
print(x + y)
OUTPUT
8.0
✔ Float numbers are used for precision (like money)
6

String Data Type

What is String? A string is text inside quotes.

👉 QUICK EXAMPLE
name = "Alice"
📝 PROGRAM EXAMPLE
first_name = "John"
last_name = "Doe"
print(first_name + " " + last_name)
OUTPUT
John Doe
✔ Strings can be joined using +
7

Boolean Data Type

What is Boolean? Boolean has only two values:

True False
👉 QUICK EXAMPLE
is_active = True
📝 PROGRAM EXAMPLE
a = 10
b = 5
print(a > b)
OUTPUT
True
✔ 10 > 5 is true, so output is True
8

Input and Output in Python

Programming becomes useful when users can interact with it.

9

Using print() Function

What is print()? It displays output on the screen.

👉 EXAMPLE
print("Welcome to Python")
OUTPUT
Welcome to Python
10

Using input() Function

What is input()? It takes input from the user.

👉 EXAMPLE
name = input("Enter your name: ")
print("Hello", name)
OUTPUT
Enter your name: Rahul
Hello Rahul
💡 Important Tip

Input always comes as a string. Convert if needed.

age = int(input("Enter age: "))
11

Arithmetic Operators

These are used for calculations.

OPERATOR MEANING
+ Addition
- Subtraction
* Multiplication
/ Division
📝 EXAMPLE
a = 10
b = 3

print(a + b)
print(a - b)
print(a * b)
print(a / b)
OUTPUT
13
7
30
3.3333333333333335
12

Comparison Operators

Used to compare values.

OPERATOR MEANING
== Equal
!= Not equal
> Greater
< Less
📝 EXAMPLE
a = 5
b = 10

print(a == b)
print(a < b)
OUTPUT
False
True
13

Logical Operators

Used to combine conditions.

OPERATOR MEANING
and Both must be true
or One must be true
not Opposite
📝 EXAMPLE
a = 5
b = 10

print(a < b and b > 5)
print(a > b or b > 5)
print(not(a > b))
OUTPUT
True
True
True
14

Real-Life Examples in Python

EXAMPLE 1

🧮 Simple Calculator

num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))

print("Addition:", num1 + num2)
🏭 Real-Life Use: Calculators, billing systems
EXAMPLE 2

🗳️ Voting Eligibility

age = int(input("Enter your age: "))

if age >= 18:
    print("You can vote")
else:
    print("You cannot vote")
🏭 Real-Life Use: Registration systems
EXAMPLE 3

🔐 Login System (Basic)

password = input("Enter password: ")

if password == "1234":
    print("Access granted")
else:
    print("Access denied")
🏭 Real-Life Use: Apps and websites
15

Complete Beginner Program

🎓 Student Info System
name = input("Enter your name: ")
age = int(input("Enter your age: "))
marks = float(input("Enter your marks: "))

print("\nStudent Details:")
print("Name:", name)
print("Age:", age)
print("Marks:", marks)

if marks >= 50:
    print("Result: Pass")
else:
    print("Result: Fail")
📤 OUTPUT EXAMPLE
Enter your name: Ravi
Enter your age: 20
Enter your marks: 65.5

Student Details:
Name: Ravi
Age: 20
Marks: 65.5
Result: Pass
✔ Takes user input
✔ Displays information
✔ Uses condition to check result
🎉

Conclusion

Learning Python basics is like learning the alphabet before writing sentences. Once you understand variables, data types, input/output, and operators, you're ready to build real programs. Don't worry if things feel new right now. With practice, everything becomes clearer. Keep experimenting, keep coding—and most importantly, enjoy the process!

❓ FAQs

1. What is Python mainly used for?

Python is used for web development, data analysis, AI, automation, and more.

2. Is Python easy for beginners?

Yes! Python is one of the easiest programming languages to learn.

3. What is the difference between int and float?

Integer is a whole number, while float has decimal values.

4. Why do we use input() in Python?

It allows users to enter data into the program.

5. What are operators in Python?

Operators are symbols used to perform operations like addition or comparison.

✦ PYTHON BASICS GUIDE ✦ BEGINNER FRIENDLY ✦
✦ THE ASCENDANT TRIAD ✦
🏆 3 game‑changing catalysts ⚡ curated for visionaries

Elevate your craft — from first spark to full-stack brilliance

🐍
Python Alchemy: Syntax to Sorcery
Unlock automation, data logic, and real‑world problem solving. Build projects that think with you — from day one.
✨ 94% mastery rate ✨
🎨
Semantic Canvas: HTML & CSS Alchemy
Architect responsive digital realms, fluid layouts, and pixel‑perfect interfaces. Become the artist of the modern web.
🌈 12+ interactive modules 🌈
JavaScript Odyssey: Frontier to Cloud
Conquer React, Node.js, databases & deployment — become a one‑person army. Build full‑stack apps that dazzle.
🔥 industry‑led bootcamp 🔥
🚀 IGNITE YOUR TRANSFORMATION →