שיעור 8:tuple, פונקציות 2, sets, dict מבוא ל Python שיעור 5: set, פונקציות, dict.

Slides:



Advertisements
Similar presentations
Python Mini-Course University of Oklahoma Department of Psychology Day 4 – Lesson 15 Tuples 5/02/09 Python Mini-Course: Day 4 – Lesson 15 1.
Advertisements

Procedures and Control Flow CS351 – Programming Paradigms.
Python Dictionary.
Title An Introduction to Python. What is Python exactly? Python is a modern rapid development language. Code is very clean and easy to read. Emphasizes.
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
ONE PASS ALGORITHM PRESENTED BY: PRADHYUMAN RAOL ID : 114 Instructor: Dr T.Y. LIN.
1 Chapter 2 Introductory Programs. 2 Getting started To create and run a Java program –Create a text file with a.java extension for the source code. For.
1 COMP 144 Programming Language Concepts Felix Hernandez-Campos Lecture 7: Python’s Built-in Types and Basic Statements COMP 144 Programming Language Concepts.
CS355 - Theory of Computation Lecture 2: Mathematical Preliminaries.
Java Programming Exceptions Handling. Topics: Learn about exceptions Try code and catch Exceptions Use the Exception getMessage() method Throw and catch.
SQL. Basic Structure SQL is based on set and relational operations with certain modifications and enhancements A typical SQL query has the form: select.
Data Structures and Abstract Data Types "Get your data structures correct first, and the rest of the program will write itself." - David Jones.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. Chapter 14 Tuples, Sets, and Dictionaries 1.
Chapter 2 Adapted from Silberschatz, et al. CHECK SLIDE 16.
MTH 231 Section 2.1 Sets and Operations on Sets. Overview The notion of a set (a collection of objects) is introduced in this chapter as the primary way.
Beyond Lists: Other Data Structures CS303E: Elements of Computers and Programming.
4 1 Array and Hash Variables CGI/Perl Programming By Diane Zak.
Built-in Data Structures in Python An Introduction.
CIT 590 Intro to Programming Lecture 5 – completing lists.
Python Functions.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 9 Dictionaries and Sets.
Chapter 9 Dictionaries and Sets.
Python Primer 1: Types and Operators © 2013 Goodrich, Tamassia, Goldwasser1Python Primer.
Presented By: Miss N. Nembhard. Relation Algebra Relational Algebra is : the formal description of how a relational database operates the mathematics.
Session 07 Module 13 - Collections. Collections / Session 7 / 2 of 32 Review  A delegate in C# is used to refer to a method in a safe manner.  To invoke.
14. DICTIONARIES AND SETS Rocky K. C. Chang 17 November 2014 (Based on from Charles Dierbach, Introduction to Computer Science Using Python and Punch and.
LECTURE 3 Python Basics Part 2. FUNCTIONAL PROGRAMMING TOOLS Last time, we covered function concepts in depth. We also mentioned that Python allows for.
Chapter 4: More Object Concepts. Objectives Understand blocks and scope Overload a method Avoid ambiguity Create and call constructors with parameters.
COSC 1306—COMPUTER SCIENCE AND PROGRAMMING PYTHON TUPLES, SETS AND DICTIONARIES Jehan-François Pâris
Module #3 - Sets 3/2/2016(c) , Michael P. Frank 2. Sets and Set Operations.
Arrays (part 2) 1 -Based on slides from Deitel & Associates, Inc. - Revised by T. A. Yang.
Introduction to Python Aug 22, 2013 Hee-gook Jun.
Lambdas and Streams. Stream manipulation Class Employee represents an employee with a first name, last name, salary and department and provides methods.
Introduction to Python Sajal Desai. What is Python? Versitile, simple, high level language No linking and compilation “By the way, the language is named.
Quiz 3 Topics Functions – using and writing. Lists: –operators used with lists. –keywords used with lists. –BIF’s used with lists. –list methods. Loops.
Python Sets and Dictionaries Peter Wad Sackett. 2DTU Systems Biology, Technical University of Denmark Set properties What is a set? A set is a mutable.
Dictionaries Alexandra Stefan CSE1310 – University of Texas at Arlington.
Copyright © 2013 by John Wiley & Sons. All rights reserved. SETS AND DICTIONARIES CHAPTER Slides by James Tam Department of Computer Science, University.
A thorough introduction to Python. What is Python exactly? Python is a modern rapid development language. – Emphasizes single, intuitive approach to most.
Topics Dictionaries Sets Serializing Objects. Topics Dictionaries Sets Serializing Objects.
CMSC201 Computer Science I for Majors Lecture 17 – Dictionaries
CMSC201 Computer Science I for Majors Lecture 21 – Dictionaries
Department of Computer Science,
Announcements Project 4 due Wed., Nov 7
Ruth Anderson CSE 140 University of Washington
structures and their relationships." - Linus Torvalds
CMSC201 Computer Science I for Majors Lecture 20 – Dictionaries
CHAPTER THREE Sequences.
CISC101 Reminders Quiz 2 graded. Assn 2 sample solution is posted.
Python Data Structures
Advanced Algorithms Analysis and Design
CSC1018F: Intermediate Python
COSC 1306 COMPUTER SCIENCE AND PROGRAMMING
Python Tutorial for C Programmer Boontee Kruatrachue Kritawan Siriboon
Topics Dictionaries Sets Serializing Objects. Topics Dictionaries Sets Serializing Objects.
Introduction to Sets.
Dictionaries Dictionary: object that stores a collection of data
Python Primer 1: Types and Operators
Michael Ernst CSE 140 University of Washington
6. Dictionaries and sets Rocky K. C. Chang 18 October 2018
Ruth Anderson CSE 160 University of Washington
Winter 2019 CISC101 4/29/2019 CISC101 Reminders
Lecture 7: Python’s Built-in Types and Basic Statements
Ruth Anderson UW CSE 160 Spring 2018
CMSC201 Computer Science I for Majors Lecture 19 – Dictionaries
structures and their relationships." - Linus Torvalds
Dictionary.
Selamat Datang di “Programming Essentials in Python”
Ruth Anderson UW CSE 160 Winter 2016
Presentation transcript:

שיעור 8:tuple, פונקציות 2, sets, dict מבוא ל Python שיעור 5: set, פונקציות, dict

שיעור 8:tuple, פונקציות 2, sets, dict שיעור 5  Tuple  dict  Sets  פונקציות 2

שיעור 8:tuple, פונקציות 2, sets, dict

שיעור 5  Tuple  dict  Sets  פונקציות 2

שיעור 8:tuple, פונקציות 2, sets, dict Dict()  טיפוס הנתונים המילון מקביל ל-hash ב שפות תכנות אחרות כמו למשל perl, או hashtable ב-JAVA.  מילון הוא טיפוס נתונים המכיל זוגות של נתונים: מפתח וערך, ומאפשר גישה יעילה לערכים על פי מפתחותיהם.  כדי להבין כיצד עובדים מילונים בפיתון, נשים לב לקטע הקוד בשקף הבא:

שיעור 8:tuple, פונקציות 2, sets, dict Dict()  יצירת מילון חדש בן שני איברים, והשמתו לתוך המשתנה  יצירת מילון נעשית על ידי כתיבת הזוגות מפתח - נקודותיים - ערך ( המפתח משמאל לערך כמובן ) מופרדים בפסיקים, בתוך סוגריים מסולסלים או ע " י השימוש במילה dict.

שיעור 8:tuple, פונקציות 2, sets, dict Dict()  דוגמאות נוספות 

שיעור 8:tuple, פונקציות 2, sets, dict שיעור 5  dict  Sets  פונקציות 2

שיעור 8:tuple, פונקציות 2, sets, dict Sets Python also includes a data type for sets. A set is an unordered collection with no duplicate elements. Basic uses include membership testing and eliminating duplicate entries. Set objects also support mathematical operations like union, intersection, difference, and symmetric difference. Curly braces or the set() function can be used to create sets.

שיעור 8:tuple, פונקציות 2, sets, dict sets() fast membership testing

שיעור 8:tuple, פונקציות 2, sets, dict sets() Demonstrate set operations on unique letters from two words

שיעור 8:tuple, פונקציות 2, sets, dict שיעור 4  dict  Sets  פונקציות 2

שיעור 8:tuple, פונקציות 2, sets, dict פונקציות 2 (המשך)  Default Argument Values  A useful form is to specify a default value for one or more arguments.  This creates a function that can be called with fewer arguments than it is defined to allow. For example: This example also introduces the in keyword. This tests whether or not a sequence contains a certain value. Usages:

שיעור 8:tuple, פונקציות 2, sets, dict פונקציות 2 (המשך)  Keyword Arguments¶  Functions can also be called using keyword arguments of the form kwarg=value. For instance, the following function:  accepts one required argument (voltage) and three optional arguments (state, action, and type). This function can be called in any of the following ways:  : parrot(1000) # 1 positional argument parrot(voltage=1000) # 1 keyword argument parrot(voltage= , action='VOOOOOM') # 2 keyword arguments parrot(action='VOOOOOM', voltage= ) # 2 keyword arguments parrot('a million', 'bereft of life', 'jump') # 3 positional arguments parrot('a thousand', state='pushing up the daisies') # 1 positional, 1 keyword

שיעור 8:tuple, פונקציות 2, sets, dict פונקציות 2 (המשך)  Default Argument Values  Important warning : The default value is evaluated only once. This makes a difference when the default is a mutable object such as a list, dictionary, or instances of most classes. For example, the following function accumulates the arguments passed to it on subsequent calls:

שיעור 8:tuple, פונקציות 2, sets, dict פונקציות 2 (המשך)  **name receives a dictionary containing all keyword arguments except for those corresponding to a formal parameter.  *name receives a tuple containing the positional arguments beyond the formal parameter list.  *name must occur before **name.  For example, if we define a function like this:example, if we define a function like this:

שיעור 8:tuple, פונקציות 2, sets, dict פונקציות 2 (המשך)