0% found this document useful (0 votes)
3 views4 pages

Python Learning Document

Learn python easy

Uploaded by

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

Python Learning Document

Learn python easy

Uploaded by

arc5285
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Python Learning Document

1. Introduction to Python
Python is a high-level, interpreted programming language known for its easy-to-read syntax
and wide range of applications—from web development to data analysis, automation, and
artificial intelligence.

Key Features

 Simple and readable syntax


 Interpreted (no compilation needed)
 Dynamically typed
 Extensive standard library
 Large community support

2. Setting Up the Environment


Installing Python

1. Visit https://www.python.org/downloads/
2. Download the latest version (recommended)
3. Install and check version:

python --version

Using an IDE or Text Editor

 IDEs: PyCharm, Visual Studio Code, Thonny


 Online Editors: Replit, Jupyter Notebook, Google Colab

3. Basic Syntax and Data Types


Hello World Example
print("Hello, World!")

Comments
# This is a single-line comment
"""
This is a
multi-line comment
"""
Variables and Data Types
name = "Alice" # string
age = 25 # integer
height = 5.6 # float
is_student = True # boolean

Common Data Types


 int
 float
 str
 bool
 list, tuple, dict, set

4. Control Flow
Conditional Statements
if age >= 18:
print("Adult")
else:
print("Minor")

Loops

For Loop

for i in range(5):
print(i)

While Loop

count = 0
while count < 5:
print(count)
count += 1

5. Functions
def greet(name):
return f"Hello, {name}!"

print(greet("Alice"))

6. Data Structures
Lists
fruits = ["apple", "banana", "cherry"]
fruits.append("orange")

Tuples
coordinates = (10.0, 20.0)

Dictionaries
person = {"name": "Alice", "age": 25}
print(person["name"])

Sets
unique_numbers = {1, 2, 3, 2}

7. File Handling
# Write to file
with open("file.txt", "w") as f:
f.write("Hello, world!")

# Read from file


with open("file.txt", "r") as f:
print(f.read())

8. Error Handling
try:
x = 10 / 0
except ZeroDivisionError:
print("Cannot divide by zero")
finally:
print("Execution complete")

9. Modules and Packages


import math
print(math.sqrt(16))

Creating Your Own Module


# mymodule.py
def add(a, b):
return a + b

# main.py
import mymodule
print(mymodule.add(2, 3))
10. Next Steps
 Practice with small projects
 Explore libraries like numpy, pandas, matplotlib
 Learn about Object-Oriented Programming (OOP)
 Try web development with Flask or Django
 Dive into automation or data science

You might also like