DS Python
DS Python
What is Python?
Python is a popular programming language. It was created by Guido van Rossum, and released
in 1991.
It is used for:
String:
Strings in python are surrounded by either single quotation marks, or double quotation marks.
print("Hello")
print('Hello')
a = "Hello"
print(a)
String Methods:
find (): Searches the string for a specified value and returns the position of where it was found
index (): Searches the string for a specified value and returns the position of where it was found
lower (): Converts a string into lower case
split (): Splits the string at the specified separator, and returns a list
List:
Lists are used to store multiple items in a single variable.
It is also possible to use the list () constructor when creating a new list.
List items are indexed and you can access them by referring to the index number:
To add an item to the end of the list, use the append () method:
Set:
Sets are used to store multiple items in a single variable.
Set items are unordered, unchangeable, and do not allow duplicate values.
thisset.remove("banana")
thisset.add("orange")
Set Methods:
add () Adds an element to the set
clear () Removes all the elements from the set
copy () Returns a copy of the set
Tuples:
Tuples are used to store multiple items in a single variable.
Once a tuple is created, you cannot change its values. Tuples are unchangeable,
or immutable as it also is called.
But there is a workaround. You can convert the tuple into a list, change the list, and convert the
list back into a tuple.
Dictionary:
Dictionaries are used to store data values in key:value pairs.
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
print(thisdict)
Adding an item to the dictionary is done by using a new index key and assigning a value to
it:
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
thisdict["color"] = "red"
print(thisdict)
Explore Anaconda
Anaconda is a popular distribution of the Python and R programming languages for data science,
machine learning, and scientific computing. It simplifies package management and deployment
by providing a comprehensive ecosystem of tools and libraries pre-installed. Here are some key
aspects and features of Anaconda:
1. Package Management: Anaconda includes the Conda package manager, which allows
you to easily install, update, and manage packages and dependencies. Conda can install
packages from the Anaconda repository as well as from other repositories such as PyPI
(Python Package Index).
2. Cross-Platform: Anaconda supports Windows, macOS, and Linux platforms, making
it versatile for development and deployment across different operating systems.
3. Integrated Development Environment (IDE): Anaconda comes with Spyder, an
opensource IDE designed specifically for scientific computing and data analysis. It also
integrates well with other popular IDEs such as Jupyter Notebook and JupyterLab.
4. Wide Range of Packages: Anaconda includes a vast collection of pre-installed
libraries and tools commonly used in data science and scientific computing, such as
NumPy, Pandas, Matplotlib, SciPy, Scikit-learn, and many others. This reduces the setup
time and ensures compatibility among the packages.
5. Virtual Environments: Conda allows you to create isolated environments that can
have their own Python version and set of installed packages. This helps in managing
dependencies and avoiding conflicts between different projects.
Overall, Anaconda is widely used by data scientists, researchers, and developers due to its ease
of use, extensive package support, and robust ecosystem tailored for scientific computing and
data analysis workflows.