SlideShare a Scribd company logo
1 of 30
Download to read offline
You are encouraged to start up
Spyder. If you do so, you can try
out the examples while listening. If
you prefer to listen only, that’s fine as
well.
Basics Exercise Next meetings
Big Data and Automated Content Analysis
Week 2 – Monday
»Getting started with Python«
Damian Trilling
d.c.trilling@uva.nl
@damian0604
www.damiantrilling.net
Afdeling Communicatiewetenschap
Universiteit van Amsterdam
4 April 2016
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Today
1 The very, very, basics of programming with Python
Datatypes
Indention: The Python way of structuring your program
2 Exercise
3 Next meetings
Big Data and Automated Content Analysis Damian Trilling
The very, very, basics of programming
You’ve read all this in chapter 3.
Basics Exercise Next meetings
Datatypes
Python lingo
Basic datatypes (variables)
int 32
float 1.75
bool True, False
string "Damian"
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Datatypes
Python lingo
Basic datatypes (variables)
int 32
float 1.75
bool True, False
string "Damian"
variable name firstname
"firstname" and firstname is not the same.
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Datatypes
Python lingo
Basic datatypes (variables)
int 32
float 1.75
bool True, False
string "Damian"
variable name firstname
"firstname" and firstname is not the same.
"5" and 5 is not the same.
But you can transform it: int("5") will return 5.
You cannot calculate 3 * "5".
But you can calculate 3 * int("5")
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Datatypes
Python lingo
More advanced datatypes
Note that the elements of a list, the keys of a dict, and the values
of a dict can have any datatype! (It should be consistent, though!)
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Datatypes
Python lingo
More advanced datatypes
list firstnames = [’Damian’,’Lori’,’Bjoern’]
lastnames =
[’Trilling’,’Meester’,’Burscher’]
Note that the elements of a list, the keys of a dict, and the values
of a dict can have any datatype! (It should be consistent, though!)
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Datatypes
Python lingo
More advanced datatypes
list firstnames = [’Damian’,’Lori’,’Bjoern’]
lastnames =
[’Trilling’,’Meester’,’Burscher’]
list ages = [18,22,45,23]
Note that the elements of a list, the keys of a dict, and the values
of a dict can have any datatype! (It should be consistent, though!)
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Datatypes
Python lingo
More advanced datatypes
list firstnames = [’Damian’,’Lori’,’Bjoern’]
lastnames =
[’Trilling’,’Meester’,’Burscher’]
list ages = [18,22,45,23]
dict familynames= {’Bjoern’: ’Burscher’,
’Damian’: ’Trilling’, ’Lori’: ’Meester’}
dict {’Bjoern’: 26, ’Damian’: 31, ’Lori’:
25}
Note that the elements of a list, the keys of a dict, and the values
of a dict can have any datatype! (It should be consistent, though!)
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Datatypes
Python lingo
Functions
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Datatypes
Python lingo
Functions
functions Take an input and return something else
int(32.43) returns the integer 32. len("Hello")
returns the integer 5.
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Datatypes
Python lingo
Functions
functions Take an input and return something else
int(32.43) returns the integer 32. len("Hello")
returns the integer 5.
methods are similar to functions, but directly associated with
an object. "SCREAM".lower() returns the string
"scream"
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Datatypes
Python lingo
Functions
functions Take an input and return something else
int(32.43) returns the integer 32. len("Hello")
returns the integer 5.
methods are similar to functions, but directly associated with
an object. "SCREAM".lower() returns the string
"scream"
Both functions and methods end with (). Between the (),
arguments can (sometimes have to) be supplied.
Big Data and Automated Content Analysis Damian Trilling
Indention: The Python way of structuring your program
Basics Exercise Next meetings
Indention
Indention
Structure
The program is structured by TABs or SPACEs
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Indention
Indention
Structure
The program is structured by TABs or SPACEs
1 firstnames=[’Damian’,’Lori’,’Bjoern’]
2 age={’Bjoern’: 27, ’Damian’: 32, ’Lori’: 26}
3 print ("The names and ages of all BigData people:")
4 for naam in firstnames:
5 print (naam,age[naam])
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Indention
Indention
Structure
The program is structured by TABs or SPACEs
1 firstnames=[’Damian’,’Lori’,’Bjoern’]
2 age={’Bjoern’: 27, ’Damian’: 32, ’Lori’: 26}
3 print ("The names and ages of all BigData people:")
4 for naam in firstnames:
5 print (naam,age[naam])
Don’t mix up TABs and spaces! Both are valid, but you have
to be consequent!!! Best: always use 4 spaces!
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Indention
Indention
Structure
The program is structured by TABs or SPACEs
1 print ("The names and ages of all BigData people:")
2 for naam in firstnames:
3 print (naam,age[naam])
4 if naam=="Damian":
5 print ("He teaches this course")
6 elif naam=="Lori":
7 print ("She was an assistant last year")
8 elif naam=="Bjoern":
9 print ("He helps on Wednesdays")
10 else:
11 print ("No idea who this is")
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Indention
Indention
The line before an indented block starts with a statement
indicating what should be done with the block and ends with a :
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Indention
Indention
The line before an indented block starts with a statement
indicating what should be done with the block and ends with a :
Indention of the block indicates that
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Indention
Indention
The line before an indented block starts with a statement
indicating what should be done with the block and ends with a :
Indention of the block indicates that
• it is to be executed repeatedly (for statement) – e.g., for
each element from a list
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Indention
Indention
The line before an indented block starts with a statement
indicating what should be done with the block and ends with a :
Indention of the block indicates that
• it is to be executed repeatedly (for statement) – e.g., for
each element from a list
• it is only to be executed under specific conditions (if, elif,
and else statements)
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Indention
Indention
The line before an indented block starts with a statement
indicating what should be done with the block and ends with a :
Indention of the block indicates that
• it is to be executed repeatedly (for statement) – e.g., for
each element from a list
• it is only to be executed under specific conditions (if, elif,
and else statements)
• an alternative block should be executed if an error occurs
(try and except statements)
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Indention
Indention
The line before an indented block starts with a statement
indicating what should be done with the block and ends with a :
Indention of the block indicates that
• it is to be executed repeatedly (for statement) – e.g., for
each element from a list
• it is only to be executed under specific conditions (if, elif,
and else statements)
• an alternative block should be executed if an error occurs
(try and except statements)
• a file is opened, but should be closed again after the block has
been executed (with statement)
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
We’ll now together do a simple exercise . . .
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Next meetings
Big Data and Automated Content Analysis Damian Trilling
Basics Exercise Next meetings
Wednesday
We will work together on “Describing an existing structured
dataset” (Appendix of the book).
Preparation: Make sure you understood all of today’s
concepts!
Big Data and Automated Content Analysis Damian Trilling

