Python 1 Flashcards
- has undoubtedly risen to prominence as a versatile and user-friendly programming language.
- Its simplicity and readability have attracted a vast developer community.
- However, like any tool, it comes with its own set of strengths and weaknesses.
Python
python advantages
- readability and simplicity
- large and active communities
- versatility
- extensive libraries
- open source
- rapid development
Python’s syntax is clean and resembles natural language, making it easy to learn and understand.
- Readability and Simplicity
A vast community of developers contributes to Python’s growth, providing extensive support and resources.
- Large and Active Community
: Python boasts a rich ecosystem of libraries
extensive libraries
Python is applicable in various domains, including web development, data
versatility
Being open-source, Python is free to use, modify, and distribute.
open source
Python’s interpreted nature and high-level abstractions facilitate rapid prototyping and development
rapid development
Python’s interpreted nature can lead to slower execution compared to compiled languages like C++ or Java.However, for many applications, this performance difference is negligible.
speed
This limits Python’s ability to fully utilize multiple CPU cores, impacting performance in multi-threaded applications.
- Global Interpreter Lock (GIL)
python disadvantages
- speed
- global interpreter lock
- dynamic typing
- memory consumption
While flexible, dynamic typing can sometimes introduce runtime errors if not handled carefully
- Dynamic Typing
Python can be relatively memory-intensive compared to other languages.
- Memory Consumption
when to use python
- rapid prototyping and scripting
- data analytics and machine learning
- web deveopment
- automation
Its ease of use and speed of development make it ideal for quickly creating prototypes.
- Rapid prototyping and scripting
Python’s rich ecosystem of libraries (NumPy, Pandas, Scikit-learn) provides powerful tools for data manipulation and modeling.
- Data analysis and machine learning
Frameworks like Django and Flask simplify web application development.
- Web development
Python excels at automating tasks, improving productivity
- Automation
Unlike many other languages, Python uses —— (specifically indentation) to define code blocks.
indentation, whitespace
Comments
- Single-line comments start with #
- Multi-line comments can be enclosed in triple quotes (‘’’ or “””)
Data Types
- numbers
- string
- list
- tuples
- dictionaries
- sets
Integers, floating-point numbers, complex numbers
- Numbers
Textual data enclosed in single or double quotes
- Strings
Ordered collections of items
- Lists
Immutable ordered collections
- Tuples
Unordered collections of key-value pairs
- Dictionaries
control flow
- if else
- for
- while
- break
- continue
Conditional execution
- if-else
Unordered collections of unique elements
- Sets
Iterating over sequences
- for
Looping until a condition is false
while
Exits a loop
break
Skips the current iteration
continue
- Python are simply containers for storing data values.
- Think of them as labeled boxes where you can place different types of information.
- Python doesn’t require you to declare a variable’s type beforehand; it determines the type automatically when you assign a value to it.
Variables
data types
- number
- string
- boolean
- list
- tuple
- dictionary
- set
Variable Naming Conventions
- Variable names can contain letters, numbers, and underscores (_).
- They must start with a letter or an underscore.
- Python is case-sensitive, so age and Age are different variables.
- descriptive names for readability