generated from cotes2020/chirpy-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add notes for Python for Data Science, AI, and Development
- Loading branch information
1 parent
30f8a1b
commit a527363
Showing
19 changed files
with
162 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
--- | ||
author: [abuturab, admin] | ||
title: "Python Data Structures" | ||
date: 2023-09-23 09:49:00 +0500 | ||
tags: ['IBM DevOps and SE/Python for Data Science, AI, and Development'] | ||
category: ['My Notes', 'DevOps and Cloud'] | ||
img_path: /assets/notes | ||
image: | ||
path: python-for-ds-ai-and-development.jpeg | ||
alt: 'Credits: Image by pressfoto on Freepik' | ||
published: true | ||
--- | ||
|
||
## **Tuples** | ||
|
||
- Tuples are an ordered sequence | ||
- Here is a Tuple “Ratings” | ||
- Tuples are written as comma-separated elements within parentheses | ||
- Tuples concatenation is possible | ||
- Tuple slicing is also possible | ||
- Tuples are immutable | ||
- If one want to manipulate tuples, they have to create a new tuple with the desired values | ||
- **Tuples nesting** (tuple containing another tuple) is also possible | ||
|
||
```py | ||
Ratings = (10, 9, 6, 5, 10, 8, 9, 6, 2) | ||
``` | ||
|
||
![Python data Structures](Python%20Data%20Structures.png){: w="650" h="350"} | ||
|
||
![Python data Structures](Python%20Data%20Structures-1.png){: w="650" h="350"} | ||
|
||
![Python data Structures](Python%20Data%20Structures-2.png){: w="650" h="350"} | ||
|
||
![Python data Structures](Python%20Data%20Structures-3.png){: w="650" h="350"} | ||
|
||
![Python data Structures](Python%20Data%20Structures-4.png){: w="650" h="350"} | ||
|
||
![Python data Structures](Python%20Data%20Structures-5.png){: w="650" h="350"} | ||
|
||
## **Lists** | ||
|
||
- Lists are also ordered in sequence | ||
- Here is a List “L” | ||
|
||
```py | ||
L = ["Michael Jackson", 10.1, 1982] | ||
``` | ||
|
||
- A List is represented with square brackets | ||
- List is **mutable** | ||
- List can nest other lists and tuples | ||
- We can combine lists | ||
- List can be extended with `extend()` method | ||
- `append.()` adds only one element to the List, if we append `L.append([1,2,3,4]`, the List “L” will be: | ||
```py | ||
L = ["Michael Jackson", 10.1, 1982,[1,2,3,4]] | ||
``` | ||
- The method `split()` can convert the string into the List | ||
```py | ||
"Hello, World!".split() | ||
``` | ||
- The `split()` can be used with a delimiter we would like to split on as an argument | ||
```py | ||
"A,B,C,D".split(",") | ||
``` | ||
- Multiple names referring to the same object is known as **aliasing** | ||
![Python data Structures](Python%20Data%20Structures-6.png){: w="650" h="350"} | ||
- We can clone the list, where both lists will be of their independent copies | ||
- So changing List “A”, will not change List “B” | ||
![Python data Structures](Python%20Data%20Structures-7.png){: w="650" h="350"} | ||
## Dictionaries | ||
![Python data Structures](Python%20Data%20Structures-8.png){: w="650" h="350"} | ||
- Dictionaries are denoted with curly Brackets {} | ||
- The keys have to be immutable and unique | ||
- The values can be immutable, mutable and duplicates | ||
- Each key and value pair is separated by a comma | ||
![Python data Structures](Python%20Data%20Structures-9.png){: w="650" h="350"} | ||
## Sets | ||
- Sets are a type of collection | ||
- This means that like lists and tuples you can input different python types | ||
- Unlike lists and tuples they are unordered | ||
- This means sets don’t record element position | ||
- Sets only have unique elements | ||
- This means there is only one of a particular element in a set | ||
### Sets: Creating a Set | ||
![Python data Structures](Python%20Data%20Structures-10.png){: w="650" h="350"} | ||
- You can convert a list into set | ||
```py | ||
List = ['foo'] | ||
set(List) | ||
``` | ||
- To add elements to the set, `set.add('foo')` | ||
- To remove an element, `set.remove(‘foo’)` | ||
- To check if an element is present in the set: | ||
```py | ||
'foo' in set | ||
True/False | ||
``` | ||
### Sets: Mathematical Expression | ||
- To find the intersection of the sets elements present in the both sets), `set1 & set2` or `set1.intersetion(set2)` | ||
|
||
![Python data Structures](Python%20Data%20Structures-11.png){: w="650" h="350"} | ||
|
||
- Union of the sets, contain elements of both the sets combined, `set1.union(set2)` | ||
- To find the difference of sets: | ||
|
||
```py | ||
#set1 difference from set2 | ||
set1.difference(set2) | ||
#set2 difference from set 1 | ||
set2.difference(set1) | ||
``` | ||
|
||
![Python data Structures](Python%20Data%20Structures-12.png){: w="650" h="350"} | ||
|
||
- To find is a set is a subset/superset (have all the elements of other set), `set1.issubset/issuperset(set2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
author: [abuturab, admin] | ||
title: "Python Programming Fundamentals" | ||
date: 2023-09-23 08:49:00 +0500 | ||
tags: ['IBM DevOps and SE/Python for Data Science, AI, and Development'] | ||
category: ['My Notes', 'DevOps and Cloud'] | ||
img_path: /assets/notes | ||
image: | ||
path: python-for-ds-ai-and-development.jpeg | ||
alt: 'Image by pressfoto on Freepik' | ||
published: true | ||
--- | ||
|
||
## **Logic Operators: OR** | ||
|
||
![Python Programming Fundamentals](Python%20Programming%20Fundamentals.png){: w="650" h="350"} | ||
|
||
## **Logic Operators: AND** | ||
|
||
![Python Programming Fundamentals](Python%20Programming%20Fundamentals-1.png){: w="650" h="350"} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.