More Related Content

What's hot

The Web of Data: do we actually understand what we built?
The Web of Data: do we actually understand what we built?The Web of Data: do we actually understand what we built?
The Web of Data: do we actually understand what we built?Frank van Harmelen
 
From TREC to Watson: is open domain question answering a solved problem?
From TREC to Watson: is open domain question answering a solved problem?From TREC to Watson: is open domain question answering a solved problem?
From TREC to Watson: is open domain question answering a solved problem?Constantin Orasan
 
Big Data LDN 2017: Machine Learning on Structured Data. Why Is Learning Rules...
Big Data LDN 2017: Machine Learning on Structured Data. Why Is Learning Rules...Big Data LDN 2017: Machine Learning on Structured Data. Why Is Learning Rules...
Big Data LDN 2017: Machine Learning on Structured Data. Why Is Learning Rules...Matt Stubbs
 

What's hot (20)

BDACA1617s2 - Lecture3
BDACA1617s2 - Lecture3BDACA1617s2 - Lecture3
BDACA1617s2 - Lecture3
 
BDACA1617s2 - Lecture 2
BDACA1617s2 - Lecture 2BDACA1617s2 - Lecture 2
BDACA1617s2 - Lecture 2
 
BDACA1617s2 - Tutorial 1
BDACA1617s2 - Tutorial 1BDACA1617s2 - Tutorial 1
BDACA1617s2 - Tutorial 1
 
