timer1

Fullscreen mode

Just press »F« on your keyboard to show your presentation in fullscreen mode. Press the »ESC« key to exit fullscreen mode.

Overview mode

Press "Esc" or "o" keys to toggle the overview mode on and off. While you're in this mode, you can still navigate between slides, as if you were at 1,000 feet above your presentation.


Python and The Basics of Programming.
Arrays


Lesson 4

Author: Egoshkin Danila Igorevichm

Arrays

Arrays

Variables vs Array

Variables

#include <iostream> 

int main(){
    // Variables
    int myCoolNumber1 = 1; // Variable 1
    int myCoolNumber2 = 2; // Variable 2
    int myCoolNumber3 = 3; // Variable 3
    int myCoolNumber4 = 4; // Variable 4
    int myCoolNumber5 = 5; // Variable 5

    return 0;
}
                        
Array

#include <iostream> 

int main(){
    int myCoolNumbers[5] = {1,2,3,4,5}; // Array

    return 0;
}
                        

Arrays in Python


numbers = [1, 2, 3] // but: it is not a simple array

import array as arr
a = arr.array('i', [1, 2, 3]) # creating an array with integer type

import numpy as np
np.array([1, 2, 3])
array([1, 2, 3])
                        

Data Changing

Variables

#include <iostream> 

int main(){
    // Variables
    int myCoolNumber1 = 1; // Variable 1
    int myCoolNumber2 = 2; // Variable 2
    int myCoolNumber3 = 3; // Variable 3
    int myCoolNumber4 = 4; // Variable 4
    int myCoolNumber5 = 5; // Variable 5

    myCoolNumber3 = 10;

    return 0;
}
                        
Array

#include <iostream> 

int main(){
    int myCoolNumbers[5] = {1,2,3,4,5}; // Array

    myCoolNumbers[2] = 10; // {1,2,10,4,5}

    return 0;
}
                        

Array indexing starts from 0

Data Printing

Variables

#include <iostream> 

int main(){
    // Variables
    int myCoolNumber1 = 1; // Variable 1
    int myCoolNumber2 = 2; // Variable 2
    int myCoolNumber3 = 3; // Variable 3
    int myCoolNumber4 = 4; // Variable 4
    int myCoolNumber5 = 5; // Variable 5

    myCoolNumber3 = 10;

    std::cout << "N1: " << myCoolNumber1 << "\n";
    std::cout << "N2: " << myCoolNumber2 << "\n";
    std::cout << "N3: " << myCoolNumber3 << "\n";
    std::cout << "N4: " << myCoolNumber4 << "\n";
    std::cout << "N5: " << myCoolNumber5 << "\n";
    return 0;
}
                        
Array

#include <iostream> 

int main(){
    int myCoolNumbers[5] = {1,2,3,4,5}; // Array

    myCoolNumbers[2] = 10; // {1,2,10,4,5} - Array indexing starts from 0 

    std::cout << "N1: " << myCoolNumbers[0] << "\n"; // - Array indexing starts from 0 
    std::cout << "N2: " << myCoolNumbers[1] << "\n";
    std::cout << "N3: " << myCoolNumbers[2] << "\n";
    std::cout << "N4: " << myCoolNumbers[3] << "\n";
    std::cout << "N5: " << myCoolNumbers[4] << "\n";

    return 0;
}
                        

Data Printing with FOR

Variables

#include <iostream> 

int main(){
    // Variables
    int myCoolNumber1 = 1; // Variable 1
    int myCoolNumber2 = 2; // Variable 2
    int myCoolNumber3 = 3; // Variable 3
    int myCoolNumber4 = 4; // Variable 4
    int myCoolNumber5 = 5; // Variable 5

    myCoolNumber3 = 10;

    std::cout << "N1: " << myCoolNumber1 << "\n";
    std::cout << "N2: " << myCoolNumber2 << "\n";
    std::cout << "N3: " << myCoolNumber3 << "\n";
    std::cout << "N4: " << myCoolNumber4 << "\n";
    std::cout << "N5: " << myCoolNumber5 << "\n";
    return 0;
}
                        
Array with FOR

#include <iostream> 

int main(){
    int myCoolNumbers[5] = {1,2,3,4,5}; // Array

    myCoolNumbers[2] = 10; // {1,2,10,4,5} - Array indexing starts from 0 

    for(int i = 0; i < 5; i++){
        std::cout << "N" << i+1 << ": " << myCoolNumbers[i] << "\n";
    }

    return 0;
}
                        

Arrays in Python


numbers = [1, 2, 3] # but: it is not a simple array

import array as arr
a = arr.array('i', [1, 2, 3]) # creating an array with integer type

import numpy as np
np.array([1, 2, 3])
array([1, 2, 3])
                        

Indexing and Slicing in Python


numbers = [1, 2, 3, 4, 5, 6, 7, 8] # but: it is not a simple array

print(numbers[0])
print(numbers[1])
print(numbers[2])
                        

Array-list in Python


numbers = [1, 2, 3] # but: it is not a simple array
                        
  • append() - Adds an element at the end of the list
  • clear() - Removes all the elements from the list
  • copy() - Returns a copy of the list
  • count() - Returns the number of elements with the specified value
  • extend() - Add the elements of a list (or any iterable), to the end of the current list
  • index() - Returns the index of the first element with the specified value
  • insert() - Adds an element at the specified position
  • pop() - Removes the element at the specified position
  • remove() - Removes the first item with the specified value
  • reverse() - Reverses the order of the list
  • sort() - Sorts the list

Special Types of Arrays

Special Types of Arrays: 1D, 2D, Jagged Array, 3D, 4D Tensor, QuadTree, OctaTree.

1D

2D


https://en.wikipedia.org/wiki/Confusion_matrix

Jagged Array

???

Jagged Array

Jagged Array

3D

3D, 4D Tensor, QuadTree, OctaTree.
https://en.wikipedia.org/wiki/Christoffel_symbols

Links:

Thanks for your attention :)