Technology • 2024-03-17
Python for Complete Beginners: Get Started in 1 Hour
Learn the absolute basics of Python programming — variables, loops, functions, and your first program — from scratch.
Python beginnerslearn Python IndiaPython tutorialPython programming basicsPython for beginners 2024
⏱ 2 min read
Why Learn Python?
Python is the world's most popular programming language for beginners. It's readable, versatile (data science, web development, automation, AI), and has enormous job demand. In India, Python skills add ₹2–10 lakh to your salary.
Install Python
- Go to python.org/downloads
- Download Python 3.x (latest version)
- During install: CHECK "Add Python to PATH"
- Or use online: repl.it or Jupyter (no install needed)
Your First Program
print("Hello, World!")
print("Namaste India!")
Variables
name = "Ajay" # String (text)
age = 30 # Integer (whole number)
salary = 75000.50 # Float (decimal number)
is_working = True # Boolean (True or False)
print(name)
print(age)
print("Name:", name, "Age:", age)
Getting Input from User
name = input("Enter your name: ")
print("Hello,", name)
age = int(input("Enter your age: ")) # Convert to integer
print("Next year you'll be", age + 1)
If-Else Conditions
marks = int(input("Enter marks: "))
if marks >= 90:
print("Grade A")
elif marks >= 75:
print("Grade B")
elif marks >= 60:
print("Grade C")
else:
print("Grade D")
Loops
# For loop
for i in range(1, 6):
print(i) # Prints 1 2 3 4 5
# While loop
count = 1
while count <= 5:
print(count)
count = count + 1
Lists (Arrays)
fruits = ["apple", "banana", "mango", "orange"]
print(fruits[0]) # apple (index starts at 0)
print(fruits[-1]) # orange (last item)
print(len(fruits)) # 4
fruits.append("guava") # add item
fruits.remove("banana") # remove item
for fruit in fruits:
print(fruit)
Functions
def calculate_emi(principal, rate, months):
r = rate / 12 / 100
emi = principal * r * (1+r)**months / ((1+r)**months - 1)
return round(emi, 2)
result = calculate_emi(500000, 10, 60)
print("Monthly EMI:", result)
Mini Project: Simple Calculator
num1 = float(input("First number: "))
op = input("Operation (+, -, *, /): ")
num2 = float(input("Second number: "))
if op == "+": print(num1 + num2)
elif op == "-": print(num1 - num2)
elif op == "*": print(num1 * num2)
elif op == "/" and num2 != 0: print(num1 / num2)
else: print("Invalid input")
What to Learn Next
- Dictionaries and sets
- File reading and writing
- Python libraries: NumPy, Pandas, requests
- Object-Oriented Programming (classes)
- Free resources: Python.org tutorial, CS50P (Harvard free course), freeCodeCamp Python on YouTube