BDACA1617s2 - Lecture4
BDACA1617s2 - Lecture4BDACA1617s2 - Lecture4
BDACA1617s2 - Lecture4
 
BD-ACA week5
BD-ACA week5BD-ACA week5
BD-ACA week5
 
BD-ACA week3a
BD-ACA week3aBD-ACA week3a
BD-ACA week3a
 
Analyzing social media with Python and other tools (1/4)
Analyzing social media with Python and other tools (1/4)Analyzing social media with Python and other tools (1/4)
Analyzing social media with Python and other tools (1/4)
 
BD-ACA week2
BD-ACA week2BD-ACA week2
BD-ACA week2
 
BDACA - Lecture4
BDACA - Lecture4BDACA - Lecture4
BDACA - Lecture4
 
BD-ACA week1a
BD-ACA week1aBD-ACA week1a
BD-ACA week1a
 
BDACA - Lecture6
BDACA - Lecture6BDACA - Lecture6
BDACA - Lecture6
 
BDACA - Lecture7
BDACA - Lecture7BDACA - Lecture7
BDACA - Lecture7
 
BDACA - Lecture8
BDACA - Lecture8BDACA - Lecture8
BDACA - Lecture8
 
Analyzing social media with Python and other tools (2/4)
Analyzing social media with Python and other tools (2/4) Analyzing social media with Python and other tools (2/4)
Analyzing social media with Python and other tools (2/4)
 
Working with text data
Working with text dataWorking with text data
Working with text data
 
Basics of IR: Web Information Systems class
Basics of IR: Web Information Systems class Basics of IR: Web Information Systems class
Basics of IR: Web Information Systems class
 
The Web of Data: do we actually understand what we built?
The Web of Data: do we actually understand what we built?The Web of Data: do we actually understand what we built?
The Web of Data: do we actually understand what we built?
 
From TREC to Watson: is open domain question answering a solved problem?
From TREC to Watson: is open domain question answering a solved problem?From TREC to Watson: is open domain question answering a solved problem?
From TREC to Watson: is open domain question answering a solved problem?
 
Data Visualization at Twitter
Data Visualization at TwitterData Visualization at Twitter
Data Visualization at Twitter
 
Big Data LDN 2017: Machine Learning on Structured Data. Why Is Learning Rules...
Big Data LDN 2017: Machine Learning on Structured Data. Why Is Learning Rules...Big Data LDN 2017: Machine Learning on Structured Data. Why Is Learning Rules...
Big Data LDN 2017: Machine Learning on Structured Data. Why Is Learning Rules...
 

Viewers also liked (13)

Taller de refuerzo 1
Taller de refuerzo 1Taller de refuerzo 1
Taller de refuerzo 1
 
PCM
PCMPCM
PCM
 
e0101
e0101e0101
e0101
 
Presentacion
PresentacionPresentacion
Presentacion
 
Viennapharmacia ltd
Viennapharmacia ltdViennapharmacia ltd
Viennapharmacia ltd
 
BDACA1516s2 - Lecture4
 BDACA1516s2 - Lecture4 BDACA1516s2 - Lecture4
BDACA1516s2 - Lecture4
 
Reunió pedagògica 1r 2016 2017 definitiva
Reunió pedagògica 1r 2016 2017 definitivaReunió pedagògica 1r 2016 2017 definitiva
Reunió pedagògica 1r 2016 2017 definitiva
 
People, Culture, & Perceptions
People, Culture, & PerceptionsPeople, Culture, & Perceptions
People, Culture, & Perceptions
 
