Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computers Software.

Similar presentations


Presentation on theme: "Computers Software."— Presentation transcript:

1 Computers Software

2 Acknowledgments Thanks to the following web site for the images used in this presentation: Wikipedia

3 Computer Layers Hardware BIOS Operating System Software
Programming languages

4 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.

5 Computer Layers Hardware BIOS Operating System Software
Programming languages

6 The operating system

7 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

8 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.

9 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.

10 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.

11 Computer Layers Hardware BIOS Operating System Software
Programming languages

12 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.

13 Computer Layers Hardware BIOS Operating System Software
Programming languages

14 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 manipulating information, 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)

15 Programming languages
There are many, many programming languages, and new ones appear every year. (

16 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 ) and it will add two numbers, give it a different pattern ( ) 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 Assembly Languages Machine Languages Hardware -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.

17 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 through a compiler The main disadvantage of interpreters is that when a program is interpreted, it runs slower than if it had been compiled.

18 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)

19 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

20 Programming languages: Compilers
A compiler is a program that translates source 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.

21 Programming languages: Examples
Interpreted languages: - Perl, Python, Matlab (type II) - Java (type III) Compiled languages: - Fortran - C, C++ - Pascal - Basic - Cobol - ADA

22 Python Writing readable code is easy Reusing 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!

23 # Game Over # Demonstrates the print command print "Game Over" raw_input("\n\nPress the enter key to exit.")

24 Triple Quoted String! # 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!

25 # 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 "\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.")

26 \\ \’ \” \a \b \n \t

27 # 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.")

28 # 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 " = ”, 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?"”” print "6 * 3 = ”, print 6 * 3 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 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?"”” print "107 % 4 = ”, print 107 % 4 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?"”” 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.")

29 How to use Python?

30 Variables!!! # Greeter # Demonstrates the use of a variable name = "Larry” print name print "Hi, " + name raw_input("\n\nPress the enter key to exit.")

31 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.")

32 # 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:” raw_input("\n\nPress the enter key to exit.")

33 # 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.")

34 What’s wrong?

35 float(x) float(“10.0”) int(x) int(“10”) str(x) str(10) “10”

36 Variable/Memory Location func(…)
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(…)

37 X = X + 5 Assignment X += 5 X: a value Memory box & Assignment X  X+5 X: old value + 5

38 Add 848, 440, 820 X: a value Memory box & X  X+5 Assignment X:
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

39 *= multiplication x = X *5
/= division x = X/5 %= modulus modulus 2 == 1 += addition -= substraction

40 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.") quote.upper();

41 Print the total if it is greater than 10!
# 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!

42 statement Flow chart decision Output end

43 print "Welcome to System Security Inc."
print "-- where security is our middle name\n" password = raw_input("Enter your password: ") if password == "secret": print "Access Granted" raw_input("\n\nPress the enter key to exit.")

44 Password  Raw_input F T “access “access denied” granted”
Password == “secret” F T “access denied” “access granted” end

45 decision F T

46 decision F T if <proposition> : <statement> <statement> (optional) else: <other statements>

47 Propositions in Python
5 == equal 8 != not equal 3 > 10 5 < 8 5 >= 10 5 <= 5

48 # 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.")

49 end

50 decision F T if <proposition> : <statement> <statement> (optional) elseif <proposition>: else: <other statements> decision

51 “????????” raw_input # Three Year-Old Simulator
# Demonstrates the while loop print "\tWelcome to the 'Three-Year-Old Simulator'\n" print "This program simulates a conversation with a three-year-old child." print "Try to stop the madness.\n" response = "" while response != "Because.": response = raw_input("Why?\n") print "Oh. Okay." raw_input("\n\nPress the enter key to exit.") “????????” raw_input

52 Variable name: response
A bunch of memory cells (bytes) “????????” raw_input 4 bytes:

53 end

54 while <proposition> : <statement>
F T while <proposition> : <statement> <statement> (optional) <other statements>

55 Modify this program to give more chances..
print "Welcome to System Security Inc." print "-- where security is our middle name\n" password = “” count = 0 while (password != “secret”) & (count <= 3): print "Access Denied” count = count + 1 password = raw_input("Enter your password: ") If … print "Access Granted” raw_input("\n\nPress the enter key to exit.") Modify this program to give more chances..

56 # Password # Demonstrates the if structure print "Welcome to System Security Inc." print "-- where security is our middle name\n” password = raw_input("Enter your password: ") numberOfTry = 1; while (password.lower() != "secret") & (numberOfTry < 3): print "Access Denied -- tried ", numberOfTry, " times." password = raw_input("Enter your password: ") numberOfTry = numberOfTry + 1; if password.lower() != "secret": print "Access Denied after ", numberOfTry, " times." else: print "Access Granted" raw_input("\n\nPress the enter key to exit.")

