This document provides a summary of the history and features of the Groovy programming language. It discusses how Groovy evolved from earlier dynamic scripting languages for Java like BeanShell and Rhino. Key points include:
- Groovy was created in 2003 by James Strachan as a new dynamic language for the Java platform.
- Groovy adds dynamic and static typing, closures, builders, metaprogramming and other features to make Java development more productive.
- Groovy scripts can omit elements like semicolons and parentheses and do not require defining a class or main method. This makes Groovy code more concise and readable.
This document provides a summary of key concepts from a Python programming tutorial, including strings, lists, tuples, and maps (dictionaries). It defines each concept and provides examples of how to create, print, add/remove elements from each data type. It also includes exercises asking the reader to apply the concepts by creating and manipulating variables of each data type. The exercises test creating and modifying strings, lists, tuples, and dictionaries with different operations like printing, adding, removing elements.
Here are the steps to solve this problem:
1. Convert both lists of numbers to sets:
set1 = {11, 2, 3, 4, 15, 6, 7, 8, 9, 10}
set2 = {15, 2, 3, 4, 15, 6}
2. Find the intersection of the two sets:
intersection = set1.intersection(set2)
3. The number of elements in the intersection is the number of similar elements:
similarity = len(intersection)
4. Print the result:
print(similarity)
The similarity between the two sets is 4, since they both contain the elements {2, 3, 4, 15}.
This document provides an overview of switching from Java to Groovy. It discusses installing and running Groovy, basic Groovy concepts like "Hello World" examples, lists, maps, and more. Templates, resources, and books for learning Groovy are also referenced. The document is intended to introduce developers to Groovy and highlight improvements and differences over Java.
MySQLConf2009: Taking ActiveRecord to the Next LevelBlythe Dunham
Taking ActiveRecord to the next level contains tips and tricks for using ActiveRecord with enterprise Ruby on Rails Applications. Learn how to import and export multiple records, read off replicas, handle deadlocks, and use temporary tables. Use MySQL functionality such as adding index hints, on duplicate key update, insert select and more.
The document discusses odd behaviors in Python related to identity, mutability, and scope. It provides examples testing the identity and mutability of various Python objects. It also discusses issues that can arise from using mutable default arguments and provides tips on how to avoid these issues, such as using None as a default instead of a mutable object.
Python Tricks That You Can't Live WithoutAudrey Roy
Audrey Roy gave a presentation on Python tricks for code readability and reuse at PyCon Philippines 2012. She discussed writing clean, understandable code by following PEP8 style guidelines and using linters. She also explained how to find and install reusable Python libraries from the standard library and PyPI, and how to write packages and modules to create reusable code.
The document discusses building lists and numbers using functional programming concepts in JavaScript. It outlines an approach to representing lists as functions that take a selector function as an argument. Using this approach, common list operations like prepend, head, tail, map and filter can be implemented. Numbers are then represented as Church encodings using lists, allowing arithmetic operations to be defined recursively in a functional style. The document concludes by encouraging experimentation with functional programming concepts in JavaScript.
This document provides a summary of the history and features of the Groovy programming language. It discusses how Groovy evolved from earlier dynamic scripting languages for Java like BeanShell and Rhino. Key points include:
- Groovy was created in 2003 by James Strachan as a new dynamic language for the Java platform.
- Groovy adds dynamic and static typing, closures, builders, metaprogramming and other features to make Java development more productive.
- Groovy scripts can omit elements like semicolons and parentheses and do not require defining a class or main method. This makes Groovy code more concise and readable.
This document provides a summary of key concepts from a Python programming tutorial, including strings, lists, tuples, and maps (dictionaries). It defines each concept and provides examples of how to create, print, add/remove elements from each data type. It also includes exercises asking the reader to apply the concepts by creating and manipulating variables of each data type. The exercises test creating and modifying strings, lists, tuples, and dictionaries with different operations like printing, adding, removing elements.
Here are the steps to solve this problem:
1. Convert both lists of numbers to sets:
set1 = {11, 2, 3, 4, 15, 6, 7, 8, 9, 10}
set2 = {15, 2, 3, 4, 15, 6}
2. Find the intersection of the two sets:
intersection = set1.intersection(set2)
3. The number of elements in the intersection is the number of similar elements:
similarity = len(intersection)
4. Print the result:
print(similarity)
The similarity between the two sets is 4, since they both contain the elements {2, 3, 4, 15}.
This document provides an overview of switching from Java to Groovy. It discusses installing and running Groovy, basic Groovy concepts like "Hello World" examples, lists, maps, and more. Templates, resources, and books for learning Groovy are also referenced. The document is intended to introduce developers to Groovy and highlight improvements and differences over Java.
MySQLConf2009: Taking ActiveRecord to the Next LevelBlythe Dunham
Taking ActiveRecord to the next level contains tips and tricks for using ActiveRecord with enterprise Ruby on Rails Applications. Learn how to import and export multiple records, read off replicas, handle deadlocks, and use temporary tables. Use MySQL functionality such as adding index hints, on duplicate key update, insert select and more.
The document discusses odd behaviors in Python related to identity, mutability, and scope. It provides examples testing the identity and mutability of various Python objects. It also discusses issues that can arise from using mutable default arguments and provides tips on how to avoid these issues, such as using None as a default instead of a mutable object.
Python Tricks That You Can't Live WithoutAudrey Roy
Audrey Roy gave a presentation on Python tricks for code readability and reuse at PyCon Philippines 2012. She discussed writing clean, understandable code by following PEP8 style guidelines and using linters. She also explained how to find and install reusable Python libraries from the standard library and PyPI, and how to write packages and modules to create reusable code.
The document discusses building lists and numbers using functional programming concepts in JavaScript. It outlines an approach to representing lists as functions that take a selector function as an argument. Using this approach, common list operations like prepend, head, tail, map and filter can be implemented. Numbers are then represented as Church encodings using lists, allowing arithmetic operations to be defined recursively in a functional style. The document concludes by encouraging experimentation with functional programming concepts in JavaScript.
This document provides an introduction to the Python programming language. It covers basic Python concepts like data types, strings, data structures, classes, methods, exceptions, iterations, generators, and scopes. Python is described as an easy to learn, read, and use dynamic language with a large selection of stable libraries. It is presented as being much easier than bash scripts for building and maintaining complex system infrastructure.
This document discusses various Python data structures including lists, tuples, and dictionaries. It provides examples of how to use each data structure, such as appending and removing items from lists, indexing and slicing sequences, and adding/deleting key-value pairs from dictionaries. The document also covers Python references, console input using raw_input() and input(), and introduces objects and classes.
This document provides an introduction and overview of the Ruby programming language. It discusses installing Ruby on Windows and Linux/OSX systems, running Ruby scripts, using the interactive Ruby shell (IRB), creating and running .rb files. It also covers key Ruby concepts like classes and objects, duck typing, attributes and accessors, arrays, hashes, symbols, blocks and iterators.
The document discusses the deque collection in Python. Some key points:
- Deque allows fast appends and pops from either side of the list, with O(1) time complexity, unlike regular lists which are slow (O(n)) for pop(0) and insert(0,v).
- Deque provides methods like append, appendleft, popleft, pop for adding/removing elements from either side of the list.
- It can be initialized with a maximum length to act as a sliding window, discarding old elements as new ones are added.
- Methods like rotate rotate the deque a given number of positions, extending adds multiple elements at once. Deque is useful when
This document discusses lists and dictionaries in Python. It provides definitions and examples of lists, including how to add and remove elements from lists. It also discusses sorting lists and getting the length of lists. Examples are provided for integrating lists with loops. The document then discusses dictionaries, including how to represent them and retrieve values from dictionaries using keys. Examples are provided for using loops to print keys and values from dictionaries. It also discusses modules like NumPy and Pandas that can be imported in Python.
This document provides an overview of PHP strings, arrays, dates and debugging functions:
1) Strings in PHP are series of characters with 256 possible characters. Important string functions include explode, nl2br, strcmp, strlen, strtolower, substr, trim.
2) Arrays in PHP are data structures that store elements accessed by indexes. Important array functions include asort, array_push, array_pop, array_search, array_random, array_reverse, array_merge, array_keys.
3) PHP has functions for working with dates like date, strtotime. Date format codes include d, D, F for formatting dates.
4) Useful debugging
PHP arrays can be indexed or associative. Indexed arrays are similar to conventional programming language arrays while associative arrays are like dictionaries or maps where elements can be accessed by keys. Array elements can be of any type and arrays can be heterogeneous. PHP provides many functions for manipulating arrays like count(), sizeof(), array_slice(), in_array(), sorting functions, and more.
This document provides an overview and introduction to Python programming. It covers setting up Python, background on the language, basic syntax like printing, variables, operators, control structures, functions, and data structures. It encourages participation and practicing the concepts by following along. The goal is to teach the fundamentals of Python in an interactive class format.
The document discusses a talk titled "The Dark Side of Ruby". The talk will cover how Ruby is an awesome programming language but also discuss some weirdness, gotchas, and ah-ha moments related to Ruby. It will explore infinity in Ruby, base conversions, splat expansion, hashes and arrays, calling procs, syntax, case statements, equality comparisons, object IDs and Fixnums, and currying.
Arrays allow storing multiple values in a single variable. There are indexed arrays which use numeric indices and associative arrays which use named keys. Arrays can be defined using the array() function or by directly assigning values. Arrays can be looped through using foreach loops or functions like sizeof() to get the size. Multidimensional arrays store arrays within other arrays.
The document discusses various PHP array functions including:
- Array functions like array_combine(), array_count_values(), array_diff() for comparing and merging arrays.
- Sorting arrays with asort(), arsort(), ksort(), krsort().
- Other functions like array_search(), array_sum(), array_rand() for searching, summing and random values.
- Modifying arrays with array_push(), array_pop(), array_shift() for adding/removing elements.
The document provides examples of using each array function in PHP code snippets.
Functional Programming & Event Sourcing - a pair made in heavenPawel Szulc
The document discusses functional programming and event sourcing. It begins with an overview of functional programming principles like avoiding side effects and variable mutation. It then provides examples of modeling user data retrieval in a functional way using classes like Cache, UserRepo, and UserFinder. The examples demonstrate functional patterns like avoiding stateful objects and embracing immutable and recursive functions. The document argues that functional programming and event sourcing are well-aligned due to their shared emphasis on immutable data models and avoidance of shared state.
An array is a data structure that stores multiple values in a single variable. There are two main types of arrays in PHP: indexed arrays which use integers as keys and associative arrays which use named keys like strings. The document discusses how to define, access, iterate through and perform operations on arrays in PHP such as counting elements and checking if a key exists.
The document introduces Arel, which is a SQL AST manager that Active Record uses to build queries. It allows for more advanced querying capabilities compared to just using Active Record. Some key points made are:
- Arel can represent SQL queries as objects, allowing for composability and dynamic queries
- It supports advanced features like outer joins, OR conditions, and functions that Active Record does not support
- Queries can be built programmatically using Arel nodes rather than injecting raw SQL strings
- Baby Squeel is introduced as a simpler wrapper around Arel for building queries in a domain specific language-like style
The document advocates for using Arel or libraries that build on it like Baby Sque
This document discusses learning jQuery and provides summaries of 5 sections:
1. Ready handlers, selectors, CSS, effects, events, and method chaining
2. Attributes, classes, HTML manipulation, and value manipulation
3. Event handling and samples for events like click and tab
4. Using AJAX with load() and get() methods
5. Plugins for thickbox, colorbox, fancybox and traversing DOM elements.
The document provides an introduction to Python programming concepts including functions, variables, data types, conditionals, loops, and data structures. It demonstrates a simple "Hello, World!" function and how to define, call, and assign the return value of functions. It also shows how to check variable types, use if/else conditional logic, iterate with for loops, and define a dictionary with nested data. The document uses examples and commentary to explain Python syntax and programming concepts in a beginner-friendly manner.
This document provides an overview of PHP arrays, including:
- Arrays allow storing multiple elements that are accessed via numeric indexes. Elements can be of any type.
- Arrays can be iterated over using foreach loops or traditional for/while loops.
- Arrays have built-in functions for sorting, searching, merging, reversing, and more.
- Multidimensional arrays allow storing other arrays as elements.
- Associative arrays use named keys instead of numeric indexes to access elements.
- Exercises demonstrate creating multidimensional arrays and outputting array data to HTML tables.
If you saw the "Crusty Talk" (Protocol Oriented Programming in Swift) at WWDC, you saw Apple announce Swift as the first "Protocol Oriented language." If you immediately jumped into Xcode and tried to write a lot of protocol oriented code, you may have discovered that the promise isn't quite the reality. In this talk, you'll learn how to rethink your types so that you can avoid complex protocol problems without giving up their power.
PLOTCON NYC: Behind Every Great Plot There's a Great Deal of WranglingPlotly
If you are struggling to make a plot, tear yourself away from stackoverflow for a moment and ... take a hard look at your data. Is it really in the most favorable form for the task at hand? Time and time again I have found that my visualization struggles are really a symptom of unfinished data wrangling. R has long had excellent facilities for data aggregation or "split-apply-combine": split an object into pieces, compute on each piece, and glue the result back together again. Recent developments, especially in the purrr package, have made "split-apply-combine" even easier and more general. But this requires a certain comfort level with lists, especially with lists that are columns inside a data frame. This is unfamiliar to most of us. I give an overview of this set of problems and match them up with solutions based on grouped, nested, and split data frames.
The document discusses slicing in Python. It explains that lists, strings, and tuples can be sliced using a range of indices. It provides examples of slicing elements and strings, demonstrating how slicing returns a substring or subsequence. It notes that slicing always creates a new collection, rather than being an alias, so changes to a slice do not affect the original object.
The document discusses tuples in Python. It explains that tuples are immutable sequences, like lists but that cannot be changed after creation. It provides examples of creating tuples using parentheses or without parentheses if context is clear. Tuples allow functions to return multiple values, provide a way to swap variable values, and are often used in loops like with the enumerate function.
This document provides an introduction to the Python programming language. It covers basic Python concepts like data types, strings, data structures, classes, methods, exceptions, iterations, generators, and scopes. Python is described as an easy to learn, read, and use dynamic language with a large selection of stable libraries. It is presented as being much easier than bash scripts for building and maintaining complex system infrastructure.
This document discusses various Python data structures including lists, tuples, and dictionaries. It provides examples of how to use each data structure, such as appending and removing items from lists, indexing and slicing sequences, and adding/deleting key-value pairs from dictionaries. The document also covers Python references, console input using raw_input() and input(), and introduces objects and classes.
This document provides an introduction and overview of the Ruby programming language. It discusses installing Ruby on Windows and Linux/OSX systems, running Ruby scripts, using the interactive Ruby shell (IRB), creating and running .rb files. It also covers key Ruby concepts like classes and objects, duck typing, attributes and accessors, arrays, hashes, symbols, blocks and iterators.
The document discusses the deque collection in Python. Some key points:
- Deque allows fast appends and pops from either side of the list, with O(1) time complexity, unlike regular lists which are slow (O(n)) for pop(0) and insert(0,v).
- Deque provides methods like append, appendleft, popleft, pop for adding/removing elements from either side of the list.
- It can be initialized with a maximum length to act as a sliding window, discarding old elements as new ones are added.
- Methods like rotate rotate the deque a given number of positions, extending adds multiple elements at once. Deque is useful when
This document discusses lists and dictionaries in Python. It provides definitions and examples of lists, including how to add and remove elements from lists. It also discusses sorting lists and getting the length of lists. Examples are provided for integrating lists with loops. The document then discusses dictionaries, including how to represent them and retrieve values from dictionaries using keys. Examples are provided for using loops to print keys and values from dictionaries. It also discusses modules like NumPy and Pandas that can be imported in Python.
This document provides an overview of PHP strings, arrays, dates and debugging functions:
1) Strings in PHP are series of characters with 256 possible characters. Important string functions include explode, nl2br, strcmp, strlen, strtolower, substr, trim.
2) Arrays in PHP are data structures that store elements accessed by indexes. Important array functions include asort, array_push, array_pop, array_search, array_random, array_reverse, array_merge, array_keys.
3) PHP has functions for working with dates like date, strtotime. Date format codes include d, D, F for formatting dates.
4) Useful debugging
PHP arrays can be indexed or associative. Indexed arrays are similar to conventional programming language arrays while associative arrays are like dictionaries or maps where elements can be accessed by keys. Array elements can be of any type and arrays can be heterogeneous. PHP provides many functions for manipulating arrays like count(), sizeof(), array_slice(), in_array(), sorting functions, and more.
This document provides an overview and introduction to Python programming. It covers setting up Python, background on the language, basic syntax like printing, variables, operators, control structures, functions, and data structures. It encourages participation and practicing the concepts by following along. The goal is to teach the fundamentals of Python in an interactive class format.
The document discusses a talk titled "The Dark Side of Ruby". The talk will cover how Ruby is an awesome programming language but also discuss some weirdness, gotchas, and ah-ha moments related to Ruby. It will explore infinity in Ruby, base conversions, splat expansion, hashes and arrays, calling procs, syntax, case statements, equality comparisons, object IDs and Fixnums, and currying.
Arrays allow storing multiple values in a single variable. There are indexed arrays which use numeric indices and associative arrays which use named keys. Arrays can be defined using the array() function or by directly assigning values. Arrays can be looped through using foreach loops or functions like sizeof() to get the size. Multidimensional arrays store arrays within other arrays.
The document discusses various PHP array functions including:
- Array functions like array_combine(), array_count_values(), array_diff() for comparing and merging arrays.
- Sorting arrays with asort(), arsort(), ksort(), krsort().
- Other functions like array_search(), array_sum(), array_rand() for searching, summing and random values.
- Modifying arrays with array_push(), array_pop(), array_shift() for adding/removing elements.
The document provides examples of using each array function in PHP code snippets.
Functional Programming & Event Sourcing - a pair made in heavenPawel Szulc
The document discusses functional programming and event sourcing. It begins with an overview of functional programming principles like avoiding side effects and variable mutation. It then provides examples of modeling user data retrieval in a functional way using classes like Cache, UserRepo, and UserFinder. The examples demonstrate functional patterns like avoiding stateful objects and embracing immutable and recursive functions. The document argues that functional programming and event sourcing are well-aligned due to their shared emphasis on immutable data models and avoidance of shared state.
An array is a data structure that stores multiple values in a single variable. There are two main types of arrays in PHP: indexed arrays which use integers as keys and associative arrays which use named keys like strings. The document discusses how to define, access, iterate through and perform operations on arrays in PHP such as counting elements and checking if a key exists.
The document introduces Arel, which is a SQL AST manager that Active Record uses to build queries. It allows for more advanced querying capabilities compared to just using Active Record. Some key points made are:
- Arel can represent SQL queries as objects, allowing for composability and dynamic queries
- It supports advanced features like outer joins, OR conditions, and functions that Active Record does not support
- Queries can be built programmatically using Arel nodes rather than injecting raw SQL strings
- Baby Squeel is introduced as a simpler wrapper around Arel for building queries in a domain specific language-like style
The document advocates for using Arel or libraries that build on it like Baby Sque
This document discusses learning jQuery and provides summaries of 5 sections:
1. Ready handlers, selectors, CSS, effects, events, and method chaining
2. Attributes, classes, HTML manipulation, and value manipulation
3. Event handling and samples for events like click and tab
4. Using AJAX with load() and get() methods
5. Plugins for thickbox, colorbox, fancybox and traversing DOM elements.
The document provides an introduction to Python programming concepts including functions, variables, data types, conditionals, loops, and data structures. It demonstrates a simple "Hello, World!" function and how to define, call, and assign the return value of functions. It also shows how to check variable types, use if/else conditional logic, iterate with for loops, and define a dictionary with nested data. The document uses examples and commentary to explain Python syntax and programming concepts in a beginner-friendly manner.
This document provides an overview of PHP arrays, including:
- Arrays allow storing multiple elements that are accessed via numeric indexes. Elements can be of any type.
- Arrays can be iterated over using foreach loops or traditional for/while loops.
- Arrays have built-in functions for sorting, searching, merging, reversing, and more.
- Multidimensional arrays allow storing other arrays as elements.
- Associative arrays use named keys instead of numeric indexes to access elements.
- Exercises demonstrate creating multidimensional arrays and outputting array data to HTML tables.
If you saw the "Crusty Talk" (Protocol Oriented Programming in Swift) at WWDC, you saw Apple announce Swift as the first "Protocol Oriented language." If you immediately jumped into Xcode and tried to write a lot of protocol oriented code, you may have discovered that the promise isn't quite the reality. In this talk, you'll learn how to rethink your types so that you can avoid complex protocol problems without giving up their power.
PLOTCON NYC: Behind Every Great Plot There's a Great Deal of WranglingPlotly
If you are struggling to make a plot, tear yourself away from stackoverflow for a moment and ... take a hard look at your data. Is it really in the most favorable form for the task at hand? Time and time again I have found that my visualization struggles are really a symptom of unfinished data wrangling. R has long had excellent facilities for data aggregation or "split-apply-combine": split an object into pieces, compute on each piece, and glue the result back together again. Recent developments, especially in the purrr package, have made "split-apply-combine" even easier and more general. But this requires a certain comfort level with lists, especially with lists that are columns inside a data frame. This is unfamiliar to most of us. I give an overview of this set of problems and match them up with solutions based on grouped, nested, and split data frames.
The document discusses slicing in Python. It explains that lists, strings, and tuples can be sliced using a range of indices. It provides examples of slicing elements and strings, demonstrating how slicing returns a substring or subsequence. It notes that slicing always creates a new collection, rather than being an alias, so changes to a slice do not affect the original object.
The document discusses tuples in Python. It explains that tuples are immutable sequences, like lists but that cannot be changed after creation. It provides examples of creating tuples using parentheses or without parentheses if context is clear. Tuples allow functions to return multiple values, provide a way to swap variable values, and are often used in loops like with the enumerate function.
This document provides an introduction to Python data structures including lists, tuples, sets, and dictionaries. It describes how to define, access, and modify each type of data structure. It also covers file handling, string functions, exceptions, and other Python concepts. The key points are:
- Lists are the most versatile data type and can contain elements of different types. They can be accessed by index, sliced, modified via assignments to slices.
- Tuples are immutable sequences that are useful for grouping related data. They allow packing and unpacking of elements.
- Sets store unique elements and support mathematical operations like union and intersection.
- Dictionaries store mappings of unique keys to values. They allow
This document provides information about dictionaries in Python. It defines dictionaries as mutable containers that store key-value pairs, with keys being unique and values being of any type. It describes dictionary syntax and how to access, update, delete and add elements. It notes that dictionary keys must be immutable like strings or numbers, while values can be any type. Properties of dictionary keys like no duplicate keys and keys requiring immutability are also summarized.
The document provides an overview of Python lists, including how to create and access list elements using indexes, loop through lists, modify lists by adding, removing, or changing elements, and several common list methods. Key points include: lists allow storing multiple values in a single variable; values can be accessed by index with list[index]; common operations include append() to add elements, sort() and reverse() modify the list in-place, and in tests for membership in a list.
This document summarizes Python basics including its features, popularity in different fields and companies, data types, control flow, containers like lists and dictionaries, NumPy for numerical computing, and classes. Python is an interpreted, general-purpose language with rich library support. It is commonly used in computer science, data analysis, biology, and academic communities. Major companies like Google, Dropbox, and Instagram use Python.
This document summarizes Python basics including its features, popularity in different fields and companies, data types, control flow, containers like lists and dictionaries, NumPy for numerical computing, and classes. Python is an interpreted, general-purpose language with rich library support. It is commonly used in computer science, data analysis, biology, and academic communities. Major companies like Google, Dropbox, and Instagram use Python.
This document provides an overview of different collection data types in Python including tuples, dictionaries, and sets. It discusses the key properties and uses of each type. Tuples are immutable sequences, dictionaries store key-value pairs and allow fast lookup by key, and sets only allow unique elements and support mathematical set operations. The document also covers performance considerations and recommends sets for fast membership checking of hashable elements.
Python is a programming language developed in 1989 that is still actively developed. It draws influences from languages like Perl, Java, C, C++, and others. Python code is portable, free, and recommended for tasks like system administration scripts, web development, scientific computing, and rapid prototyping. It has a simple syntax and is optionally object-oriented and multi-threaded. Python has extensive libraries for tasks like string manipulation, web programming, databases, and interface design. Popular applications of Python include web development, data analysis, scientific computing, and scripting.
Python has several basic data types including strings, lists, tuples and dictionaries. Strings can be accessed and manipulated using indexes and methods like split() and join(). Lists allow indexing, slicing, sorting and other controls. Tuples are ordered and immutable while dictionaries use keys to store values. Conditionals like if/else and loops like for and while control program flow. Functions and classes define reusable blocks of code. Files can be opened and their contents read line by line.
This is the presentation for the three-session intermediate Python programming course which I developed and successfully presented for the CoderDojo workshop held in Microsoft Silicon Valley in March 2016.
The document provides a recap of Python programming concepts like conditions and statements, while loops, for loops, break and continue statements, and working with strings. It also introduces regular expressions as a way to match patterns in strings using a formal language that can be interpreted by a regular expression processor.
[SUMMARY
METHODS DESCRIPTION
copy() They copy() method returns a shallow copy of the dictionary.
clear() The clear() method removes all items from the dictionary.
pop() Removes and returns an element from a dictionary having the given key.
popitem() Removes the arbitrary key-value pair from the dictionary and returns it as tuple.
get() It is a conventional method to access a value for a key.
dictionary_name.values() returns a list of all the values available in a given dictionary.
str() Produces a printable string representation of a dictionary.
update() Adds dictionary dict2’s key-values pairs to dict
setdefault() Set dict[key]=default if key is not already in dict
keys() Returns list of dictionary dict’s keys
items() Returns a list of dict’s (key, value) tuple pairs
has_key() Returns true if key in dictionary dict, false otherwise
fromkeys() Create a new dictionary with keys from seq and values set to value.
type() Returns the type of the passed variable.
cmp() Compares elements of both dict.
The document provides an overview of Python lists:
- Lists allow you to store sets of information in a particular order and are one of Python's most powerful features.
- You can define lists using square brackets and commas, and use plural names for lists to make code more readable. Lists can contain millions of items.
- Lists allow adding, inserting, removing, sorting, and accessing elements by their position or value using various list methods like append(), insert(), remove(), sort(), and indexing.
- Loops like for loops efficiently iterate through lists to work with each element.
The document provides an overview of common Python data structures and programming concepts including variables, strings, lists, tuples, dictionaries, conditionals, functions, files, classes, and more. It includes examples of how to define, access, modify, loop through, and perform operations on each type of data structure. Key points covered include using lists to store ordered sets of items, dictionaries to store connections between pieces of information as key-value pairs, and classes to define custom object types with attributes and methods.
Beginners python cheat sheet - Basic knowledge O T
The document provides an overview of common Python data structures and programming concepts including variables, strings, lists, tuples, dictionaries, conditionals, functions, files, classes, and more. It includes examples of how to define, access, modify, loop through, and perform operations on each type of data structure. Key points covered include using lists to store ordered sets of items, dictionaries to store connections between pieces of information as key-value pairs, and classes to define custom object types with attributes and methods.
Python Workshop - Learn Python the Hard WayUtkarsh Sengar
This document provides an introduction to learning Python. It discusses prerequisites for Python, basic Python concepts like variables, data types, operators, conditionals and loops. It also covers functions, files, classes and exceptions handling in Python. The document demonstrates these concepts through examples and exercises learners to practice char frequency counting and Caesar cipher encoding/decoding in Python. It encourages learners to practice more to master the language and provides additional learning resources.
This document discusses tuples and dictionaries in Python. It begins by explaining that tuples and lists are sequence types that can be iterated over with a for loop, but that tuples are immutable while lists are mutable. It then defines tuples as ordered, unchangeable collections of data that can be created, accessed, and looped through. Dictionaries are described as unordered, mutable collections that contain key-value pairs and support operations like adding, removing, and accessing items. The document provides examples of creating, modifying, and looping through both tuples and dictionaries.
This document discusses tuples and dictionaries in Python. It begins by explaining that tuples and lists are sequence types that can be iterated over with a for loop, but that tuples are immutable while lists are mutable. It then defines tuples as ordered, unchangeable collections of data that can be created, accessed, and looped through. Dictionaries are described as unordered, mutable collections that contain key-value pairs and support operations like adding, removing, and accessing items. The document provides examples of creating, modifying, and looping through both tuples and dictionaries.
Python Programming for basic beginners.pptxmohitesoham12
The document provides an overview of Python programming concepts including data types, variables, operators, and collections like lists and tuples. It defines Python as a general purpose programming language created in 1991 that can be used for desktop, web, machine learning, and data science apps. Key data types covered include numbers, strings, lists, and tuples. Operators for arithmetic, comparison, logical, membership, and identity are also summarized. Various list and tuple methods for accessing, modifying, sorting, and joining their items are demonstrated through examples.
This document provides an introduction and overview of the Python programming language. It discusses Python's major data types like lists, strings, tuples and dictionaries. It also covers Python versions, development environments, the interactive shell, and string and list methods. Common operations on lists like indexing, slicing and mutable methods are demonstrated. The document serves as a starting point for learning Python.
This document provides an introduction to the Python programming language. It discusses Python versions and distributions, development environments, the Python interactive shell, basic Python data types like lists and strings, and gives examples of working with these data types through indexing, slicing and built-in methods. It also briefly introduces dictionaries and tuples. The document aims to provide newcomers to Python with essential information on the language and getting started.
This document provides an introduction to Python basics including data types, operations, variables, user input/output, strings, numbers, and type conversion. It discusses integers, floats, booleans, arithmetic operators, comparison operators, and functions like int(), float(), str(), type(), print(), and raw_input(). The document contains examples of code snippets and exercises for readers to practice Python concepts.
Nucleophilic Addition of carbonyl compounds.pptxSSR02
Nucleophilic addition is the most important reaction of carbonyls. Not just aldehydes and ketones, but also carboxylic acid derivatives in general.
Carbonyls undergo addition reactions with a large range of nucleophiles.
Comparing the relative basicity of the nucleophile and the product is extremely helpful in determining how reversible the addition reaction is. Reactions with Grignards and hydrides are irreversible. Reactions with weak bases like halides and carboxylates generally don’t happen.
Electronic effects (inductive effects, electron donation) have a large impact on reactivity.
Large groups adjacent to the carbonyl will slow the rate of reaction.
Neutral nucleophiles can also add to carbonyls, although their additions are generally slower and more reversible. Acid catalysis is sometimes employed to increase the rate of addition.
hematic appreciation test is a psychological assessment tool used to measure an individual's appreciation and understanding of specific themes or topics. This test helps to evaluate an individual's ability to connect different ideas and concepts within a given theme, as well as their overall comprehension and interpretation skills. The results of the test can provide valuable insights into an individual's cognitive abilities, creativity, and critical thinking skills
What is greenhouse gasses and how many gasses are there to affect the Earth.moosaasad1975
What are greenhouse gasses how they affect the earth and its environment what is the future of the environment and earth how the weather and the climate effects.
The debris of the ‘last major merger’ is dynamically youngSérgio Sacani
The Milky Way’s (MW) inner stellar halo contains an [Fe/H]-rich component with highly eccentric orbits, often referred to as the
‘last major merger.’ Hypotheses for the origin of this component include Gaia-Sausage/Enceladus (GSE), where the progenitor
collided with the MW proto-disc 8–11 Gyr ago, and the Virgo Radial Merger (VRM), where the progenitor collided with the
MW disc within the last 3 Gyr. These two scenarios make different predictions about observable structure in local phase space,
because the morphology of debris depends on how long it has had to phase mix. The recently identified phase-space folds in Gaia
DR3 have positive caustic velocities, making them fundamentally different than the phase-mixed chevrons found in simulations
at late times. Roughly 20 per cent of the stars in the prograde local stellar halo are associated with the observed caustics. Based
on a simple phase-mixing model, the observed number of caustics are consistent with a merger that occurred 1–2 Gyr ago.
We also compare the observed phase-space distribution to FIRE-2 Latte simulations of GSE-like mergers, using a quantitative
measurement of phase mixing (2D causticality). The observed local phase-space distribution best matches the simulated data
1–2 Gyr after collision, and certainly not later than 3 Gyr. This is further evidence that the progenitor of the ‘last major merger’
did not collide with the MW proto-disc at early times, as is thought for the GSE, but instead collided with the MW disc within
the last few Gyr, consistent with the body of work surrounding the VRM.
Unlocking the mysteries of reproduction: Exploring fecundity and gonadosomati...AbdullaAlAsif1
The pygmy halfbeak Dermogenys colletei, is known for its viviparous nature, this presents an intriguing case of relatively low fecundity, raising questions about potential compensatory reproductive strategies employed by this species. Our study delves into the examination of fecundity and the Gonadosomatic Index (GSI) in the Pygmy Halfbeak, D. colletei (Meisner, 2001), an intriguing viviparous fish indigenous to Sarawak, Borneo. We hypothesize that the Pygmy halfbeak, D. colletei, may exhibit unique reproductive adaptations to offset its low fecundity, thus enhancing its survival and fitness. To address this, we conducted a comprehensive study utilizing 28 mature female specimens of D. colletei, carefully measuring fecundity and GSI to shed light on the reproductive adaptations of this species. Our findings reveal that D. colletei indeed exhibits low fecundity, with a mean of 16.76 ± 2.01, and a mean GSI of 12.83 ± 1.27, providing crucial insights into the reproductive mechanisms at play in this species. These results underscore the existence of unique reproductive strategies in D. colletei, enabling its adaptation and persistence in Borneo's diverse aquatic ecosystems, and call for further ecological research to elucidate these mechanisms. This study lends to a better understanding of viviparous fish in Borneo and contributes to the broader field of aquatic ecology, enhancing our knowledge of species adaptations to unique ecological challenges.
ANAMOLOUS SECONDARY GROWTH IN DICOT ROOTS.pptxRASHMI M G
Abnormal or anomalous secondary growth in plants. It defines secondary growth as an increase in plant girth due to vascular cambium or cork cambium. Anomalous secondary growth does not follow the normal pattern of a single vascular cambium producing xylem internally and phloem externally.
The binding of cosmological structures by massless topological defectsSérgio Sacani
Assuming spherical symmetry and weak field, it is shown that if one solves the Poisson equation or the Einstein field
equations sourced by a topological defect, i.e. a singularity of a very specific form, the result is a localized gravitational
field capable of driving flat rotation (i.e. Keplerian circular orbits at a constant speed for all radii) of test masses on a thin
spherical shell without any underlying mass. Moreover, a large-scale structure which exploits this solution by assembling
concentrically a number of such topological defects can establish a flat stellar or galactic rotation curve, and can also deflect
light in the same manner as an equipotential (isothermal) sphere. Thus, the need for dark matter or modified gravity theory is
mitigated, at least in part.
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...University of Maribor
Slides from talk:
Aleš Zamuda: Remote Sensing and Computational, Evolutionary, Supercomputing, and Intelligent Systems.
11th International Conference on Electrical, Electronics and Computer Engineering (IcETRAN), Niš, 3-6 June 2024
Inter-Society Networking Panel GRSS/MTT-S/CIS Panel Session: Promoting Connection and Cooperation
https://www.etran.rs/2024/en/home-english/
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...University of Maribor
Slides from:
11th International Conference on Electrical, Electronics and Computer Engineering (IcETRAN), Niš, 3-6 June 2024
Track: Artificial Intelligence
https://www.etran.rs/2024/en/home-english/
ESR spectroscopy in liquid food and beverages.pptxPRIYANKA PATEL
With increasing population, people need to rely on packaged food stuffs. Packaging of food materials requires the preservation of food. There are various methods for the treatment of food to preserve them and irradiation treatment of food is one of them. It is the most common and the most harmless method for the food preservation as it does not alter the necessary micronutrients of food materials. Although irradiated food doesn’t cause any harm to the human health but still the quality assessment of food is required to provide consumers with necessary information about the food. ESR spectroscopy is the most sophisticated way to investigate the quality of the food and the free radicals induced during the processing of the food. ESR spin trapping technique is useful for the detection of highly unstable radicals in the food. The antioxidant capability of liquid food and beverages in mainly performed by spin trapping technique.
2. The plan!
Basics: data types (and operations & calculations)
Basics: conditionals & iteration
Basics: lists, tuples, dictionaries
Basics: writing functions
Reading & writing files: opening, parsing & formats
Working with numbers: numpy & scipy
Making plots: matplotlib & pylab
… if you guys want more after all of that …
Writing better code: functions, pep8, classes
Working with numbers: Numpy & Scipy (advanced)
Other modules: Pandas & Scikit-learn
Interactive notebooks: ipython & jupyter
Advanced topics: virtual environments & version control
4. lists
# define a list:
mylist = [5, 3, 1, "a", [12, 14, 16],]
# indexing and slicing:
print mylist[2]
print mylist[:4]
# changing elements
mylist[2] = 300
print mylist
Using an existing list with methods:
mylist.method()
Finding things:
.index(element) ← first only
.count(element)
Removing things:
.pop(<pos>) ← returns element
.remove(element)
Adding things:
.append(element)
.insert(pos, element)
.extend(newlist)
also useful: len(list)
copying lists: list2 = list(list1)
5. lists, loops and conditionals
---- somefile.py ----
# lets take a close look at "range":
a = range(10)
print type(a) # (note: different in python 3)
6. lists, loops and conditionals
---- somefile.py ----
# lets take a close look at "range":
a = range(10)
print type(a) # (note: different in python 3)
# using lists in loops:
somelist = [1, 2, "a", "b", "hello", 3.0, 99]
for element in somelist:
print element, "is of type:", type(element)
7. lists, loops and conditionals
---- somefile.py ----
# lets take a close look at "range":
a = range(10)
print type(a) # (note: different in python 3)
# using lists in loops:
somelist = [1, 2, "a", "b", "hello", 3.0, 99]
for element in somelist:
print element, "is of type:", type(element)
# using lists in conditionals:
if "a" in somelist:
print "a is in the list"
Using in with lists:
for var in list:
do stuff in loop
if var in list:
do "True" block
else:
do "False" block
8. lists, loops and conditionals
---- somefile.py ----
# lets take a close look at "range":
a = range(10)
print type(a) # (note: different in python 3)
# using lists in loops:
somelist = [1, 2, "a", "b", "hello", 3.0, 99]
for element in somelist:
print element, "is of type:", type(element)
# using lists in conditionals:
if "a" in somelist:
print "a is in the list"
# using lists in tests and conditionals:
mylist = [1, 2, "a", "b", "hello", 99]
for a in range(100):
if a in mylist:
print a, "is in the list!"
Using in with lists:
for var in list:
do stuff in loop
if var in list:
do "True" block
else:
do "False" block
9. - you can download this from our drive: hamcakes_script
- How many ingredients are there in total (in the snack)?
- Are there any in the "snack" which are not in "pancakes" or "hamburger"? (add
these to the correct list)
- By majority vote: is it a pancake or hamburger?
hamcake!
# you should be able to copy-paste this :)
snack = [
"chocolate", "strawberries", "salad", "chocolate", "salad", "cheese", "cream", "cheese", "tomatoes", "bacon", "bacon", "tomatoes", "burger", "onions", "cheese",
"banana", "pineapple", "tomatoes", "bacon", "cheese", "burger", "salad", "tomatoes", "onions", "chocolate", "pineapple", "tomatoes", "onions", "salad",
"strawberries",
"egg", "cheese", "tomatoes", "burger", "bacon", "cream", "sugar", "burger", "ketchup", "salad", "chocolate", "cream", "egg", "sugar", "salad", "pineapple", "bacon",
"cheese", "bacon",
]
pancake = [ "chocolate", "strawberries", "chocolate", "cream", "pineapple", "sugar",]
hamburger = [ "tomatoes", "bacon", "cheese", "burger", "salad", "onions", "egg", ]
10. dictionaries!
---- animals.py ----
# Creating a dictionary. Note the use of "{" and "}"
# The ":" separates pairs of "keys" and "values"
sounds = {"cat": "meow", "dog": "woof"}
11. dictionaries!
---- animals.py ----
# Creating a dictionary. Note the use of "{" and "}"
# The ":" separates pairs of "keys" and "values"
sounds = {"cat": "meow", "dog": "woof"}
Creating a dictionary:
var = { key-1: value-1, key-2: value-2 … }
keys: Can be strings or numbers (integers, floats).
(or even tuples!)
values: Can be any valid python object
12. dictionaries!
---- animals.py ----
# Creating a dictionary. Note the use of "{" and "}"
# The ":" separates pairs of "keys" and "values"
sounds = {"cat": "meow", "dog": "woof"}
# using the key to find a value
print sounds["cat"]
# adding and changing an element
sounds["cow"] = "quack"
print sounds
# keys can be strings, ints, floats, or even tuples
sounds[5] = "highfive!"
print sounds
# keys can be strings, ints, floats, or even tuples
sounds[13] = ["llama", 8, "potato"]
print sounds
Creating a dictionary:
var = { key-1: value-1, key-2: value-2 … }
keys: Can be strings or numbers (integers, floats).
(or even tuples!)
values: Can be any valid python object
13. dictionaries!
---- animals.py ----
# Creating a dictionary. Note the use of "{" and "}"
# The ":" separates pairs of "keys" and "values"
sounds = {"cat": "meow", "dog": "woof"}
# using the key to find a value
print sounds["cat"]
# adding and changing an element
sounds["cow"] = "quack"
print sounds
# keys can be strings, ints, floats, or even tuples
sounds[5] = "highfive!"
print sounds
# keys can be strings, ints, floats, or even tuples
sounds[13] = ["llama", 8, "potato"]
print sounds
Creating a dictionary:
var = { key-1: value-1, key-2: value-2 … }
keys: Can be strings or numbers (integers, floats).
(or even tuples!)
values: Can be any valid python object
14. dictionaries!
---- animals.py ----
# Creating a dictionary. Note the use of "{" and "}"
# The ":" separates pairs of "keys" and "values"
sounds = {"cat": "meow", "dog": "woof"}
# using the key to find a value
print sounds["cat"]
# adding and changing an element
sounds["cow"] = "quack"
print sounds
# keys can be strings, ints, floats, or even tuples
sounds[5] = "highfive!"
print sounds
# keys can be strings, ints, floats, or even tuples
sounds[13] = ["llama", 8, "potato"]
print sounds
Creating a dictionary:
var = { key-1: value-1, key-2: value-2 … }
keys: Can be strings or numbers (integers, floats).
(or even tuples!)
values: Can be any valid python object
dictionaries are not ordered!
15. dictionaries!
---- animals.py (cont) ----
# updating an existing dictionary
jungle = {"tiger": "roar", "elephant": "fwaaaap"}
sounds.update(jungle)
print sounds
# accessing keys and values
print sounds.keys()
vals = sounds.value()
print vals
print type(vals)
print sounds.items()
# deleting an entry
print sounds
del sounds["tiger"]
print sounds
# oh yeah.. the len of a dict:
print len(sounds)
Dictionary methods:
mydict.method()
Adding one dictionary to another:
.update(dict)
Accessing keys/values:
.keys()
.values()
.items()
Not methods, but useful too:
len(dict)
del dict[‘key’]
16. copying dictionaries
---- file contents ----
# making a copy of a dictionary:
dict1 = {1: 2, 3: 12}
dict2 = dict1
dict3 = dict1.copy()
dict1["extra"] = "things"
print dict1
print dict2
print dict3
"=" does not copy a dict!
dict2 = dict1 ← are the same dict
… use:
dict2 = d.copy()
17. loops + dictionaries!
---- animals.py (cont) ----
sounds = {"cat": "meow", "dog": "woof", "tiger": "roar", "elephant": "fwaaaap"}
# looping over all keys
keys = sounds.keys()
for key in keys:
print “Looping to animal:”, key
18. loops + dictionaries!
---- animals.py (cont) ----
sounds = {"cat": "meow", "dog": "woof", "tiger": "roar", "elephant": "fwaaaap"}
# looping over all keys
keys = sounds.keys()
for key in keys:
print “Looping to animal:”, key
# looping over all values
values = sounds.values()
for val in values:
print “A noise is:”, val
# looping over all keys (again)
for key in sounds.keys():
print “The”, key, “says:” sound[key]
# looping over all key/value pairs
for key, value in sounds.items():
print “The”, key, “says:” value
Dictionaries in loops:
for key in mydict.keys():
Loop over keys
for value in mydict.values():
Loop over values
for key, value in mydict.items():
Loop over key/value pairs
for key in mydict:
Shorthand to loop over keys
19. loops + dictionaries!
---- animals.py (cont) ----
sounds = {"cat": "meow", "dog": "woof", "tiger": "roar", "elephant": "fwaaaap"}
# checking if a key exists:
if “cat” in sounds:
print “Cat is in sounds.”
# by default, this only works for keys
if “meow” in sounds:
print “Meow is in sounds”
else:
print “Meow is NOT in sounds”
# if we need to check values, use values()
if “meow” in sounds.values:
print “Meow is in sounds (a value)”
else:
print “Meow is NOT in sounds (values)”
Dictionaries in loops:
if key in mydict:
check if key is in the dictionary
20. 1. Write a script that prints the song.
Animal Orchestra:
# you should be able to copy-paste this :)
sounds = {"cat": "meow", "dog": "woof", "squirrel": "braaaap"}
song = ["dog", "cat", "dog", "squirrel", "dog", "cat", "dog", "squirrel", "dog", "squirrel",]
21. 1. Write a script that prints the song.
2. Elvis (the squirrel) has left the building! Modify the script to write the song as
before, but leave an empty space when Elvis’ part should have been (use key in
dict).
Animal Orchestra:
# you should be able to copy-paste this :)
sounds = {"cat": "meow", "dog": "woof", "squirrel": "braaaap"}
song = ["dog", "cat", "dog", "squirrel", "dog", "cat", "dog", "squirrel", "dog", "squirrel",]
22. 1. Write a script that prints the song.
2. Elvis (the squirrel) has left the building! Modify the script to write the song as
before, but leave an empty space when Elvis’ part should have been (use key in
dict).
3. The replacement has arrived! Prompt the user for the sound that the new squirrel
names. Update the dictionary to reflect these changes, and write the new song.
Animal Orchestra:
# you should be able to copy-paste this :)
sounds = {"cat": "meow", "dog": "woof", "squirrel": "braaaap"}
song = ["dog", "cat", "dog", "squirrel", "dog", "cat", "dog", "squirrel", "dog", "squirrel",]