Skip to content

Commit

Permalink
add notes for Python for Data Science, AI, and Development
Browse files Browse the repository at this point in the history
  • Loading branch information
abuturabofficial committed Nov 26, 2023
1 parent 30f8a1b commit a527363
Show file tree
Hide file tree
Showing 19 changed files with 162 additions and 2 deletions.
4 changes: 2 additions & 2 deletions _posts/2022-06-21-toc-for-devops-and-cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ published: true

### **7) Python for Data Science, AI, and Development[^8]**

1. [Python Programming Fundamentals]
2. [Python Data Structures]
1. [Python Programming Fundamentals](/posts/python-programming-fundamentals)
2. [Python Data Structures](/posts/python-data-structures)

## References

Expand Down
140 changes: 140 additions & 0 deletions _posts/2023-09-23-python-data-structures.md
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)
20 changes: 20 additions & 0 deletions _posts/2023-09-23-python-programming-fundamentals.md
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"}
Binary file added assets/notes/Python Data Structures-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/notes/Python Data Structures-10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/notes/Python Data Structures-11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/notes/Python Data Structures-12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/notes/Python Data Structures-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/notes/Python Data Structures-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/notes/Python Data Structures-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/notes/Python Data Structures-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/notes/Python Data Structures-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/notes/Python Data Structures-7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/notes/Python Data Structures-8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/notes/Python Data Structures-9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/notes/Python Data Structures.png
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.
Binary file added assets/notes/Python Programming Fundamentals.png
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.

0 comments on commit a527363

Please sign in to comment.