57 # Password # Demonstrates the if structure print "Welcome to System Security Inc." print "-- where security is our middle name\n” password = raw_input("Enter your password: ") numberOfTry = 1; while (password.lower() != "secret") & (password.lower() != “secret2”) & (numberOfTry < 3): print "Access Denied -- tried ", numberOfTry, " times." password = raw_input("Enter your password: ") numberOfTry = numberOfTry + 1; if password.lower() != "secret": print "Access Denied after ", numberOfTry, " times." else: print "Access Granted" raw_input("\n\nPress the enter key to exit.")

58 print "\tExclusive Computer Network"
print "\t\tMembers only!\n" security = 0 username = "" while not username: username = raw_input("Username: ") password = "" while not password: password = raw_input("Password: ") if username == "M.Dawson" and password == "secret": print "Hi, Mike." security = 5 elif username == "S.Meier" and password == "civilization": print "Hey, Sid." security = 3 elif username == "S.Miyamoto" and password == "mariobros":

59 Counting While loop For loop

60 # Counter # Demonstrates the range() function print "Counting:” I = 10 While I > 0: print I, I = I – 1 for i in range(10): print i, print "\n\nCounting by fives:" for i in range(0, 50, 5): print "\n\nCounting backwards:" for i in range(10, 0, -1): raw_input("\n\nPress the enter key to exit.\n")

61 end

62 # Loopy String # Demonstrates the for loop with a string word = raw_input("Enter a word: ") print "\nHere's each letter in your word:" for letter in word: print letter raw_input("\n\nPress the enter key to exit.")

63 for <index_variable> in <index control>: <statement>
<statement> (optional) <other statements>

64 for <integer_variable> in range (start, end, skip):
Index Control F T for <integer_variable> in range (start, end, skip): <statement> <statement> (optional) <other statements>

65 Use For Loop!!! # Password # Demonstrates the if structure print "Welcome to System Security Inc." print "-- where security is our middle name\n” password = raw_input("Enter your password: ") numberOfTry = 1; while (password.lower() != "secret") & (numberOfTry < 3): print "Access Denied -- tried ", numberOfTry, " times." password = raw_input("Enter your password: ") numberOfTry = numberOfTry + 1; if (pass… == “secret”): break if password.lower() != "secret": print "Access Denied after ", numberOfTry, " times." else: print "Access Granted" raw_input("\n\nPress the enter key to exit.")

66 for <index_variable> in <index control>: <statement>
<statement> (optional) <other statements>

67 # Password # Demonstrates the if structure print "Welcome to System Security Inc." print "-- where security is our middle name\n" for i in range(0,3,1): password = raw_input("Enter your password: ") if password.lower() == "secret": print "Access Granted" break print "Access Denied -- tried ", (i+1), " times." raw_input("\n\nPress the enter key to exit.")

68 # Random Access # Demonstrates string indexing import random word = ”pizza" print "The word is: ", word, "\n" high = len(word) low = -len(word) for i in range(10): position = random.randrange(low, high) print "word[", position, "]\t", word[position] raw_input("\n\nPress the enter key to exit.")

69 1 2 3 4 P i z z a -5 -4 -3 -2 -1

70 print "Enter the beginning and ending index for your slice of 'pizza'
print "Press the enter key at 'Begin' to exit." begin = None while begin != "": begin = (raw_input("\nBegin: ")) if begin: begin = int(begin) end = int(raw_input("End: ")) print "word[", begin, ":", end, "]\t\t", print word[begin:end] raw_input("\n\nPress the enter key to exit.")

71 # create a tuple with some items
inventory = ("sword", "armor", "shield", "healing potion") # print the tuple print "\nThe tuple inventory is:\n", inventory # print each element in the tuple print "\nYour items:" for item in inventory: print item if “UCDavis” in item: print “Google “, item GoogleList += item GoogleList.sort()

72 Sharing: You should know bla bla bla bye Target

