990 likes | 1.21k Views
Computers . Software. Acknowledgments. Thanks to the following web site for the images used in this presentation:. Wikipedia http://microsoft.toddverbeek.com http://www.webopedia.com http://www.engin.umd.umich.edu/ http://www.dell.com http://www.intel.com http://www.apple.com
E N D
Computers Software
Acknowledgments Thanks to the following web site for the images used in this presentation: • Wikipedia • http://microsoft.toddverbeek.com • http://www.webopedia.com • http://www.engin.umd.umich.edu/ • http://www.dell.com • http://www.intel.com • http://www.apple.com • http://www.ibm.com • http://homepages.feis.herts.ac.uk/~msc_ice/unit2/ • http://www.howstuffworks.com
Computer Layers Hardware BIOS Operating System Software Programming languages
BIOS: Basic Input/Output Layer • BIOS refers to the firmware code usually stored on the PROM, EPROM or flash drive that is run by a computer when first powered on. • BIOS performs three major tasks: • First, the Power On Self Tests (POST) are conducted. These tests verify that the hardware system is operating correctly. • - Second, the BIOS initiates the different hardware component of the system, scanning their own ROM or PROM. • - Third, the BIOS initiate the boot process. The BIOS looks for boot information that is contained in file called the master boot record (MBR) at the first sector on the disk. Once an acceptable boot record is found the operating system is loaded which takes over control of the computer.
Computer Layers Hardware BIOS Operating System Software Programming languages
The operating system Definition found on Wikipedia: “An operating system (OS) is the software that manages the sharing of the resources of a computer and provides programmers with an interface used to access those resources” Most common operating systems: - DOS (desktops, laptops) - Unix and variants, including Linux (servers) - MacOS
The operating system • Operating systems can be classified as follows: • multi-user : Allows two or more users to run programs at the same time. • -multiprocessing : Supports running a program on more than one CPU. • -multitasking : Allows more than one program to run concurrently. • multithreading : Allows different parts of a single program to run concurrently.
The operating system Memory management: Current computers organize memory resources hierarchically, from registers, CPU cache, RAM and disks. The virtual memory manager coordinates the use of these resources by tracking which one is available, which is to be allocated or deallocated and how to move data between them. If running processes require significantly more RAM than is available, the system may start thrashing.
The operating system Most operating systems come with an application that provides a user interface for managing the operating system, such as a command line interpreter or graphical user interface (GUI). Operating systems provide a software platform on top of which other programs, called application programs, can run. Your choice of operating system determines the applications you can run.
Computer Layers Hardware BIOS Operating System Software Programming languages
Application Software Application software is a class of computer software that uses the capabilities of a computer to a task that the user wishes to perform. The term application refers to both the application software and its implementation. Typical examples of software applications are word processors, spreadsheets, and media players.
Computer Layers Hardware BIOS Operating System Software Programming languages
Programming languages A programming language is an artificial language that can be used to control the behavior of a machine, particularly a computer. Programming languages are used to facilitate communication about the task of organizing and manipulatinginformation, and to express algorithms precisely. (An algorithm is a list of well-defined instructions for completing a task; that is, given an initial state, it will proceed through a well-defined series of successive states, eventually terminating in an end-state. The transition from one state to the next is not necessarily deterministic; some algorithms, known as probabilistic algorithms, incorporate randomness)
Programming languages There are many, many programming languages, and new ones appear every year. (http://www.engin.umd.umich.edu/CIS/course.des/cis400/)
Hardware Machine Languages Assembly Languages High level Languages Programming languages • Three main levels of programming languages: • Machine languages: refers to the "ones and zeroes" that processors use as instructions. Give it one pattern of bits (such as 11001001) and it will add two numbers, give it a different pattern (11001010) and it will instead subtract one from the other. • Assembly languages: is as close as you can come to writing in machine language, but has the advantage that it's also human-readable... using a small vocabulary of words with one syllable, such as: • MOV A, B -High level languages:A vocabulary and set of grammatical rules for instructing a computer to perform specific tasks. Each language has its own set of keywords and its own syntax.
Programming languages: Interpret or Compile? • Regardless of what language you use, you eventually need to convert your program into machine language so that the computer can understand it. There are two ways to do this: • interpret the program through an interpreter • compile the program througha compiler The main disadvantage of interpreters is that when a program is interpreted, it runs slower than if it had been compiled.
Programming languages: Interpreters • An interpreter is a program that either: • - executes the source code directly (type I) • translates source code into some efficient intermediate representation and immediately executes this (type II) • - is invoked to explicitly execute stored precompiled code made by a compiler which is part of the interpreter system (type III)
Programming languages: Compilers Source Code Source Code Source Code Source Code Compile Object File Object File Object File Object File Runtime Library Executable Program Link
Programming languages: Compilers A compiler is a program that translatessource codes into object codes. The compiler derives its name from the way it works, looking at the entire source code and collecting and reorganizing the instructions. Thus, a compiler differs from an interpreter, which analyzes and executes each line of source code successively, without analyzing the entire program.
Programming languages: Examples Interpreted languages: - Perl, Python, Matlab (type II) - Java (type III) Compiled languages: - Fortran - C, C++ - Pascal - Basic - Cobol - ADA
Python • Writing readable code is easy • Natural syntax to commands • Indentation-consciousness forces readability • Reusing code is easy • PYTHONPATH/import are easy to use • Object-oriented programming is easy • Finally understand what all the C++/Scheme programmers are talking about!
# Game Over # Demonstrates the print command print "Game Over" raw_input("\n\nPress the enter key to exit.")
# Game Over - Version 2 # Demonstrates the use of quotes in strings print "Program 'Game Over' 2.0” print \ "”” _____ ___ ___ ___ _____ / ___| / | / |/ | | ___| | | / /| | / /| /| | | |__ | | _ / ___ | / / |__/ | | | __| | |_| | / / | | / / | | | |___ \_____/ /_/ |_| /_/ |_| |_____| _____ _ _ _____ _____ / _ \ | | / / | ___| | _ \ | | | | | | / / | |__ | |_| | | | | | | | / / | __| | _ / | |_| | | |/ / | |___ | | \ \ \_____/ |___/ |_____| |_| \_\ ""” raw_input("\n\nPress the enter key to exit.") Triple Quoted String!
# Fancy Credits # Demonstrates escape sequences # sound the system bell print "\a” print "\t\t\tFancy Credits” print "\t\t\t \\ \\ \\ \\ \\ \\ \\” print "\t\t\t\tby” print "\t\t\tMichael Dawson” print "\t\t\t \\ \\ \\ \\ \\ \\ \\” print "\nSpecial thanks goes out to:” print "My hair stylist, Henry \'The Great\', who never says \"can\'t\".” raw_input("\n\nPress the enter key to exit.")
\\ \’ \” \a \b \n \t
# Silly Strings # Demonstrates string concatenation and repetition print "You can concatenate two " + "strings with the '+' operator.” print "\nThis string " + "may not " + "seem terr" + "ibly impressive. " \ + "But what " + "you don't know," + " is that " + "it's one real" \ + "l" + "y" + " long string, created from the concatenation " \ + "of " + "thirty-two " + "different strings, broken across " \ + "nine lines." + " Now are you" + " impressed?\n\n" + "See, " \ + "even newlines can be embedded into a single string, making" \ + " it look " + "as " + "if " + "it" + "'s " + "got " + "to " \ + "be" + " multiple strings." + " Okay, now this " + "one " \ + "long" + " string is over!” print \ ""” If you really like a string, you can repeat it. For example, who doesn't like pie? That's right, nobody. But if you really like it, you should say it like you mean it:""", print "Pie" * 10 print "\nNow that's good eating.” raw_input("\n\nPress the enter key to exit.")
# Word Problems # Demonstrates numbers and math print \ "”” If a pregnant hippo, weighing 2,000 pounds, gives birth to a 100 pound calf, but then eats 50 pounds of food, how much does she weigh?"”” raw_input("Press the enter key to find out.”) print "2000 - 100 + 50 = ”, print 2000 - 100 + 50 print \ "”” If an adventurer returns from a successful quest and buys each of 6 companions 3 bottles of ale, how many bottles does the adventurer buy?"”” raw_input("Press the enter key to find out.”) print "6 * 3 = ”, print 6 * 3 print \ "”” If a kid has 24 pieces of Halloween candy and eats 6 pieces a day, how many days will the stash last?"”” raw_input("Press the enter key to find out.") print "24 / 6 = ”, print 24 / 6 print \ "”” If a group of 4 pirates finds a chest full of 107 gold coins, and they divide the booty evenly, how many coins will be left over?"”” raw_input("Press the enter key to find out.”) print "107 % 4 = ”, print 107 % 4 print \ "”” If a restaurant check comes to 19 dollars with tip, and you and your friends split it evenly 4 ways, how much do you each throw in?"”” raw_input("Press the enter key to find out.”) print "19 / 4 = ”, print 19 / 4 print "WRONG!” raw_input("Press the enter key for the right answer.”) print 19.0 / 4 raw_input("\n\nPress the enter key to exit.")
Variables!!! # Greeter # Demonstrates the use of a variable name = "Larry” print name print "Hi, " + name raw_input("\n\nPress the enter key to exit.")
Variables!!! # Greeter # Demonstrates the use of a variable name = raw_input("Hi. What's your name? ") print name print "Hi, " + name raw_input("\n\nPress the enter key to exit.")
# Quotation Manipulation # Demonstrates string methods # quote from IBM Chairman, Thomas Watson, in 1943 quote = "I think there is a world market for maybe five computers.” print "Original quote:” print quote print "\nIn uppercase:” print quote.upper() print "\nIn lowercase:” print quote.lower() print "\nAs a title:” print quote.title() print "\nWith a minor replacement:” print quote.replace("five", "millions of") print "\nOriginal quote is still:” print quote raw_input("\n\nPress the enter key to exit.")
# Trust Fund Buddy - Bad # Demonstrates a logical error print \ ""” Trust Fund Buddy Totals your monthly spending so that your trust fund doesn't run out (and you're forced to get a real job). Please enter the requested, monthly costs. Since you're rich, ignore pennies and use only dollar amounts. "”” car = raw_input("Lamborghini Tune-Ups: ”) rent = raw_input("Manhattan Apartment: ") jet = raw_input("Private Jet Rental: ") gifts = raw_input("Gifts: ") food = raw_input("Dining Out: ") staff = raw_input("Staff (butlers, chef, driver, assistant): ") guru = raw_input("Personal Guru and Coach: ") games = raw_input("Computer Games: ") total = car + rent + jet + gifts + food + staff + guru + games print "\nGrand Total: " + total raw_input("\n\nPress the enter key to exit.")
float(x) float(“10.0”) 10.0 int(x) int(“10”) 10 str(x) str(10) “10”
car = raw_input("Lamborghini Tune-Ups: ") car = int(car) rent = int(raw_input("Manhattan Apartment: ")) jet = int(raw_input("Private Jet Rental: ")) gifts = int(raw_input("Gifts: ")) food = int(raw_input("Dining Out: ")) staff = int(raw_input("Staff (butlers, chef, driver, assistant): ")) guru = int(raw_input("Personal Guru and Coach: ") ) games = int(raw_input("Computer Games: ")) total = car + rent + jet + gifts + food + staff + guru + games print "\nGrand Total: ", total Car raw_input(…) Variable/Memory Location func(…)
X = X + 5 Assignment X += 5 X: a value Memory box & Assignment X X+5 X: old value + 5
ADD X, X, const(5) Add 848, 440, 820 ADD X, X, const(5) X . X: a value Memory box & Assignment X X+5 X: old value + 5
*= multiplication x = X *5 /= division x = X/5 %= modulus 7 modulus 2 == 1 += addition -= substraction
# Craps Roller # Demonstrates random number generation import random # generate random numbers 1 - 6 die1 =random.randrange(6) + 1 die2 = random.randrange(6) + 1 total = die1 + die2 print "You rolled a", die1, "and a", die2, "for a total of", total raw_input("\n\nPress the enter key to exit.") quote.upper();
# Craps Roller # Demonstrates random number generation import random # generate random numbers 1 - 6 die1 =random.randrange(6) + 1 die2 = random.randrange(6) + 1 total = die1 + die2 print "You rolled a", die1, "and a", die2, "for a total of", total raw_input("\n\nPress the enter key to exit.") Print the total if it is greater than 10!
statement Flow chart decision Output end
print "Welcome to System Security Inc." print "-- where security is our middle name\n" password = raw_input("Enter your password: ") ifpassword == "secret": print "Access Granted" raw_input("\n\nPress the enter key to exit.")
Raw_input Password Password == “secret” F T “access denied” “access granted” end
decision F T
decision F T if <proposition> : <statement> <statement> (optional) else: <statement> <statement> (optional) <other statements>
Propositions in Python 5 == 5 equal 8 != 5 not equal 3 > 10 5 < 8 5 >= 10 5 <= 5
# Maitre D' # Demonstrates treating a value as a condition print "Welcome to the Chateau D' Food" print "It seems we are quite full this evening.\n" money = int(raw_input("How many dollars do you slip the Maitre D'? ")) if money: print "Ah, I am reminded of a table. Right this way." else: print "Please, sit. It may be a while." raw_input("\n\nPress the enter key to exit.")
decision F T if <proposition> : <statement> <statement> (optional) elseif <proposition>: <statement> <statement> (optional) … else: <statement> <statement> (optional) <other statements> decision