computers n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Computers PowerPoint Presentation
Download Presentation
Computers

Loading in 2 Seconds...

play fullscreen
1 / 98

Computers - PowerPoint PPT Presentation


  • 177 Views
  • Uploaded on

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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Computers' - bianca


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
computers

Computers

Software

slide2

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
slide3

Computer Layers

Hardware

BIOS

Operating System

Software

Programming languages

slide4

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

Computer Layers

Hardware

BIOS

Operating System

Software

Programming languages

slide7

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

slide8

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

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.

slide10

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.

slide11

Computer Layers

Hardware

BIOS

Operating System

Software

Programming languages

slide12

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.

slide13

Computer Layers

Hardware

BIOS

Operating System

Software

Programming languages

slide14

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)

slide15

Programming languages

There are many, many programming languages, and new ones

appear every year.

(http://www.engin.umd.umich.edu/CIS/course.des/cis400/)

slide16

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.

slide17

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.

slide18

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

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

slide20

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.

slide21

Programming languages: Examples

Interpreted languages:

- Perl, Python, Matlab (type II)

- Java (type III)

Compiled languages:

- Fortran

- C, C++

- Pascal

- Basic

- Cobol

- ADA

python
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!
slide23

# Game Over

# Demonstrates the print command

print "Game Over"

raw_input("\n\nPress the enter key to exit.")

slide24

# 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!

slide25

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

slide26

\\

\’

\”

\a

\b

\n

\t

slide27

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

slide28

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

slide30

Variables!!!

# Greeter

# Demonstrates the use of a variable

name = "Larry”

print name

print "Hi, " + name

raw_input("\n\nPress the enter key to exit.")

slide31

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

slide32

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

slide33

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

slide35

float(x) float(“10.0”) 10.0

int(x) int(“10”) 10

str(x) str(10) “10”

slide36

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(…)

slide37

X = X + 5

Assignment

X += 5

X:

a value

Memory box

&

Assignment

X  X+5

X:

old value + 5

slide38

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

slide39

*= multiplication x = X *5

/= division x = X/5

%= modulus 7 modulus 2 == 1

+= addition

-= substraction

slide40

# 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();

slide41

# 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!

slide42

statement

Flow chart

decision

Output

end

slide43

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

slide44

Raw_input

Password 

Password == “secret”

F

T

“access

denied”

“access

granted”

end

slide46

decision

F

T

if <proposition> :

<statement>

<statement> (optional)

else:

<statement>

<statement> (optional)

<other statements>

propositions in python
Propositions in Python

5 == 5 equal

8 != 5 not equal

3 > 10

5 < 8

5 >= 10

5 <= 5

slide48

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

slide50

decision

F

T

if <proposition> :

<statement>

<statement> (optional)

elseif <proposition>:

<statement>

<statement> (optional)

else:

<statement>

<statement> (optional)

<other statements>

decision

slide51

# 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

slide52

Variable name: response

A bunch of memory cells (bytes)

“????????” raw_input

4 bytes: 00000000 00000000 00000000 00000000

slide54

St.

Proposition???

F

T

while <proposition> :

<statement>

<statement> (optional)

<other statements>

slide55

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

slide56

# Password# Demonstrates the if structureprint "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.")

slide57

# Password# Demonstrates the if structureprint "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.")

slide58

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":

counting
Counting
  • While loop
  • For loop
slide60

# 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 i,

print "\n\nCounting backwards:"

for i in range(10, 0, -1):

print i,

raw_input("\n\nPress the enter key to exit.\n")

slide62

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

slide63

Index Control

F

T

for <index_variable> in <index control>:

<statement>

<statement> (optional)

<other statements>

slide64

Index Control

F

T

for <integer_variable> in range (start, end, skip):

<statement>

<statement> (optional)

<other statements>

slide65

# Password# Demonstrates the if structureprint "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”): breakif password.lower() != "secret": print "Access Denied after ", numberOfTry, " times."else: print "Access Granted"raw_input("\n\nPress the enter key to exit.")

Use For Loop!!!

slide66

Index Control

F

T

for <index_variable> in <index control>:

<statement>

<statement> (optional)

<other statements>

slide67

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

slide68

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

slide69

0

1

2

3

4

P

i

z

z

a

-5

-4

-3

-2

-1

slide70

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

slide71

# 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()

slide72

Sharing:

You should know bla bla bla

http://www.xyz.com… bye

Target

http://www.xyz.com

slide73

# 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

slide74

# 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

slide75

The usage of “in”

# 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.”)

slide76

The usage of “in”

# 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.”)

slide77

# 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]

slide78

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):]

0

1

2

3

4

P

i

z

z

a

slide79

# 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”

slide80

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."}

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

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

slide83

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

slide84

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

slide85

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

slide86

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

slide87

# 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]

slide88

# 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]

slide89

# 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]

slide90

# 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]

slide91

# 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]