INTRODUCTION TO PYTHON
"A Beginner's Guide to Python Programming“
Name: M.Faraz Siddiqui
Date: 20-11-2023
Agenda:
What is Python?
Why Python?
Python's Syntax
Data Types and Variables
Control Flow and Loops
Functions
Data Structures
File Handling
Libraries and Frameworks
Conclusion
What is Python?
High-Level, Interpreted
Programming Language
Developed by Guido van Rossum
(First released in 1991)
Readable and Simple Syntax
(Indentation-based)
Versatile and Beginner-Friendly
Why Python?
Popularity in the programming community
Versatility for Web Development, Data Science, Machine
Learning, Automation
Extensive Community Support
Rich Ecosystem of Libraries and Frameworks
Python's Syntax
Indentation-based syntax
if x > 5:
print("x is greater than 5")
else:
print("x is less than or equal to 5“)
Clean and Concise Syntax
Consistent Indentation is Key
for Readability
Data Types and Variables
Data Types in Python:
• Integer
• Float
• String
• Boolean
• and more...
Variables:
• Variable Assignment
x=5
• Data Manipulation
y=x+3
Control Flow and Loops
Conditional Statements:
if x > 0:
print("Positive")
elif x < 0:
print("Negative")
else:
print("Zero")
Loops:
for i in range(5): while x > 0:
print(i)
print(x)
Functions
Definition using 'def':
def greet(name):
print("Hello, " + name)
Calling a Function:
greet("Alice")
Parameters and Return Values:
def add(x, y):
return x + y
result = add(3, 5)
print(result)
Data Structures
Lists:
Ordered, Mutable
Example: [1, 2, 3]
Tuples:
Ordered, Immutable
Example: (1, 2, 3)
Dictionaries:
Unordered, Key-Value Pairs
Example: {'a': 1, 'b': 2}
File Handling
Opening a File:
file = open("example.txt", "r")
Reading from a File:
content = file.read()
Writing to a File:
file = open("example.txt", "w")
file.write("Hello, Python!")
Appending to a File:
file = open("example.txt", "a")
file.write("\nNew content")
Closing a File:
file.close()
Libraries and Frameworks
Python Ecosystem:
• Extensive libraries and
• frameworks
• Examples:
• NumPy: Numerical computing
• Pandas: Data manipulation
• Django: Web development
• Flask: Web microframework
• TensorFlow: Machine Learning
Conclusion
Recap of Key Concepts:
Python syntax, data types,
control flow, functions,
data structures, file handling,
libraries, and frameworks
Python's Strengths:
Versatility, readability,
extensive community support
Encourage Further Learning:
Explore online courses,
documentation, and community
forums for continued learning