Conceptualizing and measuring news exposure as network of users and news items
Conceptualizing and measuring news exposure as network of users and news itemsConceptualizing and measuring news exposure as network of users and news items
Conceptualizing and measuring news exposure as network of users and news items
 
6.1 the roman republic
6.1 the roman republic6.1 the roman republic
6.1 the roman republic
 
Andean Summit Mini Agenda
Andean Summit Mini AgendaAndean Summit Mini Agenda
Andean Summit Mini Agenda
 
Ejercicios de retroalimentacion
Ejercicios de retroalimentacionEjercicios de retroalimentacion
Ejercicios de retroalimentacion
 
Tipos de cromosomas
Tipos de cromosomasTipos de cromosomas
Tipos de cromosomas
 

Similar to BDACA1516s2 - Lecture2

Coding in Kotlin with Arrow NIDC 2018
Coding in Kotlin with Arrow NIDC 2018Coding in Kotlin with Arrow NIDC 2018
Coding in Kotlin with Arrow NIDC 2018Garth Gilmour
 
What is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red Team
What is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red TeamWhat is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red Team
What is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red TeamMITRE ATT&CK
 
Class 27: Pythonic Objects
Class 27: Pythonic ObjectsClass 27: Pythonic Objects
Class 27: Pythonic ObjectsDavid Evans
 
Write better python code with these 10 tricks | by yong cui, ph.d. | aug, 202...
Write better python code with these 10 tricks | by yong cui, ph.d. | aug, 202...Write better python code with these 10 tricks | by yong cui, ph.d. | aug, 202...
Write better python code with these 10 tricks | by yong cui, ph.d. | aug, 202...amit kuraria
 
These questions will be a bit advanced level 2
These questions will be a bit advanced level 2These questions will be a bit advanced level 2
These questions will be a bit advanced level 2sadhana312471
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python amiable_indian
 
A Gentle Introduction to Coding ... with Python
A Gentle Introduction to Coding ... with PythonA Gentle Introduction to Coding ... with Python
A Gentle Introduction to Coding ... with PythonTariq Rashid
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python ProgrammingDozie Agbo
 
Programming in Python
Programming in Python Programming in Python
Programming in Python Tiji Thomas
 
Python for Security Professionals
Python for Security ProfessionalsPython for Security Professionals
Python for Security ProfessionalsAditya Shankar
 
Python Interview Questions | Python Interview Questions And Answers | Python ...
Python Interview Questions | Python Interview Questions And Answers | Python ...Python Interview Questions | Python Interview Questions And Answers | Python ...
Python Interview Questions | Python Interview Questions And Answers | Python ...Simplilearn
 
JavaScript Best Pratices
JavaScript Best PraticesJavaScript Best Pratices
JavaScript Best PraticesChengHui Weng
 

Similar to BDACA1516s2 - Lecture2 (20)

BDACA - Lecture2
BDACA - Lecture2BDACA - Lecture2
BDACA - Lecture2
 
BDACA - Lecture3
BDACA - Lecture3BDACA - Lecture3
BDACA - Lecture3
 
Coding in Kotlin with Arrow NIDC 2018
Coding in Kotlin with Arrow NIDC 2018Coding in Kotlin with Arrow NIDC 2018
Coding in Kotlin with Arrow NIDC 2018
 
Python cheat-sheet
Python cheat-sheetPython cheat-sheet
Python cheat-sheet
 
BD-ACA week7a
BD-ACA week7aBD-ACA week7a
BD-ACA week7a
 
What is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red Team
What is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red TeamWhat is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red Team
What is ATT&CK coverage, anyway? Breadth and depth analysis with Atomic Red Team
 
Class 27: Pythonic Objects
Class 27: Pythonic ObjectsClass 27: Pythonic Objects
Class 27: Pythonic Objects
 