73 # create a LIST with some items
inventory = ["sword", "armor", "shield", "healing potion”] # print the LIST print "\nThe LIST inventory is:\n", inventory # print each element in the LIST print "\nYour items:" for item in inventory: print item

74 # get the length of a tuple
print "You have", len(inventory), "items.” # test for membership with in if "healing potion" in inventory: print "You will live to fight another day." # display one item through an index index = int(raw_input("\nEnter the index number: ")) print "At index", index, "is", inventory[index] # display a slice begin = int(raw_input("\nEnter begin of a slice: ")) end = int(raw_input("Enter end of the slice: ")) print "inventory[", begin, ":", end, "]\t\t", print inventory[begin:end] inventory[1:3] inventory = inventory + chest

75 The usage of “in” if "e" in message: # Message Analyzer
# Demonstrates the len() function and the in operator message = raw_input("Enter a message: ") print "\nThe length of your message is:", len(message) print "\nThe most common letter in the English language, 'e',", if "e" in message: print "is in your message." else: print "is not in your message." raw_input("\n\nPress the enter key to exit.”)

76 The usage of “in” if ”the" in message: # Message Analyzer
# Demonstrates the len() function and the in operator message = raw_input("Enter a message: ") print "\nThe length of your message is:", len(message) print "\nThe most common letter in the English language, 'e',", if ”the" in message: print "is in your message." else: print "is not in your message." raw_input("\n\nPress the enter key to exit.”)

77 # create a tuple with some items
inventory = ("sword", "armor", "shield", "healing potion") # print the tuple print "\nThe tuple inventory is:\n", inventory # print each element in the tuple print "\nYour items:" for i in range(0, len(inventory), 1): print inventory[i]

78 import random # create a sequence of words to choose from WORDS = ("python", "jumble", "easy", "difficult”) # pick one word randomly from the sequence word = random.choice(WORDS) correct = word # create a jumbled version of the word jumble ="" while word: position = random.randrange(len(word)) jumble += word[position] word = word[:position] + word[(position + 1):] 1 2 3 4 P i z z a

79 # create a LIST with some items
inventory = ["sword", "armor", "shield", "healing potion”] # print the LIST print "\nThe LIST inventory is:\n", inventory # print each element in the LIST print "\nYour items:" for item in inventory: print item inventory[2] = “golden spear”

80 Dictionary # Geek Translator # Demonstrates using dictionaries
geek = {"404": "clueless. From the web error message 404, meaning page not found.", "Googling": "searching the Internet for background information on a person.", "Keyboard Plaque" : "the collection of debris found in computer keyboards.", "Link Rot" : "the process by which web page links become obsolete.", "Percussive Maintenance" : "the act of striking an electronic device to make it work.", "Uninstalled" : "being fired. Especially popular during the dot-bomb era."} # Geek Translator # Demonstrates using dictionaries geek = {"404": "clueless. From the web error message 404, meaning page not found.", "Googling": "searching the Internet for background information on a person.", "Keyboard Plaque" : "the collection of debris found in computer keyboards.", "Link Rot" : "the process by which web page links become obsolete.", "Percussive Maintenance" : "the act of striking an electronic device to make it work.", "Uninstalled" : "being fired. Especially popular during the dot-bomb era."}

81 Dictionary DictID = { <key> : <object>, …} <object>
Integer/float/string, list/tuple/dictionary,… {“myDeck” : (“2S”, “3S”,…), “myScore” : 4, “myContract” : “3NT”,…} DictID[<key>] DictID[“myDeck”]

82 term = raw_input("What term do you want me to translate
term = raw_input("What term do you want me to translate?: ") if term in geek: definition = geek[term] print "\n", term, "means", definition else: print "\nSorry, I don't know", term

83 term = raw_input("What term do you want me to add
term = raw_input("What term do you want me to add?: ") if term not in geek: definition = raw_input("\nWhat's the definition?: ") geek[term] = definition print "\n", term, "has been added.” else: print "\nThat term already exists! Try redefining it."

84 term = raw_input("What term do you want me to redefine?: ")
if term in geek: definition = raw_input("What's the new definition?: ") geek[term] = definition print "\n", term, "has been redefined.” else: print "\nThat term doesn't exist! Try adding it.”

85 term = raw_input("What term do you want me to delete?: ”)
if term in geek: del geek[term] print "\nOkay, I deleted", term else: print "\nI can't do that!", term, "doesn't exist in the dictionary.”

86 def ask_yes_no(question):
"""Ask a yes or no question.""" response = None while response not in ("y", "n"): response = raw_input(question).lower() return response

87 # create a tuple with some items
inventory = ("sword", "armor", "shield", "healing potion") # print the tuple print "\nThe tuple inventory is:\n", inventory # print each element in the tuple print "\nYour items:" for i in range(0, len(inventory), 1): print inventory[i]

88 # create a tuple with some items
inventory = ("sword", "armor", "shield", "healing potion") # print the tuple print "\nThe tuple inventory is:\n", inventory # print each element in the tuple print "\nYour items:" for i in range(0, len(inventory), 1): print inventory[i]

89 # create a tuple with some items
inventory = ("sword", "armor", "shield", "healing potion") # print the tuple print "\nThe tuple inventory is:\n", inventory # print each element in the tuple print "\nYour items:" for i in range(0, len(inventory), 1): print inventory[i]

90 # create a tuple with some items
inventory = ("sword", "armor", "shield", "healing potion") # print the tuple print "\nThe tuple inventory is:\n", inventory # print each element in the tuple print "\nYour items:" for i in range(0, len(inventory), 1): print inventory[i]

91 # create a tuple with some items
inventory = ("sword", "armor", "shield", "healing potion") # print the tuple print "\nThe tuple inventory is:\n", inventory # print each element in the tuple print "\nYour items:" for i in range(0, len(inventory), 1): print inventory[i]

92

93

94 end

95 end

96

97

98


Download ppt "Computers Software."

Similar presentations


Ads by Google