Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs.

Similar presentations


Presentation on theme: "Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs."— Presentation transcript:

1 Programming Introduction November 9 Unit 7

2 What is Programming? Besides being a huge industry? Programming is the process used to write computer programs Computer programs are basically a list of instructions for your computer to execute –Programs are written for some task –As simple as adding up a bunch of numbers –As complicated as your operating system

3 Programming Languages A programming language is a specific way of telling a computer how to do what you want It is a language –Has grammar rules –Key words There are many different programming languages –C–C –C++ –Java –Visual Basic –Lisp –Perl –Python

4 Programming Languages, cont. Programming languages are often created for specific purposes or to solve specific problems There are many different types or families of programming languages In general, all programming languages in the same family share similar properties –Once you know one language it’s easy to learn another

5 Markup Language vs. Programming Language HTML is a markup language Python is a programming language So what’s the difference? –Markup languages are used to create documents –Programming languages are used to create programs –Programs provide instructions for your computer to execute –Markup languages describe documents Programming allows us to add extra functions to our web pages that HTML simply cannot support Programming languages support the use of variables, conditional statements (like “if”), and iterative statements (like “for-each”)

6 Why Learn to Program? Because it’s fun!!! Programming is a challenge But, –Once you know how to program a bit it can be very useful –Not just for computer scientists –Especially useful in the sciences –Sometimes it’s faster to write a program than to do the work by hand Summing up all the numbers in a file

7 So Why Python? Other more well-known languages like C, C++, and Java are more for creating desktop applications –Not very suitable for the Web Python is a high-level language (like C, C++ and Java) Because it’s a high-level language it’s portable –Python runs on most types of computers

8 High vs. Low-Level So what is meant by high-level and low-level languages? High-level languages have to actually be converted into low-level languages in order to be executed Low-level languages are also known as assembly languages or machine languages Low-level languages are not portable –They have to be re-written for each different type of computer High-level languages are more human-readable High-level languages are more widely-used –Low-level is for very specialized tasks like embedded items, microcontrollers,

9 High -> Low-Level Languages High-level languages must be converted into low-level languages in order to be executed Two types of translations: –Using a compiler –Using an interpreter Compilers completely translate your program before executing it –Your program is called source code and the translation the compiler produces is called object code or the executable Interpreters do it a bit at a time –Alternately read and execute your file

10 So What’s it Good for With python, and most languages, we can do quite a lot User input –“enter your name” –“enter a number between 1 and 100” We can output information –“You are over your limit” –“The sum of 2 and 2 is 4”

11 Behind the Scenes Between input and output (if we have input) there is a lot going on “behind the scenes” We can do pretty much any math –Add, subtract, divide, square, etc. We can compare one item to another –Is the password you entered the same password for you login? If you dream it, you can probably program it –With enough lines of code

12 Beginning with Python You should download python –Available from the course website under “course software” –It is available on the ACS computers You can write python in a text editor and save it with the extension “.py” –Or you can use IDLE Integrated DeveLopment Environment for Python Comes with the installation Better choice Lastly, you can type commands directly into the python interpreter –The python interpreter is what you get when run the python program (usually a black window with white text)

13 Hello World The “Hello, world!” program is often the first program anyone writes in a new language It’s tradition, so we’ll start with it too. Writing a program that displays “Hello, world!” is typically the simplest program to write in any language Basically, what we want is for the program to display the output “Hello, world!”

14 “Hello, world!” in Python When you run the interpreter you’ll get something like: “Python 24 (#60, Nov 30, 2004, 11:49:19) Type “help”, “copyright”, “credits”, or “license” for more information >>>” This “>>>” is referred to as the prompt >>>print “Hello, world!”

15 Hello, world in a File We can also put “print ‘Hello, world!’” into a file and run it this way –This is what you will typically be doing Easiest to do in IDLE –In IDLE you’ll get an interpreter window and a window where you can write, edit, and save your python program –In the editing window simply type: print “Hello, world!” –Then you can run the file by pressing F5 ( you will need to also save it) –In the interpreter window you should see Hello, world!

16 Questions? Enjoy your long weekend!


Download ppt "Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs."

Similar presentations


Ads by Google