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.
Basic Data Types


Lesson 1

Author: Egoshkin Danila Igorevich

Basic Data Types

In the beginning was the ****

In the beginning was the Word
- Bible

In the beginning - people started to speak.

Then...???

So we need some types to count:


                            int number = 5; // Counting on fingers
                            float numberPi = 3.14f; // With FLOATing point ****.******
                            double bigNumberPi = 3.1415926535 8979323846 2643383279 ...;
                        

What next...???

Writing:


                            char ch = 'A'; // Only one charachter
                            char ch_srt[100] = "Hello 1"; // 100 charachters
                        

Logic:


                            bool isAlive {true};
                            bool isDead {false};
                            std::cout << "isAlive: " << isAlive << "\n"; 
                            std::cout << "isDead: " << isDead << "\n"; 
                        

That is all Folks!

But wait... What about pictures, music, etc

ANSI Image

Image by color palette

Image by RGB (Read, Green, Blue)

RAM memory

С++

                            int x = 5;
                            cout << "sizeof(x) = " << sizeof(int) << " bytes" << endl; // 4 bytes
                            cout << "sizeof(x) = " << sizeof(x) << " bytes" << endl; // 4 bytes
                        
С#

                            using System.Runtime.InteropServices;

                            int x = 5;
                            Console.WriteLine("sizeof(x) = " + sizeof(int));
                            Console.WriteLine(System.Runtime.InteropServices.Marshal.SizeOf(x));
                            Console.WriteLine(Marshal.SizeOf(x)); // using System.Runtime.InteropServices;
                        
Python

                            import sys
                            x = int(5);
                            print(sys.getsizeof(x))
                            # 28 bytes
                            print(sys.getsizeof('this'))
                            # 38
                            print(sys.getsizeof('this also'))
                            # 48
                        

Static typing vs Dynamic typing

Static typing C++


                                int number = 5;
                                float numberPi = 3.14;
                                char ch = 'A';
                                string str = "Hello"
                                
                            

Dynamic typing


                            number = 5;
                            numberPi = 3.14;
                            ch = 'A';
                            str = "Hello"

                        
C++
                        #include <typeinfo>
                        //...    
                        cout << "typeid(100).name() = " << typeid(100).name() << endl;
                        cout << "typeid(string).name() = " << typeid("string").name() << endl;
                        cout << "typeid('A').name() = " << typeid('A').name() << endl;
                        
C#
                        int number = 5;
                        Console.WriteLine(number.GetType());
                        string str = "Hello World!";
                        Console.WriteLine(str.GetType());
                        float[] array = {1.5f, 2.5f, 3.5f};
                        Console.WriteLine(array.GetType());
                    
Python
                        print(type('string'))   # <class 'str'>
                        print(type(100))        # <class 'int'>
                        print(type([0, 1, 2]))  # <class 'list'>
                        

What next after data types?

Base IO - Input\Output

Terminal vs Console - difference???

Base IO - Input\Output

C++
                        std::cout << "Enter something: ";
                            /**/
                            char input1[100];
                            cin >> input1;
                            cout << input1 << endl;
                            /**/
                            /**/
                            char input2[100];
                            cin.getline(input2, sizeof(input2));
                            cout << input2 << endl;
                            /**/
                            /**/
                            string input3;
                            std::getline(std::cin, input3);
                            cout << input3 << endl;
                            /**/
                        

Base IO - Input\Output

Python
                        input=input('Enter a something: ')
                            print('You Entered:', input)
                            print('Data type of input', type(input))
                            // number++                            
                        

Format IO - Input\Output

C++
(work only with ISO C++ 20 (/std:c++20))
                        #include <format>
                        #include <iomanip>
                            
                        std::cout << std::format("name = {:.7}.", "Smith Will"); 
                        

Format IO - Input\Output

Python
                        
                            text1 = "Flawless"
                            text2 = "Supercalifragilisticexpialidocious"
                            print(text1 + " and " + text2)
                            print(text1, "and", text2) # C++ << ... << ... <<
                            print('{1} and {0}'.format(text1, text2)) # C#
                            print(f 'Some text: {text1} {text2}') # Shell
                            
                            print("Decimal(int) : %2d, Portal : %5.2f" % (1, 05.333)) # C printf("%X", ...);
                            print("Total students : %3d, Boys : %2d, Girls : %2d" % (240, 120, 120))   # print integer value
                            print("%7.3o" % (25))   # print octal value
                            print("%10.3E" % (356.08977))   # print exponential value
                        

Links:

Python: Other languages:
Thanks for your attention :)