Write better python code with these 10 tricks | by yong cui, ph.d. | aug, 202...
Write better python code with these 10 tricks | by yong cui, ph.d. | aug, 202...Write better python code with these 10 tricks | by yong cui, ph.d. | aug, 202...
Write better python code with these 10 tricks | by yong cui, ph.d. | aug, 202...
 
Dynamic Python
Dynamic PythonDynamic Python
Dynamic Python
 
These questions will be a bit advanced level 2
These questions will be a bit advanced level 2These questions will be a bit advanced level 2
These questions will be a bit advanced level 2
 
Python45 2
Python45 2Python45 2
Python45 2
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python
 
A Gentle Introduction to Coding ... with Python
A Gentle Introduction to Coding ... with PythonA Gentle Introduction to Coding ... with Python
A Gentle Introduction to Coding ... with Python
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python Programming
 
Clean code
Clean codeClean code
Clean code
 
Programming in Python
Programming in Python Programming in Python
Programming in Python
 
Python for Security Professionals
Python for Security ProfessionalsPython for Security Professionals
Python for Security Professionals
 
Python Interview Questions | Python Interview Questions And Answers | Python ...
Python Interview Questions | Python Interview Questions And Answers | Python ...Python Interview Questions | Python Interview Questions And Answers | Python ...
Python Interview Questions | Python Interview Questions And Answers | Python ...
 
Python for Dummies
Python for DummiesPython for Dummies
Python for Dummies
 
JavaScript Best Pratices
JavaScript Best PraticesJavaScript Best Pratices
JavaScript Best Pratices
 

More from Department of Communication Science, University of Amsterdam (10)

BDACA - Tutorial5
BDACA - Tutorial5BDACA - Tutorial5
BDACA - Tutorial5
 
BDACA - Lecture5
BDACA - Lecture5BDACA - Lecture5
BDACA - Lecture5
 
BDACA - Tutorial1
BDACA - Tutorial1BDACA - Tutorial1
BDACA - Tutorial1
 
BDACA - Lecture1
BDACA - Lecture1BDACA - Lecture1
BDACA - Lecture1
 
BDACA1617s2 - Lecture 1
BDACA1617s2 - Lecture 1BDACA1617s2 - Lecture 1
BDACA1617s2 - Lecture 1
 
Media diets in an age of apps and social media: Dealing with a third layer of...
Media diets in an age of apps and social media: Dealing with a third layer of...Media diets in an age of apps and social media: Dealing with a third layer of...
Media diets in an age of apps and social media: Dealing with a third layer of...
 
Data Science: Case "Political Communication 2/2"
Data Science: Case "Political Communication 2/2"Data Science: Case "Political Communication 2/2"
Data Science: Case "Political Communication 2/2"
 
Data Science: Case "Political Communication 1/2"
Data Science: Case "Political Communication 1/2"Data Science: Case "Political Communication 1/2"
Data Science: Case "Political Communication 1/2"
 
BDACA1516s2 - Lecture1
BDACA1516s2 - Lecture1BDACA1516s2 - Lecture1
BDACA1516s2 - Lecture1
 
Should we worry about filter bubbles?
Should we worry about filter bubbles?Should we worry about filter bubbles?
Should we worry about filter bubbles?
 

Recently uploaded

Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 

Recently uploaded (20)

Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 

