L1 Intro To Python Programming
L1 Intro To Python Programming
Introduction to
Python Programming
BSIT 2
OCTOBER 11, 2023
What is Python Programming?
• Python was invented in 1991 by Guido van Rossum with
the goal of emphasizing readability and simplicity.
• Drawing from his love for Monty Python, van Rossum
named the language “Python,” a playful homage to his
favorite comedy group.
Why Python?
• Python is widely used for web development, data analysis,
artificial intelligence, and more.
• Easy-to-read syntax makes it a great choice for beginners.
• A vast community and extensive libraries are available for
support.
Python in web development
• Python is widely used for web development, data analysis,
artificial intelligence, and more.
• Easy-to-read syntax makes it a great choice for beginners.
• A vast community and extensive libraries are available for
support.
Key Features
• Readability: Code is easy to understand and write.
• Versatility: Python can be used for various applications.
• Interpreted Language: No need for compilation; code is executed line by
line.
• Dynamically Typed: Variable types are determined at runtime.
• Indentation: Uses indentation to define code blocks (no braces or
semicolons).
Python Basics
• Variables and Data Types
• Conditional Statements (if, elif, else)
• Loops (for, while)
• Functions
• Lists and Dictionaries
Python in Real World
• Web Development (Django, Flask)
• Data Analysis (Pandas, NumPy)
• Machine Learning (TensorFlow, PyTorch)
• Automation (Scripting)
• Game Development (Pygame)
Python Syntax
What is Syntax?
• Syntax refers to the set of rules that dictate how programs written in a
programming language must be structured.
• It defines how statements, expressions, and instructions should be
written for the computer to understand.
Python's Clean and Readable Syntax
• Python is known for its clean and readable syntax.
• It emphasizes code readability, which makes it easier to write and
maintain.
Basic Python Syntax Rules
• Statements end with a newline character (no semicolons).
• Indentation is used for code blocks (no braces).
• Case-sensitive language.
• Use of descriptive variable names.
Python Indentation
• Python uses indentation to define code blocks.
• Consistent indentation (typically 4 spaces) is crucial.
• Incorrect indentation can lead to syntax errors.
Common Syntax Errors
• Missing colons in control structures.
• Example: if condition should be if condition:
• Inconsistent indentation.
• Example: Inconsistent use of spaces for indentation.
• Mismatched parentheses, brackets, or quotes.
• Example: print("Hello) should be print("Hello")
• Misspelled keywords and variable names.
• Example: Using prnt instead of print.