These are the slides of the second part of this multi-part series, from Learn Python Den Haag meetup group. It covers List comprehensions, Dictionary comprehensions and functions.
Introduction to the basics of Python programming (part 3)Pedro Rodrigues
This is the 3rd part of a multi-part series that teaches the basics of Python programming. It covers list and dict comprehensions, functions, modules and packages.
The basics of Python are rather straightforward. In a few minutes you can learn most of the syntax. There are some gotchas along the way that might appear tricky. This talk is meant to bring programmers up to speed with Python. They should be able to read and write Python.
Inspired by Josh Bloch's Java Puzzlers, we put together our own Python Puzzlers. This slide deck brings you a set of 10 python puzzlers, that are fun and educational. Each puzzler will show you a piece of python code. Your task if to figure out what happens when the code is run. Whether you're a python beginner or a passionate python veteran, we hope that there's something to learn for everybody.
This slide deck was first presented at shopkick. Nandan Sawant and Ryan Rueth are engineers at shopkick. Keeping the audience in mind, most of the puzzlers are based on python 2.x.
This presentation covers Python most important data structures like Lists, Dictionaries, Sets and Tuples. Exception Handling and Random number generation using simple python module "random" also covered. Added simple python programs at the end of the presentation
Introduction to the basics of Python programming (part 3)Pedro Rodrigues
This is the 3rd part of a multi-part series that teaches the basics of Python programming. It covers list and dict comprehensions, functions, modules and packages.
The basics of Python are rather straightforward. In a few minutes you can learn most of the syntax. There are some gotchas along the way that might appear tricky. This talk is meant to bring programmers up to speed with Python. They should be able to read and write Python.
Inspired by Josh Bloch's Java Puzzlers, we put together our own Python Puzzlers. This slide deck brings you a set of 10 python puzzlers, that are fun and educational. Each puzzler will show you a piece of python code. Your task if to figure out what happens when the code is run. Whether you're a python beginner or a passionate python veteran, we hope that there's something to learn for everybody.
This slide deck was first presented at shopkick. Nandan Sawant and Ryan Rueth are engineers at shopkick. Keeping the audience in mind, most of the puzzlers are based on python 2.x.
This presentation covers Python most important data structures like Lists, Dictionaries, Sets and Tuples. Exception Handling and Random number generation using simple python module "random" also covered. Added simple python programs at the end of the presentation
Python 101++: Let's Get Down to Business!Paige Bailey
You've started the Codecademy and Coursera courses; you've thumbed through Zed Shaw's "Learn Python the Hard Way"; and now you're itching to see what Python can help you do. This is the workshop for you!
Here's the breakdown: we're going to be taking you on a whirlwind tour of Python's capabilities. By the end of the workshop, you should be able to easily follow any of the widely available Python courses on the internet, and have a grasp on some of the more complex aspects of the language.
Please don't forget to bring your personal laptop!
Audience: This course is aimed at those who already have some basic programming experience, either in Python or in another high level programming language (such as C/C++, Fortran, Java, Ruby, Perl, or Visual Basic). If you're an absolute beginner -- new to Python, and new to programming in general -- make sure to check out the "Python 101" workshop!
This presentation is all about various built in
datastructures which we have in python.
List
Dictionary
Tuple
Set
and various methods present in each data structure
Installing and Using Python
Basic I/O
Variables and Expressions
Conditional Code
Functions
Loops and Iteration
Python Data Structures
Errors and Exceptions
Object Oriented with Python
Multithreaded Programming with Python
Install/Create and Using Python Library
Compile Python Script
Resources
===========================
and 7 Quizzes
The presentation from SPb Python Interest Group community meetup.
The presentation tells about the dictionaries in Python, reviews the implementation of dictionary in CPython 2.x, dictionary in CPython 3.x, and also recent changes in CPython 3.6. In addition to CPython the dictionaries in alternative Python implementations such as PyPy, IronPython and Jython are reviewed.
In this chapter we will review how to work with text files in C#. We will explain what a stream is, what its purpose is, and how to use it. We will explain what a text file is and how can you read and write data to a text file and how to deal with different character encodings. We will demonstrate and explain the good practices for exception handling when working with files. All of this will be demonstrated with many examples in this chapter
All data values in Python are encapsulated in relevant object classes. Everything in Python is an object and every object has an identity, a type, and a value. Like another object-oriented language such as Java or C++, there are several data types which are built into Python. Extension modules which are written in C, Java, or other languages can define additional types.
To determine a variable's type in Python you can use the type() function. The value of some objects can be changed. Objects whose value can be changed are called mutable and objects whose value is unchangeable (once they are created) are called immutable.
Introduction to the Python programming language (version 2.x)
Ambient intelligence: technology and design
http://bit.ly/polito-ami
Politecnico di Torino, 2015
Python 101++: Let's Get Down to Business!Paige Bailey
You've started the Codecademy and Coursera courses; you've thumbed through Zed Shaw's "Learn Python the Hard Way"; and now you're itching to see what Python can help you do. This is the workshop for you!
Here's the breakdown: we're going to be taking you on a whirlwind tour of Python's capabilities. By the end of the workshop, you should be able to easily follow any of the widely available Python courses on the internet, and have a grasp on some of the more complex aspects of the language.
Please don't forget to bring your personal laptop!
Audience: This course is aimed at those who already have some basic programming experience, either in Python or in another high level programming language (such as C/C++, Fortran, Java, Ruby, Perl, or Visual Basic). If you're an absolute beginner -- new to Python, and new to programming in general -- make sure to check out the "Python 101" workshop!
This presentation is all about various built in
datastructures which we have in python.
List
Dictionary
Tuple
Set
and various methods present in each data structure
Installing and Using Python
Basic I/O
Variables and Expressions
Conditional Code
Functions
Loops and Iteration
Python Data Structures
Errors and Exceptions
Object Oriented with Python
Multithreaded Programming with Python
Install/Create and Using Python Library
Compile Python Script
Resources
===========================
and 7 Quizzes
The presentation from SPb Python Interest Group community meetup.
The presentation tells about the dictionaries in Python, reviews the implementation of dictionary in CPython 2.x, dictionary in CPython 3.x, and also recent changes in CPython 3.6. In addition to CPython the dictionaries in alternative Python implementations such as PyPy, IronPython and Jython are reviewed.
In this chapter we will review how to work with text files in C#. We will explain what a stream is, what its purpose is, and how to use it. We will explain what a text file is and how can you read and write data to a text file and how to deal with different character encodings. We will demonstrate and explain the good practices for exception handling when working with files. All of this will be demonstrated with many examples in this chapter
All data values in Python are encapsulated in relevant object classes. Everything in Python is an object and every object has an identity, a type, and a value. Like another object-oriented language such as Java or C++, there are several data types which are built into Python. Extension modules which are written in C, Java, or other languages can define additional types.
To determine a variable's type in Python you can use the type() function. The value of some objects can be changed. Objects whose value can be changed are called mutable and objects whose value is unchangeable (once they are created) are called immutable.
Introduction to the Python programming language (version 2.x)
Ambient intelligence: technology and design
http://bit.ly/polito-ami
Politecnico di Torino, 2015
A tour of Python: slides from presentation given in 2012.
[Some slides are not properly rendered in SlideShare: the original is still available at http://www.aleksa.org/2015/04/python-presentation_7.html.]
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Basics of Python programming (part 2)
1. Introduction to the basics of
Python programming
(PART 2)
by Pedro Rodrigues (pedro@startacareerwithpython.com)
2. A little about me
{
“Name”: “Pedro Rodrigues”,
“Origin”: {“Country”: “Angola”, “City”: “Luanda”},
“Lives”: [“Netherlands”, 2013],
“Past”: [“CTO”, “Senior Backend Engineer”],
“Present”: [“Freelance Software Engineer”, “Coach”],
“Other”: [“Book author”, “Start a Career with Python”]
}
3. Why this Meetup Group?
Promote the usage of Python
Gather people from different industries and backgrounds
Teach and Learn
4. What will be covered
List and Dictionary comprehensions
Functions
Positional arguments
Keyword arguments
Default parameter values
Variable number of arguments
Names, namespaces and scope
5. A little recap
Python is an interpreted language (CPython is the reference interpreter)
Variables are names bound to objects stored in memory
Data Types: immutable or mutable
Data Types: Numbers (int, float, bool), Sequences (str, tuple, list, bytes, bytearray),
set, dict
Control Flow: if statement, for loop, while loop
Indentation determines whether a statement belongs to a code block or not
Iterables are container objects capable of returning their elements one at a time
Iterators implement the methods __iter__ and __next__
6. List comprehensions
Concise way to create lists
Each element is a the result of a transformation applied to the original element
Regular way of building lists:
new_list = []
for elem in some_sequence:
new_list.append(do_something(elem))
With list comprehension:
new_list = [do_something(elem) for elem in some_sequence]
7. List comprehensions (examples)
names = ["John", "Mary", "Russell", "Devon", "Elizabeth"]
new_names = []
for name in names:
if len(name) > 4:
new_names.append(name)
>>> names = ["John", "Mary", "Russell", "Devon", "Elizabeth"]
>>> new_names = [name for name in names if len(name) > 4]
>>> new_names
['Russell', 'Devon', 'Elizabeth']
8. List comprehensions (examples)
pairs = []
for i in range(3):
for j in range(3):
if i != j:
pairs.append((i, j))
>>> pairs = [(i, j) for i in range(3) for j in range(3) if i != j]
>>> pairs
[(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)]
9. List comprehensions (challenge)
Use split and sorted to print a sorted list of strings read from the standard input. Use a
list comprehension for build a list where the strings are in lowercase.
Strings in the standard input are separated by commas (no spaces)
Sample input: THIs,is,A,strING,WITH,COMmas
Sample output: ['a', 'commas', 'is', 'string', 'this', 'with']
>>> "Hello,World,how,are,you".split(",")
['Hello', 'World', 'how', 'are', 'you']
>>> sorted(["b", "z", "a", "c", "l"])
['a', 'b', 'c', 'l', 'z']
10. Dictionary comprehensions
Concise way to create dictionaries
Keys and/or Values are the result of applying transformations to elements in the original sequence
Regular way of building a dictionary:
d = {}
for k, v in some_seq:
key = do_something(k)
value = do_something(v)
d[key] = value
With dict comprehension:
d = {do_something(k): do_something(v) for k, v in some_seq}
11. Dictionary comprehensions (examples)
d = {}
for i in range(2, 11, 2):
d[i] = i**2
d = {i: i**2 for i in range(2, 11, 2)}
>>> d
{8: 64, 2: 4, 4: 16, 10: 100, 6: 36}
12. Dictionary comprehensions (examples)
# example: name=Pedro age=34
info = input("> ")
info_list = [item.split("=") for item in info.split(" ")]
info_dict = {}
for k, v in info_list:
key = k.capitalize()
d[key] = v
>>> info_dict
{'Age': '34', 'Name': 'Pedro'}
13. Dictionary comprehensions (examples)
# With dict comprehension
>>> info = input("> ")
>>> d = {k.capitalize(): v for k, v in [item.split("=") for item in info.split(" ")]}
>>> d
{'Age': '34', 'Name': 'Pedro'}
14. Dictionary comprehensions (challenge)
Build a dictionary where the keys are in lowercase and the values are integers,
from a string read from the standard input
Sample input: John=28 Martha=32 Stewart=46 Peter=30
Sample output:
{'stewart': 46, 'peter': 30, 'john': 28, 'martha': 32}
15. Functions
Callable data type
Control Flow construct
def function_name(params_list):
suite
def print_hello_world():
print("Hello")
print("World")
18. Challenge
Read coordinates from standard input and print the distance between the two points.
Use list comprehension and sequence unpacking.
Define a function that takes 4 integers (x1, y1, x2, y2) and returns the distance between
two points: Point 1 (x1, y1), Point 2 (x2, y2).
(𝑥2 − 𝑥1)2+(𝑦2 − 𝑦1)2
>>> import math
>>> math.sqrt(16)
4.0
Sample input: 1 3 7 4
Sample output: 6.082762530298219
20. Keyword arguments
The order of the arguments doesn’t matter
def sum_squares(x, y):
return x**2 + y**2
>>> sum_squares(y=3, x=2)
13
You cannot have a positional argument after a keyword argument
>>> sum_squares(y=3, 2)
22. Default parameter values
For parameters with default value, the corresponding argument can be omitted
def sum_squares(x, y=3):
return x**2 + y**2
>>> sum_squares(2)
13
After the first parameter with default value, all other parameters must have default
value
# Wrong!
def sum_squares(x=2, y):
return x**2 + y**2
23. Default parameter values
Be careful with mutable default values!
names = ["John", "Louise"]
def print_hello(n=names):
for name in n:
print("Hello, ", name)
names.append("Something")
>>> print_hello()
Hello, John
Hello, Louise
>>> names
['John', 'Louise', 'Something']
24. Variable number of arguments
def function_name(*args, **kwargs):
pass
args is initialized as a tuple with positional arguments
kwargs is initialized as a dictionary with keyword arguments
The words args and kwargs are just a convention, they are not reserved in
Python.
29. Challenge
Sample input: x1=1 y1=3 x2=7 y2=4, x1=13 y1=10 x2=109 y2=45
Sample output:
6.082762530298219
102.18121158021175
Use dict comprehension and unpack the dictionary in distance.
30. Names, Namespaces and Scope
Namespace: place where the binding between names and objects are stored.
Different namespaces: built-in, global module namespace, local namespace for
a function, objects namespace.
Scope is a text region that determines whether a namespace is available or not.
Scope influences name resolution.
31. Names, Namespaces and Scope
Global module namespace
x = 10
print(x)
Local namespace of a function
x = 10
def print_x():
x = 5
print(x) # prints 5
32. Names, Namespaces and Scope
Local namespace of a function
x = 10
def print_x():
print(x) # prints 10
33. Names, Namespaces and Scope
People coming from other languages, beware of for loops!
>>> for i in range(3):
... print(i)
...
0
1
2
>>> print(i)
2
34. Names, Namespaces and Scope
Namespaces have different life times:
Local namespace is created when a function is called and destroyed when the function
returns.
Global module namespace is created when the module definition is read in.
Built-in namespace is created when the interpreter starts and is never destroyed during
the program execution.
Global namespace of a function is the global namespace of the module where the
function was defined.
35. Reading material
List comprehensions: https://docs.python.org/3.5/tutorial/datastructures.html#list-
comprehensions
Dict comprehensions:
https://docs.python.org/3.5/tutorial/datastructures.html#dictionaries
Functions and parameters:
https://docs.python.org/3.5/reference/compound_stmts.html#function-definitions
Names, Namespaces and Scopes:
https://docs.python.org/3.5/tutorial/classes.html#a-word-about-names-and-
objects
36. More resources
Python Tutorial: https://docs.python.org/3/tutorial/index.html
Python Language Reference: https://docs.python.org/3/reference/index.html
Slack channel: https://startcareerpython.slack.com/
Start a Career with Python newsletter: https://www.startacareerwithpython.com/
Book: Start a Career with Python
Book 15% off (NZ6SZFBL): https://www.createspace.com/6506874
Editor's Notes
I speak a bit fast, but don’t worry because the presentation will be available online, as well as a Slack channel.
Note that the keys are not ordered, which is normal. If you depend on the order of the keys, use OrderedDict instead.