BDACA1516s2 - Lecture2

  • 1. You are encouraged to start up Spyder. If you do so, you can try out the examples while listening. If you prefer to listen only, that’s fine as well.
  • 2. Basics Exercise Next meetings Big Data and Automated Content Analysis Week 2 – Monday »Getting started with Python« Damian Trilling d.c.trilling@uva.nl @damian0604 www.damiantrilling.net Afdeling Communicatiewetenschap Universiteit van Amsterdam 4 April 2016 Big Data and Automated Content Analysis Damian Trilling
  • 3. Basics Exercise Next meetings Today 1 The very, very, basics of programming with Python Datatypes Indention: The Python way of structuring your program 2 Exercise 3 Next meetings Big Data and Automated Content Analysis Damian Trilling
  • 4. The very, very, basics of programming You’ve read all this in chapter 3.
  • 5. Basics Exercise Next meetings Datatypes Python lingo Basic datatypes (variables) int 32 float 1.75 bool True, False string "Damian" Big Data and Automated Content Analysis Damian Trilling
  • 6. Basics Exercise Next meetings Datatypes Python lingo Basic datatypes (variables) int 32 float 1.75 bool True, False string "Damian" variable name firstname "firstname" and firstname is not the same. Big Data and Automated Content Analysis Damian Trilling
  • 7. Basics Exercise Next meetings Datatypes Python lingo Basic datatypes (variables) int 32 float 1.75 bool True, False string "Damian" variable name firstname "firstname" and firstname is not the same. "5" and 5 is not the same. But you can transform it: int("5") will return 5. You cannot calculate 3 * "5". But you can calculate 3 * int("5") Big Data and Automated Content Analysis Damian Trilling
  • 8. Basics Exercise Next meetings Datatypes Python lingo More advanced datatypes Note that the elements of a list, the keys of a dict, and the values of a dict can have any datatype! (It should be consistent, though!) Big Data and Automated Content Analysis Damian Trilling
  • 9. Basics Exercise Next meetings Datatypes Python lingo More advanced datatypes list firstnames = [’Damian’,’Lori’,’Bjoern’] lastnames = [’Trilling’,’Meester’,’Burscher’] Note that the elements of a list, the keys of a dict, and the values of a dict can have any datatype! (It should be consistent, though!) Big Data and Automated Content Analysis Damian Trilling
  • 10. Basics Exercise Next meetings Datatypes Python lingo More advanced datatypes list firstnames = [’Damian’,’Lori’,’Bjoern’] lastnames = [’Trilling’,’Meester’,’Burscher’] list ages = [18,22,45,23] Note that the elements of a list, the keys of a dict, and the values of a dict can have any datatype! (It should be consistent, though!) Big Data and Automated Content Analysis Damian Trilling
  • 11. Basics Exercise Next meetings Datatypes Python lingo More advanced datatypes list firstnames = [’Damian’,’Lori’,’Bjoern’] lastnames = [’Trilling’,’Meester’,’Burscher’] list ages = [18,22,45,23] dict familynames= {’Bjoern’: ’Burscher’, ’Damian’: ’Trilling’, ’Lori’: ’Meester’} dict {’Bjoern’: 26, ’Damian’: 31, ’Lori’: 25} Note that the elements of a list, the keys of a dict, and the values of a dict can have any datatype! (It should be consistent, though!) Big Data and Automated Content Analysis Damian Trilling
  • 12. Basics Exercise Next meetings Datatypes Python lingo Functions Big Data and Automated Content Analysis Damian Trilling
  • 13. Basics Exercise Next meetings Datatypes Python lingo Functions functions Take an input and return something else int(32.43) returns the integer 32. len("Hello") returns the integer 5. Big Data and Automated Content Analysis Damian Trilling
  • 14. Basics Exercise Next meetings Datatypes Python lingo Functions functions Take an input and return something else int(32.43) returns the integer 32. len("Hello") returns the integer 5. methods are similar to functions, but directly associated with an object. "SCREAM".lower() returns the string "scream" Big Data and Automated Content Analysis Damian Trilling
  • 15. Basics Exercise Next meetings Datatypes Python lingo Functions functions Take an input and return something else int(32.43) returns the integer 32. len("Hello") returns the integer 5. methods are similar to functions, but directly associated with an object. "SCREAM".lower() returns the string "scream" Both functions and methods end with (). Between the (), arguments can (sometimes have to) be supplied. Big Data and Automated Content Analysis Damian Trilling
  • 16. Indention: The Python way of structuring your program
  • 17. Basics Exercise Next meetings Indention Indention Structure The program is structured by TABs or SPACEs Big Data and Automated Content Analysis Damian Trilling
  • 18.
  • 19. Basics Exercise Next meetings Indention Indention Structure The program is structured by TABs or SPACEs 1 firstnames=[’Damian’,’Lori’,’Bjoern’] 2 age={’Bjoern’: 27, ’Damian’: 32, ’Lori’: 26} 3 print ("The names and ages of all BigData people:") 4 for naam in firstnames: 5 print (naam,age[naam]) Big Data and Automated Content Analysis Damian Trilling
  • 20. Basics Exercise Next meetings Indention Indention Structure The program is structured by TABs or SPACEs 1 firstnames=[’Damian’,’Lori’,’Bjoern’] 2 age={’Bjoern’: 27, ’Damian’: 32, ’Lori’: 26} 3 print ("The names and ages of all BigData people:") 4 for naam in firstnames: 5 print (naam,age[naam]) Don’t mix up TABs and spaces! Both are valid, but you have to be consequent!!! Best: always use 4 spaces! Big Data and Automated Content Analysis Damian Trilling
  • 21. Basics Exercise Next meetings Indention Indention Structure The program is structured by TABs or SPACEs 1 print ("The names and ages of all BigData people:") 2 for naam in firstnames: 3 print (naam,age[naam]) 4 if naam=="Damian": 5 print ("He teaches this course") 6 elif naam=="Lori": 7 print ("She was an assistant last year") 8 elif naam=="Bjoern": 9 print ("He helps on Wednesdays") 10 else: 11 print ("No idea who this is") Big Data and Automated Content Analysis Damian Trilling
  • 22. Basics Exercise Next meetings Indention Indention The line before an indented block starts with a statement indicating what should be done with the block and ends with a : Big Data and Automated Content Analysis Damian Trilling
  • 23. Basics Exercise Next meetings Indention Indention The line before an indented block starts with a statement indicating what should be done with the block and ends with a : Indention of the block indicates that Big Data and Automated Content Analysis Damian Trilling
  • 24. Basics Exercise Next meetings Indention Indention The line before an indented block starts with a statement indicating what should be done with the block and ends with a : Indention of the block indicates that • it is to be executed repeatedly (for statement) – e.g., for each element from a list Big Data and Automated Content Analysis Damian Trilling
  • 25. Basics Exercise Next meetings Indention Indention The line before an indented block starts with a statement indicating what should be done with the block and ends with a : Indention of the block indicates that • it is to be executed repeatedly (for statement) – e.g., for each element from a list • it is only to be executed under specific conditions (if, elif, and else statements) Big Data and Automated Content Analysis Damian Trilling
  • 26. Basics Exercise Next meetings Indention Indention The line before an indented block starts with a statement indicating what should be done with the block and ends with a : Indention of the block indicates that • it is to be executed repeatedly (for statement) – e.g., for each element from a list • it is only to be executed under specific conditions (if, elif, and else statements) • an alternative block should be executed if an error occurs (try and except statements) Big Data and Automated Content Analysis Damian Trilling
  • 27. Basics Exercise Next meetings Indention Indention The line before an indented block starts with a statement indicating what should be done with the block and ends with a : Indention of the block indicates that • it is to be executed repeatedly (for statement) – e.g., for each element from a list • it is only to be executed under specific conditions (if, elif, and else statements) • an alternative block should be executed if an error occurs (try and except statements) • a file is opened, but should be closed again after the block has been executed (with statement) Big Data and Automated Content Analysis Damian Trilling
  • 28. Basics Exercise Next meetings We’ll now together do a simple exercise . . . Big Data and Automated Content Analysis Damian Trilling
  • 29. Basics Exercise Next meetings Next meetings Big Data and Automated Content Analysis Damian Trilling
  • 30. Basics Exercise Next meetings Wednesday We will work together on “Describing an existing structured dataset” (Appendix of the book). Preparation: Make sure you understood all of today’s concepts! Big Data and Automated Content Analysis Damian Trilling