{"id":22267730,"url":"https://github.com/addleonel/python-fundamentals","last_synced_at":"2025-03-25T14:43:23.145Z","repository":{"id":53458623,"uuid":"270338950","full_name":"addleonel/python-fundamentals","owner":"addleonel","description":"This contains all the basic topics of Python","archived":false,"fork":false,"pushed_at":"2022-08-04T22:47:44.000Z","size":176,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-30T13:28:06.235Z","etag":null,"topics":["dictionaries","oop","python-fundamentals","python3","topics","tuples"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/addleonel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-07T14:56:21.000Z","updated_at":"2021-12-25T21:19:38.000Z","dependencies_parsed_at":"2022-09-18T12:00:48.876Z","dependency_job_id":null,"html_url":"https://github.com/addleonel/python-fundamentals","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/addleonel%2Fpython-fundamentals","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/addleonel%2Fpython-fundamentals/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/addleonel%2Fpython-fundamentals/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/addleonel%2Fpython-fundamentals/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/addleonel","download_url":"https://codeload.github.com/addleonel/python-fundamentals/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245485586,"owners_count":20623232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dictionaries","oop","python-fundamentals","python3","topics","tuples"],"created_at":"2024-12-03T11:08:35.737Z","updated_at":"2025-03-25T14:43:23.120Z","avatar_url":"https://github.com/addleonel.png","language":"Python","readme":"# Python Fundamentals\n\nThis contains all the basic topics of Python\n\n\u003e Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together.\n\n#### What can be done with Python?\n- General Web Development\n- Scientific Computing / Data Science\n- Machine Learning\n- Automation and Scripting\n- Web Scraping\n- build games\n\n#### Install Python:\nTo install Python, follow these steps:\n- Navigate to the Python downloads page: Python [downloads](https://www.python.org/downloads/).\n- Click on the link/button to download Python 3.x or Python 2.7\n- Follow the installation instructions.\n- Open your terminal again and type the command python. The Python interpreter should respond with the version number.\n\ne.g. on windows:\n````text\nPython 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n\u003e\u003e\u003e\n````\n\n#### How to do \"Hello world\" in Python?\n```python\n# this is a comment\nprint(\"Hello World\")\n```\n\n#### Variables\n````python\nnumber = 10  # This a variable\n````\n````python\nPI = 3.14159  # This is a constant\n````\n\n#### Data type\nPython has the following data types built-in by default, in these categories:\n\nCategory | Data type\n----------|----------\nText Type |\t[str](https://github.com/addleonel/python-fundamentals/blob/master/lecture_1/data_type.py)\nNumeric Types |[int](https://github.com/addleonel/python-fundamentals/blob/master/lecture_1/data_type.py), [float](https://github.com/addleonel/python-fundamentals/blob/master/lecture_1/data_type.py), complex\nBoolean Type|\t[bool](https://github.com/addleonel/python-fundamentals/blob/master/lecture_1/data_type.py)\nSequence Types| [list](https://github.com/addleonel/python-fundamentals/blob/master/lecture_1/data_type.py), [tuple](https://github.com/addleonel/python-fundamentals/blob/master/lecture_1/data_type.py), range\nMapping Type|\t[dict](https://github.com/addleonel/python-fundamentals/blob/master/lecture_1/data_type.py)\nSet Types|\t[set](https://github.com/addleonel/python-fundamentals/blob/master/lecture_1/data_type.py), frozenset\nBinary Types|\tbytes, bytearray, memoryview\n\nPrimitive data structures | Non-primitive data structures\n-------------------------| -----------------------------\nIntegers, Float, strings, Boolean| Arrays, Lists, Tuples, Dictionary, Sets, Files\n\n#### Built-in Data Structures\n- [Strings](https://github.com/addleonel/python-fundamentals/blob/master/lecture_1/strings.py)\n- [Lists](https://github.com/addleonel/python-fundamentals#lists)\n- [Tuples](https://github.com/addleonel/python-fundamentals#tuples)\n- [Sets](https://github.com/addleonel/python-fundamentals#sets)\n- [Dictionaries](https://github.com/addleonel/python-fundamentals#dictionaries)\n\n#### Lists\n````python\nmy_list = ['First', 'Second', 'Third', True, 21, 10.5]\nlength = len(my_list)  # Length of the list\n````\n\n#### List Methods\nMethod | Description\n----------------|--------------\n|**append**(x) | Add an item to the end of the list. Equivalent to `a[len(a):] = [x]`.0|\n|**insert**(iterable) | Insert an item at a given position. The first argument is the index of the element before which to insert, so `a.insert(0, x)` inserts at the front of the list, and `a.insert(len(a), x)` is equivalent to `a.append(x)`.|\n|**extend**(i, x) | Extend the list by appending all the items from the iterable. Equivalent to `a[len(a):] = iterable`.\n|**remove**(x) | Remove the first item from the list whose value is equal to x. It raises a `ValueError` if there is no such item.|\n|**pop**(**[**i**]**) | Remove the item at the given position in the list, and return it. If no index is specified, `a.pop()` removes and returns the last item in the list.|\n|**clear**() | Remove all items from the list. Equivalent to `del a[:]`.|\n|**index**(x **[**, start **[**, end **]** **]**) | Return zero-based index in the list of the first item whose value is equal to x. Raises a `ValueError` if there is no such item.|\n|**count**(x) | Return the number of times x appears in the list.|\n|**sort**(\\*, key=None, reverse=False)| Sort the items of the list in place.|\n|**reverse**() | Reverse the items of the list in place. |\n|**copy**() | Return a shadow copy of the list. Equivalent to `a[:]`.|\n\n#### Tuples\n````python\nmy_tuple = (3, 5, 6, 3, 7)\n\n````\n\n#### Tuple methods\nMethod | Description\n--------- | ---------------\n|**count**(x)| Return the number of items x appers in the tuple.|\n|**index**(x **[**, start **[**, end **]** **]**) | Return zero-based index in the tuple of the first item whose value is equal to x. Raises a `ValueError` if there is no such item.|\n\n#### Sets\n```python\nmy_set = {3, 4, 5, 6, 7, 2, 2}  # duplicate items are removed, then the set is {2, 3, 4, 5, 6, 7}\n```\n\n#### Set methods\nMethod | Description\n---------|-------------------\n|**add**(x)|Adds a given element to a set. If the element is already present, it doesn't add any element. `add()` method takes a single parameter:|\n|**clear**()|Removes all elements from the set. It doesn't take any parameters.|\n|**copy**()|Returns a shallow copy of the set. It doesn't take any parameters.|\n|**pop**()|Removes an arbitrary element from the set and returns the element removed. It doesn't take any arguments.|\n|**remove**(x)|Removes the specified element from the set. It takes a single element as an argument and removes it from the set.|\n|**discard**(x)|Takes a single element x and removes it from the set (if present).|\n|**difference**(set)|Returns the difference between two sets which is also a set. It doesn't modify original sets.|\n|**difference_update**(set)|Updates the set calling `difference_update()` method with the difference of sets.|\n|**intersection**(**[** set **[** , ... **]** **]**)|Returns a new set with elements that are common to all sets. Allows arbitrary number of arguments (sets).|\n|**intersection_update**(**[** set **[** , ... **]** **]**)|Updates the set calling `intersection_update()` method with the intersection of sets.|\n|**union**(**[** set **[** , ... **]** **]**)|Returns a new set with elements from the set and all other sets (passed as an argument).|\n|**symmetric_difference**(set)|Returns the symmetric difference of two sets.|\n|**symmetric_difference_update**(set)|Finds the symmetric difference of two sets and updates the set calling it.|\n|**update**(**[** iter **[** , ... **]** **]**)|Updates the set, adding items from other iterables.|\n|**issubset**(set)|Returns `True` if all elements of a set are present in another set (passed as an argument). If not, it returns `False`.|\n|**issuperset**(set)|Return `True` if all elements of another set is present in the current set (method caller). If not, it returns `False`.|\n|**isdisjoint**(set)|Return `True` if two sets are disjoint sets. If not, it returns `False`.|\n\n#### Dictionaries\n```python\nmy_dict = {'name': 'Leo', 'age': 22} # {key:value,}\n```\n#### Dictionary methods\n|Method | Description|\n|--------|-----------|\n|**clear**()|Removes all items from the dictionary.|\n|**copy**()|Returns a shallow copy of the dictionary.|\n|**get**(key **[** , other **]**)|Returns the value of the `key` if this doesn't exist returns `other` that it's `None` for default.|\n|**items**()|Returns a new object of the dictionary's items in (key, value) format.|\n|**keys**()|Returns a new object of the dictionary's keys.|\n|**values**()|Returns a new object of the dictionary's values|\n|**pop**(key **[** , other **]**)|Removes the item with the `key` and returns its value or `other` if `key` is not found. If `other` is not provided and the `key` is not found, it raises `KeyError`.|\n|**popitem**()|Removes and returns an arbitrary item (key, value). Raises `KeyError` if the dictionary is empty.|\n|**update**( **[** other **]** )|Updates the dictionary with the key/value pairs from `other`, overwriting existing keys.|\n|**fromkeys**( sequence, **[** , values **]** )|Returns a new dictionary with the given sequence of elements as the keys of the dictionary.|\n|**setdefault**(key **[** , default_value **]**)|Returns the value of a key (if the key is in dictionary). If not, it inserts key with a value to the dictionary.|\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faddleonel%2Fpython-fundamentals","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faddleonel%2Fpython-fundamentals","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faddleonel%2Fpython-fundamentals/lists"}