Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computers and Programming

Similar presentations


Presentation on theme: "Computers and Programming"— Presentation transcript:

1 Computers and Programming
CIS 40 – Introduction to Programming in Python De Anza College Clare Nguyen

2 Intro Welcome to Introduction to Programming in Python.
This course is an introductory tour into the computer programming world, where we learn to write instructions to tell the computer to do a task for us. Just as we could use English when we write instructions for someone to do work, in this class we’ll use a language called Python to write instructions for the computer to do work. Along the way, we’ll get a feel for the kind of work that goes into creating our favorite phone app, or the myPortal system to register for class, or an online sales transaction, etc. In this first module, we will go over what a computer program is, what makes up a computer, and how a computer sees the world.

3 Using the Powerpoint notes
The topics covered in class are in these Powerpoint notes. You can consider them class notes that have been taken for you. It is highly recommended that you view these notes as a slide show so that you can see the video in the notes. After you’ve seen the notes as a slide show, then you can study individual slides when you take the quizzes or do the assignments. Some of the notes have different fonts to highlight them. I try to keep them to a minimum so it’s easy to remember: Vocabulary terms are italicized, you should know the definition of these terms. Example code are in blue, they are valid Python words or code that you could run. Menu selections are in grey, you should look for them when following instructions on how to use a tool.

4 What Is Programming? (1 of 2)
Programming means writing instructions to tell the computer to do a certain task. Programming is a creative and rewarding activity. Programmers enjoy solving problems and seeing tangible results. People write programs for many reasons, from analyzing multi-dimensional data sets to creating an interactive web page to controlling machinery. Computers are all around us daily: laptops and cell phones are obvious ones, but computers are also found in cars, home appliances, and entertainment / personal devices. If you have ever successfully set a ringtone on your phone, or entered an address in a GPS, or set up a game system to play, then you’ve had your first experience in programming. You’ve completed a sequence of steps to tell the computer to do a task.

5 What Is Programming? (2 of 2)
If we were to write the instructions to show someone how to set the ringtone on a phone, it would be similar to this: Go to the phone Settings menu Choose the Sound menu Choose the Ringtones menu Select the ringtone you like Click OK to save the ringtone that you choose The steps above are instructions that we give to our phone, the computer, to perform a task. They are equivalent to a computer program. When someone calls our phone, the phone (the computer) follows our instructions and plays our chosen ringtone. Similar to the “programming” example above, in this class we write instructions that tell the computer to do a specific task, and then we run the program to see the result.

6 Computer Architecture (1 of 2)
Laptops, cell phones, game systems, certain appliances… are all considered computers. So what makes a device a computer? A computer has the following main components that are connected together: Central Processing Unit or CPU: the “brain” of the computer. The CPU runs our instructions to do the task we specify. Memory: stores data and instructions that the CPU uses. Network: connects the computer to the internet. Input / Output or IO Devices: such as keyboard, touch screen, camera, hard drive, sensor, etc. An input device is used to enter data into the computer, such as a mouse being used to select a choice. An output device receives data that are sent out from the computer, such as a screen that displays the result.

7 Computer Architecture (2 of 2)
The following diagram shows the basic hardware components of a computer: We typically use an IO device such as a keyboard to enter our instructions (or our program) into the computer. The computer stores our program and data in memory. When the program runs, the instructions in the program are sent to the CPU, where each instruction is run or executed. As the instructions run, the computer may access the network to communicate with remote servers (other computers). When there are output data, the data are displayed through output devices, sent out on the network, or stored in memory. Central Processing Unit (CPU) Memory IO Devices Network

8 Instruction Cycle When our program runs, each instruction in our program goes through the stages of an instruction cycle: The instruction is fetched from memory It is decoded into a specific CPU operation and associated data The CPU executes or performs the operation on the data The result of the operation is stored The next instruction is fetched from memory It is decoded … The cycle continues until all instructions have run. Fetch Decode Execute Store

9 Click for a video demo of how instructions are executed in a program
Program Execution Click for a video demo of how instructions are executed in a program

10 Data Representation (1 of 2)
As the CPU runs the instructions in our program, some instructions require input data. For example, if the task is to calculate the tip for a restaurant bill, the required data will be the cost of the meal and the percent of tipping rate. Many of the data used in a computer program are numeric data such as a dollar amount or a percent, but some data can be text characters, such as in this Powerpoint slide, or images, such as the pictures we take with our phone. How does the computer handle different kinds of data? The answer is that the computer doesn’t work with different kinds of data. It only works with one kind: numbers. This is straightforward when the data are already numbers, but when data are text characters or images, they are actually also stored as numbers on the computer.

11 Data Representation (2 of 2)
Text characters are translated into numbers by using the ASCII or Unicode standards. Across computer systems, the word “Python” is seen as the sequence: , one number for each letter. Likewise, a digital image is divided into many rows and columns, and each cell is a pixel. Each pixel is one tiny part of the image, and the pixel’s color is stored as 3 numeric values. For example, a dark green pixel has the values ( ) and a light grey pixel has the values ( ). In addition, all the numeric values given above are in base 10, which is the most familiar base for us humans. Computers work with base 2, or binary, because at the most basic level, the computer hardware can only detect 2 states: on or off. Therefore, the computer actually sees the green pixel discussed above as the sequence:

12 What’s Next At this point you may wonder if in class we’ll have to work with numbers such as: The answer is no, fortunately. We’ll be able to work in a much more “human” way: (these base 10 values correspond to the binary values above). To see why we don’t have to “speak” binary to the computer, we’ll continue with module 2.


Download ppt "Computers and Programming"

Similar presentations


Ads by Google