Working with Dictionaries

Slides:



Advertisements
Similar presentations
Does each sentence begin with a capital letter? Underline the beginning letter of each sentence. Is there a. ! ? after each sentence? Circle the punctuation.
Advertisements

This Week More Types boolean string Modules print statement Writing programs if statement Type boolean.
What gets printed out? def f(n): if (n == 0): return (" ") else: print(“blug ") return f(n-1) f(3)
Code: from cisc106 import * def myfunc(value1,value2): return (value1 + value2) assertEqual(myfunc(3,2),5) assertEqual(myfunc(7,4),11) assertEqual(myfunc(9,8),17)
Def f(n): if (n == 0): return else: print(“*”) return f(n-1) f(3)
Maths investigation School diary Science table Annotating an image Recipe Date and title College applications PEE paragraphs Dialogue Notes Writing about.
G make_counter params: body: count = 0 def counter():... my_counter params: body: count += 1... E1 count0 counter E2E2.
1 st 6 weeks Root Study. Define the following roots 1.spec 2. dict 3.ject.
Academic Vocabulary 8 th Grade – Unit 2 – Week 7.
First Quarter Vocabulary
Dictionaries Last half of Chapter 5. Dictionary A sequence of key-value pairs – Key is usually a string or integer – Value can be any python object There.
Academic Vocabulary 7 th Grade – Unit 3 – Week 2.
TPCASTT Group Breakdown
Programming Seminar 2009 Night 1. Review: Last Time We covered variables, for loops, functions, modules, and how programming isn’t math – Actually, we.
Internet Search Strategies Preparing Your Keyword Search.
Python November 18, Unit 7. So Far We can get user input We can create variables We can convert values from one type to another using functions We can.
Main task -write me a program
How to Write a 7-UP Sentence
Academic Vocabulary 7 th Grade – Unit 2 – Week 8.
Point of View. Narration not “Quotation ” When trying to determine point of view, you must look at the narration. Do not look at anything in quotation.
Python – Making Decisions Lecture 02. Control Structures A program that only has one flow is useful but limited. We can use if statements to make these.
Common Writing Problems: Pronouns 9-10 Writing Companion © Perfection Learning ® Reproduction permitted for classroom use only. 1 Lesson 1 Pronouns Activity.
This Week The string type Modules print statement Writing programs if statements (time permitting) The boolean type (time permitting)
Computer Science 111 Fundamentals of Programming I Dictionaries redux.
Of Mice and Men by John Steinbeck Chapter 6 vocabulary.
Computer Science 111 Fundamentals of Programming I Default and Optional Parameters Higher-Order Functions.
Lecture 4 Functions. 2 CodeCademy 4.a. 3 CodeCademy: comments.  As parameter of a function  Second way to introduce variables:  What do max, min,
THREE DICTIONARIES FULL OWNERSHIP—Words you know and can use at will MIDRANGE—Words you have less comfort with. You probably don’t use it yourself when.
Coding Time This is a starter activity and should take about 10 minutes [ slide 1 ] 1.Log in to your computer 2.Open IDLE 3.Start a script session (Select.
Friend Function. 2 Any data which is declared private inside a class is not accessible from outside the class. A non-member function cannot have an access.
Return to Home! Go To Next Slide! Return to Home! Go To Next Slide!
Machine Language Computer languages cannot be directly interpreted by the computer – they are not in binary. All commands need to be translated into binary.
Dr. Philip Cannata 1 Python Classes. Dr. Philip Cannata 2 # The following python statement has python variables which are intended to represent the fact.
Parts of Speech Review.
Vocabulary List Your name.
Fundamentals of Programming I Higher-Order Functions
Topic: Functions – Part 1
HourOfCode, CS Education Week 2014
CS170 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
Computer Programming Fundamentals
Sets and Dictionaries Examples Copyright © Software Carpentry 2010
Python: Logic Gates Damian Gordon.
Vocabulary Pages 1-57.
Programming For Big Data
My Picture Dictionary Comments and Future Considerations: Sentences T
Fundamentals of Programming I Dictionaries redux
Summary Conditional: if .. else New Nested conditional elif
Fundamentals of Programming I Managing the Namespace
FINAL PROJECT- CITIES (2ndes)
CMSC201 Computer Science I for Majors Lecture 17 – Dictionaries
Dialogue Rules and Practice.
Vocabulary Journal Click here to play the audio.
ХУД 60-р сургууль Сургалтын менежер Я. Алтантугалаг 2013 он
Practice sentences: 4.A.

WALT: GIVE OPINIONS ABOUT DIFFERENT ASPECTS OF SCHOOL.
Suggested Layout ** Designed to be printed on white A3 paper.
Four-Dimensional Study
Text Type: Dictionaries
HOMEWORK due in Wednesday 8th November
Module 3 Selection Structures 4/4/2019 CSE 1321 Module 3.
Module 2 - Part 1 Variables, Assignment, and Data Types
General Mathematics CST #2
PUNCTUATING DIALOUE Writing workshop#1.
Weekly Reading Log A I predict……because…
Hacker.
More Basics of Python Common types of data we will work with
Recursion Exercises.
What does this code do? def digitsum(): code goes here def diffsum():
Python Reserved Words Poster
Presentation transcript:

Working with Dictionaries def reply(sentence): """Returns a reply to the sentence.""” if 'mom' or 'work' or 'died' in sentence.split(): for word in sentence.split(): if word == 'mom': return random.choice(keywords.get('mom')) if word == 'work': return random.choice(keywords.get('work')) if word == 'died': return random.choice(keywords.get('died')) probability = random.randint(0, 3) if probability == 0: return random.choice(hedges)) etc.

Working with Dictionaries def reply(sentence): """Returns a reply to the sentence.""” probability = random.randint(0, 3) if probability == 0: return random.choice(hedges)) elif probability == 1: return getKeywordResponse(sentence) etc.

Working with Dictionaries def getKeywordResponse(sentence): """Returns a keyword response to the sentence.""” if 'mom' or 'work' or 'died' in sentence.split(): for word in sentence.split(): if word == 'mom': return random.choice(keywords.get('mom')) if word == 'work': return random.choice(keywords.get('work')) if word == 'died': return random.choice(keywords.get('died')) return reply(sentence)

Working with Dictionaries def getKeywordResponse(sentence): """Returns a keyword response to the sentence.""” for word in sentence.split(): if word in keywords: return random.choice(keywords.get(word)) return reply(sentence)