🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

Lesson 1 - Computer Concepts and Programming.pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

Republic of the Philippines POLYTECHNIC UNIVERSITY OF THE PHILIPPINES College of Computer and Information Sciences COMP 002 COMPUTER PROGRAMMING 1 Lesson 1- Computer Concepts and Programming Introduction Computers have become an important part of...

Republic of the Philippines POLYTECHNIC UNIVERSITY OF THE PHILIPPINES College of Computer and Information Sciences COMP 002 COMPUTER PROGRAMMING 1 Lesson 1- Computer Concepts and Programming Introduction Computers have become an important part of our life. We use computers for different purposes. As a student, we use computers to search and read learning materials, do assignments, send email, and even attend in an online class. As consumers, we use computers to pay bills, shop online, and order food online. In the university and industry, computers are used to create presentations, conduct business transactions, and communicate with co-workers. We need computers because most of the things that we do, in our personal and professional life, depend on it. But when did computers start? How did they become that powerful? Let's study history. Computers Computer is defined as the device that can store, process data and produces an output. Early computers required too much space but performed few tasks. Analytical Engine The Analytical Engine, invented by Charles Babbage in the 19th century, was designed to perform arithmetic operations. It used punch cards to input data. It was never fully built, but it's often seen as the first mechanical digital computer. Ada Lovelace an English mathematician, collaborated with Babbage and wrote the world's first computer program for the Analytical Engine. She discovered that a machine could follow a programmed sequence of instructions for complex calculations, and predicted its potential to process different types of data, not just numbers. Electronic Numerical Integrator and Computer ENIAC was built at the University of Pennsylvania between 1943 and 1945 by two professors, John Mauchly and J. Presper Eckert. ENIAC was designed to calculate artillery firing tables for the US Army's Ballistic Research Laboratory. Republic of the Philippines POLYTECHNIC UNIVERSITY OF THE PHILIPPINES College of Computer and Information Sciences Artillery Firing Tables: These are charts that help soldiers determine how to aim artillery guns to hit targets accurately, taking into account factors like distance, angle, and wind conditions. Colossus Colossus, the world's first electronic computer, had a single purpose: to help decipher the Lorenz- encrypted (Tunny) messages between Hitler and his generals during World War II.. Atanasoff-Berry Computer The ABC was designed for a specific purpose, the solution of systems of simultaneous linear equations. It could handle systems with up to twenty-nine equations, a difficult problem for the time. Problems of this were becoming common in physics, the department in which John Atanasoff worked. IBM In 1953, the International Business Machine (IBM) made their mark in the computer world. IBM has been a leader in creating mainframe computers used by large organizations for business operations, such as transaction processing and data management. Personal Computer IBM introduced the personal computer (PC) for home and office use. Macintosh Apple introduced Macintosh computer with its icon driven interface. Understanding Computer A computer, in general, must perform four certain tasks: Input, Storage, Processing, and Output. It must input data or information by means of input devices such as keyboard, microphone, mouse, camera. The data should be stored in the memory to be processed by the CPU, and the output can be generated by means of output devices like monitor, printer, and speaker. In a computer, what comes in and goes out is all about data and information. Data and information are represented by binary 1s and 0s, on and off, or true and false. It represents letters, numbers, characters, even graphics, pictures, video and audio using 1s and 0s. Inside the computer system are the memory, processors, and several electronic components that interact together to form a circuit. This circuits make it possible for the computer to perform the general tasks: Input, Store, Processing, and Output data/information. Overview of Computer Architecture Republic of the Philippines POLYTECHNIC UNIVERSITY OF THE PHILIPPINES College of Computer and Information Sciences 1. Hardware vs. Software The computer system consists of hardware and software. Hardware refers to the physical components of a computer system, such as the CPU, RAM, and hard drives. It's the tangible part you can touch and see. Software is the collection of instructions that computers use to process data. This includes the operating system, applications, and the code we write as programmers. 2. Fundamental Components CPU (Central Processing Unit) It's the brain of the computer where most calculations take place. It interprets and executes the instructions in our programs. For the computers to be able to add numbers, allow communication for online meeting, modify images, etc., the instructions must be executed by the CPU. A program in execution is called as process. Running MS Word is a process. Running Zoom is a process. Same with the running web browsers in our computer, those are all processes. Example: When you run a program or open an application, the CPU is at work. RAM (Random Access Memory) It's the computer's short-term memory. All the data that the CPU needs to process is first loaded into RAM because accessing data from RAM is faster than from a hard drive. Example: When you're editing a document, it's loaded into RAM. Once you save, it gets written back to the storage. Storage (e.g., HDD, SSD) The computer’s main memory is too small, and it can only accommodate data mostly from programs and processes. To store data permanently, modern computer system has the secondary storage. This is where data is stored long-term. Applications, documents, and the operating system reside here. Example: The files saved on your desktop or documents folder reside in your storage device. I/O (Input/Output) Devices These are the peripherals like the keyboard, mouse, and monitor. They allow the computer to receive input from users and display output. Republic of the Philippines POLYTECHNIC UNIVERSITY OF THE PHILIPPINES College of Computer and Information Sciences Example: When you type on a keyboard (input) and see the characters appear on your screen (output). 3. Software A software is a set of instructions that tells the computer what to do. Everything that a computer does is under the control of the software. Without software, computer will not be able to serve its purpose. The software has two general categories: System Software and Application Software. System Software System software control and manage the basic operations of a computer. It is also divided into three types: Operating System, Utility Programs, and Software Development Tools. Operating System controls and manages the hardware and other programs in a computer. It manages the CPU, memory, input output devices and even all the other programs running in a computer. Utility Programs perform special tasks that are needed for computers' operation and maintenance. Examples of utility programs are virus scanner, file compression programs, data backup programs. Software Development Tools are the programs that the programmers use to build applications. These are compilers and interpreters. Application Software These are programs that are used by people for their tasks. The application software can be a word processing tool, image editing application, video conferencing platform, etc. A program can be an instruction to perform certain task such as adding numbers, creating and modifying a document, enhancing images, editing videos, tracking your orders, and so much more! 5. Introduction to Computer Programming Programming is the process of creating a set of instructions that tells a computer how to perform a task. At its core, it's a way to solve problems and automate tasks. The first programs were written using low-level machine code directly. These were sequences of 0s and 1s that the computer could understand. This was done on early computers like ENIAC and UNIVAC for basic math operations and data storage. After that, Assembly language were introduced, which was easier for people to read compared to machine code, but still very close to how computers naturally understand instructions. Republic of the Philippines POLYTECHNIC UNIVERSITY OF THE PHILIPPINES College of Computer and Information Sciences Unlike machine code which uses binary numbers, Assembly language uses human-readable text. Each instruction in Assembly language has a name (like ADD for addition, SUB for subtraction), which makes it easier to understand what the code is doing It was used on computers like the IBM 701. Later on, high-level languages like Fortran (1957) for science tasks and COBOL (1959) for business tasks were created to make programming easier and more friendly for people. As time went on, many new languages were created, each with its own special features. For instance C (1972) is flexible. Because it lets programmers to manage memory and organize data freely. C is widely used for system-level programming. It allows direct manipulation of hardware resources (memory, CPU), which is crucial for operating systems, embedded systems, and firmware development. Python (1991) is easy to read. It has a simple and English-like syntax. Hence, Python is great for beginners. It’s also a popular language in academic and industry for data science and AI/ML applications. Java (1995) is portable. It can work on many different computers without needing changes. It can run on different operating systems. It’s popular for enterprise applications and large-scale systems. 6.. Real-world Applications and Use-cases of Computer Programming Websites & Web Apps From information portals like Wikipedia to e-commerce platforms like Amazon. Mobile Apps Programs designed for mobile devices. Examples include WhatsApp for communication and Google Maps for navigation. Games Whether it's PC games like "Fortnite" or mobile games like "Candy Crush," programming brings these virtual worlds to life. Automation Companies use scripts to automate repetitive tasks. For instance, a bank might use a program to process thousands of transactions automatically. Data Analysis & Artificial Intelligence Programs analyze vast amounts of data for insights or drive AI models for tasks like image recognition or language translation. Embedded Systems These are computer systems built into other products, such as the software in microwave ovens or in car engines. Republic of the Philippines POLYTECHNIC UNIVERSITY OF THE PHILIPPINES College of Computer and Information Sciences System Development Life Cycle The System Development Life Cycle (SDLC) is a structured process used to develop software applications in a systematic and efficient manner. It consists of several phases, each with distinct goals and tasks 1. Planning Phase This is the initial stage where the goals and scope of the software project are defined. The costs, timeline, resources, and other requirements are estimated. Feedback from stakeholders, who will use and benefit from the application, is gathered. Example: Create a software system to manage a library's book inventory, member registrations, and book returns. 2. Analysis Phase (also known as Requirement Analysis or Feasibility) The needs of the project are thoroughly analyzed. It's determined what the software should do based on the requirements collected during the planning phase. Example: book tracking, member management, notification system for due dates, etc. 3. Design Phase Plan the software structure. How data will be input, processed, and output. Design the user interface. How users will interact with the system, including the screens they'll use to check out books, register members, and view inventory. Plan for security. Ensure data privacy and system integrity. 4. Development Phase Programmers write the code using a suitable programming language like Java or Python. This is where the actual creation of the software occurs. 5. Testing Phase The software is tested to make sure it works as intended. This phase helps find and fix bugs, ensuring the software functions smoothly. 6. Deployment Phase The software is made available for users. Republic of the Philippines POLYTECHNIC UNIVERSITY OF THE PHILIPPINES College of Computer and Information Sciences It might be installed on users' devices or servers, or released in a controlled or public manner. 7. Maintenance Phase Once the software is being used, it's important to ensure it continues working correctly. This phase involves fixing any new bugs, making updates, and ensuring the software remains secure and effective. The SDLC is essential for managing large software projects to ensure the final product meets the quality and functionality requirements. It's utilized across various fields like healthcare, education, and business to develop applications tailored to meet specific needs and goals Steps in Program Development 1. Analyze Programming Problems Before starting into coding, it's important to understand the problem you're trying to solve. This involves determining the requirements, understanding the inputs and expected outputs, and considering any limitations. Example: Suppose you're developing a system for a library. Analyzing would involve understanding functionalities like book borrowing, returning, tracking overdue books, and member registrations. 2. Design Algorithms An algorithm is a step-by-step procedure to solve a problem. In this phase, you'll decide the approach or method to address the problem. We can use tools like pseudocode or flowcharts to visualize the process. Example: For the library system, designing an algorithm for book borrowing might involve steps like: check if the book is available, check if the member has no overdue books, update the database to show the book as borrowed, etc. 3. Implement Algorithms Here, you'll convert your algorithms into actual code in a chosen programming language. form. Example: Here, you might write functions based on your algorithms, such as borrow_book(member_id, book_id) that will have the coded logic for the borrowing process. 4. Test and Verify Program Once implemented, the program should be tested to ensure it works as expected. This involves running the program with various inputs and checking if the outputs match the expected results. Republic of the Philippines POLYTECHNIC UNIVERSITY OF THE PHILIPPINES College of Computer and Information Sciences Errors and bugs discovered during testing are sent back for re-implementation. Example: For the library system, testing the borrow_book function would involve trying to borrow available books, attempting to borrow already borrowed books, and checking how the system reacts if a member with overdue books tries to borrow. 5. Maintain and Update Program After deployment, a program might need updates due to changing requirements, discovered bugs, or new functionalities. Maintenance ensures the software remains relevant and functional over time. Example: A year after the library system is in place, there might be a need to introduce e-books. The system would then need updates to accommodate this new feature. Algorithm Algorithm is a procedure or set of steps. We use it in doing certain things. It could be the recipe in cooking pork adobo. It could be the steps to get from point A to point B. Algorithm is the steps to accomplish task or achieve something. In computing, algorithm is a set of instructions that solves problem. More often, it takes an input, process it, and produces the desired output. We need to define algorithm when developing a program. Pseudocode The first modeling tool you usually learn is pseudocode. Pseudocode is one method of designing and planning a program. Pseudo means false, means pseudocode is a false code. Because it just imitates the real code, but it is not the real code. It uses English statements to describe what a program will accomplish. The following outline of a simple program illustrates pseudocode. We want to be able to enter the ages of two people and have the computer calculate their average age and display the answer. Example: Input Declare variables number1, number2, and sum. Read values of number1 and number2. Process Add number1 and number2 and assign the result to sum. Republic of the Philippines POLYTECHNIC UNIVERSITY OF THE PHILIPPINES College of Computer and Information Sciences sum = number1 + number2 Output Display sum Flowchart Flowchart is another modeling tool to use to plan and design a program. It is a type of diagram that represents flow of the process. The common symbols of a flowchart consists of terminal, Input/Output, Process, Decision, Flow lines, Connectors. Algorithm 1: Add two numbers entered by the user Input Declare variables number1, number2, and sum. Read values of number1 and number2. Process Add number1 and number2 and assign the result to sum. sum = number1 + number2 Output Display sum Republic of the Philippines POLYTECHNIC UNIVERSITY OF THE PHILIPPINES College of Computer and Information Sciences Algorithm 2: Find the largest number among three numbers: Input Declare variables a, b, and c. Read the values of a, b, and c. Process If a > b: If a > c, then a is the largest number. Else, c is the largest number. Else: If b > c, then b is the largest number. Else, c is the largest number. Output Display the largest number (a, b, or c).

Use Quizgecko on...
Browser
Browser