Ch.01-Introduction to Computers and Programming (1) PDF
Document Details
Uploaded by RoomierGlockenspiel1479
2023
Tags
Summary
This presentation provides an introduction to computer hardware and software, focusing on programming with Python. It covers fundamental concepts about computer components, data storage, and program execution. The presentation is organized by chapters with subtopics about Python, computers, and computer programming.
Full Transcript
Introduction to Programming with Python 2023 Chapter 1 Introducing Python 2 What is Python? Python is a powerful, multi- paradigm, interpreted language popular with start- ups and large Co’s. It was created by Guido van Rossum, and first...
Introduction to Programming with Python 2023 Chapter 1 Introducing Python 2 What is Python? Python is a powerful, multi- paradigm, interpreted language popular with start- ups and large Co’s. It was created by Guido van Rossum, and first released in 1991. Two versions, 2 and 3. 3 Why Python? Guido van Rossum defined his goals for Python: An easy and intuitive language just as powerful as those of the major competitors; Code that is as understandable as plain English; Open source, so anyone can contribute to its development; Suitable for everyday tasks, allowing for short development times. Portability, Multi-platform. 4 What is a Computer? Hardware and Software 5 What is a Computer Fundamentally, a machine that can: 1. Perform calculations a billion calculations per second (Ghz). 2. Remember results 100s of gigabytes of storage. (Bit, Byte, Kbyte, MB, GB, Terabyte…etc.). 3. Interface with I/O Devices. Computers only know what you tell them. 6 Computer Main Components 7 Computer Hardware 8 How a Program Works CPUs perform simple operations on pieces of data Examples: reading data, adding, subtracting, multiplying, and dividing numbers Understands instructions written in machine language and included in its instruction set Each brand of CPU has its own instruction set To carry out meaningful calculation, CPU must perform many operations 9 How Computers Store Data All data in a computer is stored in sequences of 0s and 1s Byte: just enough memory to store One letter or small number: Divided into eight bits Bit: electrical component that can hold positive or negative charge, like on/off switch The on/off pattern of bits in a byte represents data stored in the byte 10 Memory & Storage RAM, Random Access Memory, volatile, Load user applications to be executed on CPU. ROM, Read Only Memory, nonvolatile, stores system programs. Secondary Storage e.g. Hard Disks, Store user software applications e.g. Operating System, Office, Chrome Browser…etc. 11 Secondary Storage Devices Secondary storage is a type of memory that can hold data for long periods of time, even when there is no power to the computer. Programs are normally stored in secondary memory and loaded into main memory as needed. Important data, such as word processing documents, payroll data, and inventory records, is saved to secondary storage as well. The most common type of secondary storage device is the disk drive. A traditional disk drive stores data by magnetically encoding it onto a spinning circular disk. 12 Input Devices Input is any data the computer collects from people and from other devices. The component that collects the data and sends it to the computer is called an input device. Common input devices are the keyboard, mouse, touchscreen, scanner, microphone, and digital camera. Disk drives and optical drives can also be considered input devices, because programs and data are retrieved from them and loaded into the computer’s memory. 13 Output Devices Output is any data the computer produces for people or for other devices. It might be a sales report, a list of names, or a graphic image. The data is sent to an output device, which formats and presents it. Common output devices are video displays and printers. Disk drives can also be considered output devices because the system sends data to them in order to be saved. 14 Software 15 Software Everything the computer does is controlled by software General categories: Application software System software Application software: programs that make computer useful for every day tasks Examples: word processing, email, games, and Web browsers 16 Software If a computer is to function, software is not optional. Everything computer does, from the time you turn the power switch on until you shut the system down, is under the control of software. There are two general categories of software: system software and application software. Most computer programs clearly fit into one 17 System Software – Operating System An operating system is the most fundamental set of programs on a computer. The operating system controls the internal operations of the computer’s hardware, manages all of the devices connected to the computer, allows data to be saved to and retrieved from storage devices, and allows other programs to run on the computer. Popular operating systems for laptop and desktop computers include Windows, macOS, and Linux. Popular operating systems for mobile devices include Android and iOS. 18 Operating System 19 Computer Programs & Programming Languages 20 Computer Program 1. A Computer Program is a set of instructions that a programmer write to tell the computer what to do. 2. These instructions are written using a Programming Language. 3. Computer program is written in text using special keywords and syntax. 4. The compiler/Interpreter translates that text into machine code that can be executed by the CPU. 21 Compilers and Interpreters Programs written in high-level languages must be translated into machine language to be executed Compiler: translates high-level language program into separate machine language program Machine language program can be executed at any time Interpreter: translates and executes instructions in high- level language program Used by Python language Interprets one instruction at a time No separate machine language program 22 What does a computer program do? 23 Components of Computer Program 1. Data 2. Instructions 3. Flow of Control a. Conditional Branching b. Repetition and Iteration. c. Function calls. 24 1- Write your Program Define Number A 10 If A > B then Define Number B A 20 Print “A is bigger than B” A = 10 B Else Print “A is not Bigger B = 20 than” If A > B then Compiler - Interpreter Print “A is bigger than B” OS Else 011101001 Print “A is not Bigger than B” 001101010 End If 010010111 001001 25 2- Compile/Interpret your program 26 3- Run Program Program must be copied from secondary memory to RAM each time CPU executes it CPU executes program in cycle: Fetch: read the next instruction from memory into CPU Decode: CPU decodes fetched instruction to determine which operation to perform Execute: perform the operation 27 Run Program 28 High-Level Languages Low-level language: close in nature to machine language Example: assembly language High-Level language: allows simple creation of powerful and complex programs No need to know how CPU works or write large number of instructions More intuitive to understand 29 Python Setup 30 Install Python on Your Machine 1. Download Python from the Internet. You can get the latest version of Python from https://www.python.org/ 2. Install Python on your machine. 31 Introduce Jupyter Notebooks Live Presentation Setup Jupyter Notebook Download Anaconda from the Internet. You can get the latest version individual version from https:// www.anaconda.com/products/individual Install Anaconda on your machine. Open Jupyter from Windows Start Menu. 33 Notebook basic_commands.ipynb 34