0% found this document useful (0 votes)
2 views3 pages

Python Guide

Python is a high-level, interpreted programming language known for its readability and simplicity, widely used in various fields such as web development and data science. The document covers basic concepts including variables, control flow, functions, object-oriented programming, and common libraries. It also provides key tips for using Python effectively, such as utilizing virtual environments and f-strings for formatting.

Uploaded by

anumitachoubey8
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Python Guide

Python is a high-level, interpreted programming language known for its readability and simplicity, widely used in various fields such as web development and data science. The document covers basic concepts including variables, control flow, functions, object-oriented programming, and common libraries. It also provides key tips for using Python effectively, such as utilizing virtual environments and f-strings for formatting.

Uploaded by

anumitachoubey8
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python

Simple, Powerful, and Versatile – The Swiss Army Knife of Programming

What is Python?
Python is a high-level, interpreted, general-purpose programming language emphasizing code
readability and simplicity. Created by Guido van Rossum in 1991, it is now one of the most popular
languages in the world, used in web development, data science, AI/ML, automation, and more.

Hello World
print("Hello, World!")

Variables & Data Types


name = "Alice" # str
age = 30 # int
price = 9.99 # float
is_active = True # bool
scores = [90, 85, 92] # list
info = {"city": "NY"} # dict

Control Flow
# If-elif-else
if age >= 18:
print("Adult")
elif age >= 13:
print("Teen")
else:
print("Child")

# For loop
for i in range(5):
print(i)

# List comprehension
squares = [x**2 for x in range(10)]
Functions
def greet(name, greeting="Hello"):
return f"{greeting}, {name}!"

print(greet("Bob"))
print(greet("Alice", "Hi"))

# Lambda
double = lambda x: x * 2

Classes & OOP


class Person:
def __init__(self, name, age):
[Link] = name
[Link] = age

def introduce(self):
return f"I'm {[Link]}, {[Link]} years old"

p = Person("Alice", 30)
print([Link]())

Common Libraries
• os / sys – Operating system and system interactions
• requests – HTTP requests (pip install requests)
• pandas – Data analysis and DataFrames
• numpy – Numerical computing with arrays
• matplotlib – Data visualization and charts
• flask / django – Web frameworks
• scikit-learn – Machine learning

Key Tips
• Use virtual environments: python -m venv env
• Install packages with pip: pip install package-name
• Python uses indentation (4 spaces) instead of braces
• Use f-strings for readable string formatting: f'Hello {name}'
• The Python REPL is great for quick experiments: just type python

You might also like