Familiarization with the basics of Python programming
Introduction to Python
Programming
Python is a high-level, interpreted
programming language known for its simplicity, readability, and versatility.
Features of Python:
- High-level:
Abstracts away many low-level details, making it easier to write code.
- Interpreted:
No need to compile the code before running it.
- Object-oriented:
Supports object-oriented programming principles.
- Dynamically typed:
No need to explicitly declare variable types.
- Large standard library: Provides a wide range of built-in functions and
modules.
"Hello, World!" Program
Python
print("Hello,
World!")
Execution Modes:
- Interactive Mode:
Type and execute Python code directly in the interpreter.
- Script Mode:
Write Python code in a file (with a .py extension) and execute it from the
command line.
Python Character Set:
- Letters (uppercase and lowercase), digits, symbols (+,
-, *, /, etc.), whitespace (spaces, tabs, newlines).
Python Tokens:
- Keywords:
Reserved words with special meanings (e.g., if, else, for).
- Identifiers:
Names given to variables, functions, classes (e.g., name, age, my_function).
- Literals:
Represent constant values (e.g., 10, 3.14, "Hello").
- Operators:
Symbols that perform operations (e.g., +, -, *, /, ==, >).
- Punctuators:
Symbols used for various purposes (e.g., (, ),
[, ], :, ,).
Variables:
- Store data values.
- l-value:
The memory location of a variable.
- r-value:
The value stored in a variable.
Comments:
- Lines in the code that are ignored by the interpreter.
- Single-line comments:
Start with #.
- Multi-line comments:
Enclosed within triple quotes ("""...""").
No comments:
Post a Comment