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
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.
print("Hello, World!")
Hello, World!
This single line tells the computer to display a message.
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.
name = "John" age = 25
name
stores text
age
stores a number
Data Types in Python
Data types define what kind of value a variable holds.
Integer Data Type
What is Integer? An integer is a whole number (no decimal).
age = 20
a = 10 b = 5 print(a + b)
15
a and b are integers+ adds themFloat Data Type
What is Float? A float is a number with decimals.
price = 99.99
x = 5.5 y = 2.5 print(x + y)
8.0
String Data Type
What is String? A string is text inside quotes.
name = "Alice"
first_name = "John" last_name = "Doe" print(first_name + " " + last_name)
John Doe
+Boolean Data Type
What is Boolean? Boolean has only two values:
is_active = True
a = 10 b = 5 print(a > b)
True
TrueInput and Output in Python
Programming becomes useful when users can interact with it.
Using print() Function
What is print()? It displays output on the screen.
print("Welcome to Python")
Welcome to Python
Using input() Function
What is input()? It takes input from the user.
name = input("Enter your name: ")
print("Hello", name)
Enter your name: Rahul Hello Rahul
Input always comes as a string. Convert if needed.
age = int(input("Enter age: "))
Arithmetic Operators
These are used for calculations.
a = 10 b = 3 print(a + b) print(a - b) print(a * b) print(a / b)
13 7 30 3.3333333333333335
Comparison Operators
Used to compare values.
a = 5 b = 10 print(a == b) print(a < b)
False True
Logical Operators
Used to combine conditions.
a = 5 b = 10 print(a < b and b > 5) print(a > b or b > 5) print(not(a > b))
True True True
Real-Life Examples in Python
🧮 Simple Calculator
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
print("Addition:", num1 + num2)
🗳️ Voting Eligibility
age = int(input("Enter your age: "))
if age >= 18:
print("You can vote")
else:
print("You cannot vote")
🔐 Login System (Basic)
password = input("Enter password: ")
if password == "1234":
print("Access granted")
else:
print("Access denied")
Complete Beginner Program
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")
Enter your name: Ravi Enter your age: 20 Enter your marks: 65.5 Student Details: Name: Ravi Age: 20 Marks: 65.5 Result: Pass
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
Python is used for web development, data analysis, AI, automation, and more.
Yes! Python is one of the easiest programming languages to learn.
Integer is a whole number, while float has decimal values.
It allows users to enter data into the program.
Operators are symbols used to perform operations like addition or comparison.
Elevate your craft — from first spark to full-stack brilliance

0 Comments
If you have any doubts, Please let me know