# Hackspace - Python ## 03.02.2022 --- ## Why Python --- - **Versatile**: You can use it for wide variety of applications like Data Science, Machine Learning, Web Development and more. - **Strong Community**: Meaning there's a package for almost everything so you do not need to re-invent. --- - **Easy to learn**: Easy to read, concise, interpreted language which has libraries that allows you to build pretty much everything. It's written similar to English or spoken language. It's interpreted nature doesn't require it to be compiled first and then run. --- Today we're going to focus on fundamentals of Python: - Installing Python. - Input and output - Data Types - Installing and using Python packages. --- Two ways of writing python. Shell ( interpreter ) or through code editor. --- ### Data Structures - Elements surrounded by `[]` are lists, `{}` are dictionaries or sets, and `()` are tuples. - Dictionaries and sets are almost identical. --- `{}` - **Set** is unordered collection of data types that contains unique keys and not values. Sets are iterable, mutable and has no duplicate elements. ``` myset = {"apple", "banana", "cherry"} ``` - **Dictionaries** are unordered collection of data values and contains key-value pairs. ``` thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964 } ``` --- **Tuples `()` vs Lists `[]`** - Tuples are used to store multiple items in a single variable. - A tuple is a collection which is ordered and unchangeable whether lists can be modified. ``` mytuple = ("apple", "banana", "cherry") ``` --- **Primitive Data Types** In most of the languages you define data types, where python infers that. Ex. amount = 10 ( python will make type of amount an `int` ) amount = 10.5 ( python will make type of amount `float` ) --- ****Step 1: Download**** [Official website](https://www.python.org/downloads/) It comes up with standart library that contains build-in functions. - If you need something extra you can import it from [Python Stadart Library](https://docs.python.org/3/library/) ``` import random ``` --- Let's see the language practically! ---
{"metaMigratedAt":"2023-06-16T19:02:22.608Z","metaMigratedFrom":"Content","title":"Hackspace - Python","breaks":true,"contributors":"[{\"id\":\"7a5548f0-da55-4d05-a75d-a38212f27c1c\",\"add\":3658,\"del\":1505}]"}
    132 views