Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Python Object and
Data Structure Basics
Basic Data Types
Complete Python 3 Bootcamp
● In this section of the course we will cover
the key data types in Python.
● These are your basic building blocks when
constructing larger pieces of code.
● Let’s quickly discuss all of the possible data
types, then we’ll have lectures that go into
more detail about each one!
Complete Python 3 Bootcamp
Name Type Description
Integers int Whole numbers, such as: 3 300 200
Floating point float Numbers with a decimal point: 2.3 4.6 100.0
Strings str Ordered sequence of characters: "hello" 'Sammy' "2000" "楽しい"
Lists list Ordered sequence of objects: [10,"hello",200.3]
Dictionaries dict Unordered Key:Value pairs: {"mykey" : "value" , "name" : "Frankie"}
Tuples tup Ordered immutable sequence of objects: (10,"hello",200.3)
Sets set Unordered collection of unique objects: {"a","b"}
Booleans bool Logical value indicating True or False
Complete Python 3 Bootcamp
Name Type Description
Integers int Whole numbers, such as: 3 300 200
Floating point float Numbers with a decimal point: 2.3 4.6 100.0
Strings str Ordered sequence of characters: "hello" 'Sammy' "2000" "楽しい"
Lists list Ordered sequence of objects: [10,"hello",200.3]
Dictionaries dict Unordered Key:Value pairs: {"mykey" : "value" , "name" : "Frankie"}
Tuples tup Ordered immutable sequence of objects: (10,"hello",200.3)
Sets set Unordered collection of unique objects: {"a","b"}
Booleans bool Logical value indicating True or False
Complete Python 3 Bootcamp
Name Type Description
Integers int Whole numbers, such as: 3 300 200
Floating point float Numbers with a decimal point: 2.3 4.6 100.0
Strings str Ordered sequence of characters: "hello" 'Sammy' "2000" "楽しい"
Lists list Ordered sequence of objects: [10,"hello",200.3]
Dictionaries dict Unordered Key:Value pairs: {"mykey" : "value" , "name" : "Frankie"}
Tuples tup Ordered immutable sequence of objects: (10,"hello",200.3)
Sets set Unordered collection of unique objects: {"a","b"}
Booleans bool Logical value indicating True or False
Complete Python 3 Bootcamp
Name Type Description
Integers int Whole numbers, such as: 3 300 200
Floating point float Numbers with a decimal point: 2.3 4.6 100.0
Strings str Ordered sequence of characters: "hello" 'Sammy' "2000" "楽しい"
Lists list Ordered sequence of objects: [10,"hello",200.3]
Dictionaries dict Unordered Key:Value pairs: {"mykey" : "value" , "name" : "Frankie"}
Tuples tup Ordered immutable sequence of objects: (10,"hello",200.3)
Sets set Unordered collection of unique objects: {"a","b"}
Booleans bool Logical value indicating True or False
Complete Python 3 Bootcamp
Name Type Description
Integers int Whole numbers, such as: 3 300 200
Floating point float Numbers with a decimal point: 2.3 4.6 100.0
Strings str Ordered sequence of characters: "hello" 'Sammy' "2000" "楽しい"
Lists list Ordered sequence of objects: [10,"hello",200.3]
Dictionaries dict Unordered Key:Value pairs: {"mykey" : "value" , "name" : "Frankie"}
Tuples tup Ordered immutable sequence of objects: (10,"hello",200.3)
Sets set Unordered collection of unique objects: {"a","b"}
Booleans bool Logical value indicating True or False
Complete Python 3 Bootcamp
Name Type Description
Integers int Whole numbers, such as: 3 300 200
Floating point float Numbers with a decimal point: 2.3 4.6 100.0
Strings str Ordered sequence of characters: "hello" 'Sammy' "2000" "楽しい"
Lists list Ordered sequence of objects: [10,"hello",200.3]
Dictionaries dict Unordered Key:Value pairs: {"mykey" : "value" , "name" : "Frankie"}
Tuples tup Ordered immutable sequence of objects: (10,"hello",200.3)
Sets set Unordered collection of unique objects: {"a","b"}
Booleans bool Logical value indicating True or False
Complete Python 3 Bootcamp
Name Type Description
Integers int Whole numbers, such as: 3 300 200
Floating point float Numbers with a decimal point: 2.3 4.6 100.0
Strings str Ordered sequence of characters: "hello" 'Sammy' "2000" "楽しい"
Lists list Ordered sequence of objects: [10,"hello",200.3]
Dictionaries dict Unordered Key:Value pairs: {"mykey" : "value" , "name" : "Frankie"}
Tuples tup Ordered immutable sequence of objects: (10,"hello",200.3)
Sets set Unordered collection of unique objects: {"a","b"}
Booleans bool Logical value indicating True or False
Complete Python 3 Bootcamp
Name Type Description
Integers int Whole numbers, such as: 3 300 200
Floating point float Numbers with a decimal point: 2.3 4.6 100.0
Strings str Ordered sequence of characters: "hello" 'Sammy' "2000" "楽しい"
Lists list Ordered sequence of objects: [10,"hello",200.3]
Dictionaries dict Unordered Key:Value pairs: {"mykey" : "value" , "name" : "Frankie"}
Tuples tup Ordered immutable sequence of objects: (10,"hello",200.3)
Sets set Unordered collection of unique objects: {"a","b"}
Booleans bool Logical value indicating True or False
Complete Python 3 Bootcamp
Name Type Description
Integers int Whole numbers, such as: 3 300 200
Floating point float Numbers with a decimal point: 2.3 4.6 100.0
Strings str Ordered sequence of characters: "hello" 'Sammy' "2000" "楽しい"
Lists list Ordered sequence of objects: [10,"hello",200.3]
Dictionaries dict Unordered Key:Value pairs: {"mykey" : "value" , "name" : "Frankie"}
Tuples tup Ordered immutable sequence of objects: (10,"hello",200.3)
Sets set Unordered collection of unique objects: {"a","b"}
Booleans bool Logical value indicating True or False
Let’s get started!
Numbers
Complete Python 3 Bootcamp
● There are two main number types we will
work with:
○ Integers which are whole numbers.
○ Floating Point numbers which are
numbers with a decimal.
● Let’s explore basic math with Python!
● We will also discuss how to create
variables and assign them values.
Variable Assignments
Complete Python 3 Bootcamp
● We just saw how to work with numbers,
but what do these numbers represent?
● It would be nice to assign these data types
a variable name to easily reference them
later on in our code!
● For example:
○ my_dogs = 2
Complete Python 3 Bootcamp
● Rules for variable names
○ Names can not start with a number.
○ There can be no spaces in the name, use
_ instead.
○ Can't use any of these symbols
:'",<>/?|()!@#$%^&*~-+
Complete Python 3 Bootcamp
● Rules for variable names
○ It's considered best practice (PEP8) that
names are lowercase.
○ Avoid using words that have special
meaning in Python like "list" and "str"
Complete Python 3 Bootcamp
● Python uses Dynamic Typing
● This means you can reassign variables to
different data types.
● This makes Python very flexible in assigning
data types, this is different than other
languages that are “Statically-Typed”
Complete Python 3 Bootcamp
my_dogs = 2
my_dogs = [ “Sammy” , “Frankie” ]
This is okay in
Python!
Complete Python 3 Bootcamp
my_dogs = 2
my_dogs = [ “Sammy” , “Frankie” ]
ERROR
in other
Languages!
Complete Python 3 Bootcamp
int my_dog = 1;
my_dog = “Sammy” ; //RESULTS IN ERROR
Example of Static Typing
(C++)
Complete Python 3 Bootcamp
● Pros of Dynamic Typing:
○ Very easy to work with
○ Faster development time
● Cons of Dynamic Typing:
○ May result in bugs for unexpected data
types!
○ You need to be aware of type()
Let’s explore these
concepts!
Strings
Complete Python 3 Bootcamp
● Strings are sequences of characters, using
the syntax of either single quotes or double
quotes:
○ 'hello'
○ "Hello"
○ " I don't do that "
Complete Python 3 Bootcamp
● Because strings are ordered sequences it
means we can using indexing and slicing
to grab sub-sections of the string.
● Indexing notation uses [ ] notation after the
string (or variable assigned the string).
● Indexing allows you to grab a single
character from the string...
Complete Python 3 Bootcamp
● These actions use [ ] square brackets and a
number index to indicate positions of what
you wish to grab.
Character : h e l l o
Index : 0 1 2 3 4
Complete Python 3 Bootcamp
● These actions use [ ] square brackets and a
number index to indicate positions of what
you wish to grab.
Character : h e l l o
Index : 0 1 2 3 4
Reverse Index: 0 -4 -3 -2 -1
Complete Python 3 Bootcamp
● Slicing allows you to grab a subsection of
multiple characters, a “slice” of the string.
● This has the following syntax:
○ [start:stop:step]
● start is a numerical index for the slice start
Complete Python 3 Bootcamp
● Slicing allows you to grab a subsection of
multiple characters, a “slice” of the string.
● This has the following syntax:
○ [start:stop:step]
● start is a numerical index for the slice start
● stop is the index you will go up to (but not
include)
● step is the size of the “jump” you take.
Let’s explore these
concepts!
String Indexing
and Slicing
String Properties
and Methods
String Formatting
for Printing
Complete Python 3 Bootcamp
● Often you will want to “inject” a variable into
your string for printing. For example:
○ my_name = “Jose”
○ print(“Hello ” + my_name)
● There are multiple ways to format strings for
printing variables in them.
● This is known as string interpolation.
Complete Python 3 Bootcamp
● Let’s explore two methods for this:
○ .format() method
○ f-strings (formatted string literals)
Lists
Complete Python 3 Bootcamp
● Lists are ordered sequences that can hold a
variety of object types.
● They use [] brackets and commas to
separate objects in the list.
○ [1,2,3,4,5]
● Lists support indexing and slicing. Lists can
be nested and also have a variety of useful
methods that can be called off of them.
Dictionaries
Complete Python 3 Bootcamp
● Dictionaries are unordered mappings for
storing objects. Previously we saw how lists
store objects in an ordered sequence,
dictionaries use a key-value pairing instead.
● This key-value pair allows users to quickly
grab objects without needing to know an
index location.
Complete Python 3 Bootcamp
● Dictionaries use curly braces and colons to
signify the keys and their associated values.
{'key1':'value1','key2':'value2'}
● So when to choose a list and when to
choose a dictionary?
Complete Python 3 Bootcamp
● Dictionaries: Objects retrieved by key
name.
Unordered and can not be sorted.
● Lists: Objects retrieved by location.
Ordered Sequence can be indexed or sliced.
Tuples
Complete Python 3 Bootcamp
Tuples are very similar to lists. However they
have one key difference - immutability.
Once an element is inside a tuple, it can not be
reassigned.
Tuples use parenthesis: (1,2,3)
Sets
Complete Python 3 Bootcamp
Sets are unordered collections of unique
elements.
Meaning there can only be one representative
of the same object.
Let’s see some examples!
Booleans
Complete Python 3 Bootcamp
Booleans are operators that allow you to
convey True or False statements.
These are very important later on when we
deal with control flow and logic!
Files
Complete Python 3 Bootcamp
Before we finish this section, let’s quickly go
over how to perform simple I/O with basic .txt
files.
We’ll also discuss file paths on your computer.
Let’s get started!
Objects and
Data Structures
Assessment Test
Complete Python 3 Bootcamp
Let’s have a quick overview of your first test.
You can download the notebooks from GitHub
or as a zip file from the Course Overview
Lecture.
Objects and
Data Structures
Assessment Test
SOLUTIONS
Complete Python 3 Bootcamp
● Numbers: Store numerical information and
come in two forms:
○ Integers - Whole Numbers
○ Floating Point - Numbers with a decimal
Complete Python 3 Bootcamp
● Strings: Ordered sequence of characters
● Lists: Ordered sequence of objects
(mutable)
● Tuples: Ordered sequence of objects
(immutable)
● Dictionary: Key-Value pairing that is
unordered.
Python Documentation

More Related Content

Similar to Python Objects and Data Structure Basics

unit 1.docx
unit 1.docxunit 1.docx
unit 1.docx
ssuser2e84e4
 
23UCACC11 Python Programming (MTNC) (BCA)
23UCACC11 Python Programming (MTNC) (BCA)23UCACC11 Python Programming (MTNC) (BCA)
23UCACC11 Python Programming (MTNC) (BCA)
ssuser7f90ae
 
UNIT 4 python.pptx
UNIT 4 python.pptxUNIT 4 python.pptx
UNIT 4 python.pptx
TKSanthoshRao
 
Strings in Python
Strings in PythonStrings in Python
Strings in Python
nitamhaske
 
INTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptxINTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptx
Nimrahafzal1
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
AkshayAggarwal79
 
PYTHON PROGRAMMING (2).pptx
PYTHON PROGRAMMING (2).pptxPYTHON PROGRAMMING (2).pptx
PYTHON PROGRAMMING (2).pptx
SoundariyaSathish
 
Python slide.1
Python slide.1Python slide.1
Python slide.1
Aswin Krishnamoorthy
 
GRADE 11 Chapter 5 - Python Fundamentals.pptx
GRADE 11 Chapter 5 - Python Fundamentals.pptxGRADE 11 Chapter 5 - Python Fundamentals.pptx
GRADE 11 Chapter 5 - Python Fundamentals.pptx
DeepaRavi21
 
Copy_of_Programming_Fundamentals_CSC_104__-_Session_3.pdf
Copy_of_Programming_Fundamentals_CSC_104__-_Session_3.pdfCopy_of_Programming_Fundamentals_CSC_104__-_Session_3.pdf
Copy_of_Programming_Fundamentals_CSC_104__-_Session_3.pdf
faridafatawu07
 
PPS_Unit 4.ppt
PPS_Unit 4.pptPPS_Unit 4.ppt
PPS_Unit 4.ppt
KundanBhatkar
 
Python revision tour II
Python revision tour IIPython revision tour II
Python revision tour II
Mr. Vikram Singh Slathia
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Python Basics it will teach you about data types
Python Basics it will teach you about data typesPython Basics it will teach you about data types
Python Basics it will teach you about data types
NimitSinghal2
 
Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...
Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...
Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...
manikbuma
 
Python cheat-sheet
Python cheat-sheetPython cheat-sheet
Python cheat-sheet
srinivasanr281952
 
Notes3
Notes3Notes3
Notes3
hccit
 
beginners_python_cheat_sheet_pcc_all (3).pptx
beginners_python_cheat_sheet_pcc_all (3).pptxbeginners_python_cheat_sheet_pcc_all (3).pptx
beginners_python_cheat_sheet_pcc_all (3).pptx
HongAnhNguyn285885
 
11 Introduction to lists.pptx
11 Introduction to lists.pptx11 Introduction to lists.pptx
11 Introduction to lists.pptx
ssuser8e50d8
 
20.C++Pointer.pptx
20.C++Pointer.pptx20.C++Pointer.pptx
20.C++Pointer.pptx
AtharvPotdar2
 

Similar to Python Objects and Data Structure Basics (20)

unit 1.docx
unit 1.docxunit 1.docx
unit 1.docx
 
23UCACC11 Python Programming (MTNC) (BCA)
23UCACC11 Python Programming (MTNC) (BCA)23UCACC11 Python Programming (MTNC) (BCA)
23UCACC11 Python Programming (MTNC) (BCA)
 
UNIT 4 python.pptx
UNIT 4 python.pptxUNIT 4 python.pptx
UNIT 4 python.pptx
 
Strings in Python
Strings in PythonStrings in Python
Strings in Python
 
INTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptxINTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptx
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
 
PYTHON PROGRAMMING (2).pptx
PYTHON PROGRAMMING (2).pptxPYTHON PROGRAMMING (2).pptx
PYTHON PROGRAMMING (2).pptx
 
Python slide.1
Python slide.1Python slide.1
Python slide.1
 
GRADE 11 Chapter 5 - Python Fundamentals.pptx
GRADE 11 Chapter 5 - Python Fundamentals.pptxGRADE 11 Chapter 5 - Python Fundamentals.pptx
GRADE 11 Chapter 5 - Python Fundamentals.pptx
 
Copy_of_Programming_Fundamentals_CSC_104__-_Session_3.pdf
Copy_of_Programming_Fundamentals_CSC_104__-_Session_3.pdfCopy_of_Programming_Fundamentals_CSC_104__-_Session_3.pdf
Copy_of_Programming_Fundamentals_CSC_104__-_Session_3.pdf
 
PPS_Unit 4.ppt
PPS_Unit 4.pptPPS_Unit 4.ppt
PPS_Unit 4.ppt
 
Python revision tour II
Python revision tour IIPython revision tour II
Python revision tour II
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Python Basics it will teach you about data types
Python Basics it will teach you about data typesPython Basics it will teach you about data types
Python Basics it will teach you about data types
 
Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...
Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...
Presentation pythonpppppppppppppppppppppppppppppppppyyyyyyyyyyyyyyyyyyytttttt...
 
Python cheat-sheet
Python cheat-sheetPython cheat-sheet
Python cheat-sheet
 
Notes3
Notes3Notes3
Notes3
 
beginners_python_cheat_sheet_pcc_all (3).pptx
beginners_python_cheat_sheet_pcc_all (3).pptxbeginners_python_cheat_sheet_pcc_all (3).pptx
beginners_python_cheat_sheet_pcc_all (3).pptx
 
11 Introduction to lists.pptx
11 Introduction to lists.pptx11 Introduction to lists.pptx
11 Introduction to lists.pptx
 
20.C++Pointer.pptx
20.C++Pointer.pptx20.C++Pointer.pptx
20.C++Pointer.pptx
 

Recently uploaded

What is an Construction Equipment Management System?
What is an Construction Equipment Management System?What is an Construction Equipment Management System?
What is an Construction Equipment Management System?
NYGGS Construction ERP Software
 
Full stack odoo development solutions provided by Fortune 500 trusted supplier
Full stack odoo development solutions provided by Fortune 500 trusted supplierFull stack odoo development solutions provided by Fortune 500 trusted supplier
Full stack odoo development solutions provided by Fortune 500 trusted supplier
Odoo Red
 
Understanding Automated Testing Tools for Web Applications.pdf
Understanding Automated Testing Tools for Web Applications.pdfUnderstanding Automated Testing Tools for Web Applications.pdf
Understanding Automated Testing Tools for Web Applications.pdf
kalichargn70th171
 
Cal Girls Fort Chandragupt Jaipur 8445551418 Khusi Top Class Girls Call Jaipu...
Cal Girls Fort Chandragupt Jaipur 8445551418 Khusi Top Class Girls Call Jaipu...Cal Girls Fort Chandragupt Jaipur 8445551418 Khusi Top Class Girls Call Jaipu...
Cal Girls Fort Chandragupt Jaipur 8445551418 Khusi Top Class Girls Call Jaipu...
Trisha Kumari
 
Top 10 ERP Companies in UAE Banibro IT Solutions.pdf
Top 10 ERP Companies in UAE Banibro IT Solutions.pdfTop 10 ERP Companies in UAE Banibro IT Solutions.pdf
Top 10 ERP Companies in UAE Banibro IT Solutions.pdf
Banibro IT Solutions
 
4. The Build System _ Embedded Android.pdf
4. The Build System _ Embedded Android.pdf4. The Build System _ Embedded Android.pdf
4. The Build System _ Embedded Android.pdf
VishalKumarJha10
 
How Odoo Accounting Can Save Your Business, Time and Money.pdf
How Odoo Accounting Can Save Your Business, Time and Money.pdfHow Odoo Accounting Can Save Your Business, Time and Money.pdf
How Odoo Accounting Can Save Your Business, Time and Money.pdf
Banibro IT Solutions
 
Googling for Software Development: What Developers Search For and What They F...
Googling for Software Development: What Developers Search For and What They F...Googling for Software Development: What Developers Search For and What They F...
Googling for Software Development: What Developers Search For and What They F...
Andre Hora
 
CrushFTP 10.4.0.29 PC Software - WhizNews
CrushFTP 10.4.0.29 PC Software - WhizNewsCrushFTP 10.4.0.29 PC Software - WhizNews
CrushFTP 10.4.0.29 PC Software - WhizNews
Eman Nisar
 
'Build Your First Website with WordPress' Workshop Introduction
'Build Your First Website with WordPress' Workshop Introduction'Build Your First Website with WordPress' Workshop Introduction
'Build Your First Website with WordPress' Workshop Introduction
Sunita Rai
 
Guide to Improving QA Testing with Gen AI.pdf
Guide to Improving QA Testing with Gen AI.pdfGuide to Improving QA Testing with Gen AI.pdf
Guide to Improving QA Testing with Gen AI.pdf
kalichargn70th171
 
How to Download YouTube Video to MP4 on PC/Mac
How to Download YouTube Video to MP4 on PC/MacHow to Download YouTube Video to MP4 on PC/Mac
How to Download YouTube Video to MP4 on PC/Mac
Jessica Chen
 
Automating Enterprise Workflows with Node.pdf
Automating Enterprise Workflows with Node.pdfAutomating Enterprise Workflows with Node.pdf
Automating Enterprise Workflows with Node.pdf
Jane Brewer
 
Alluxio Webinar | What’s new in Alluxio Enterprise AI 3.2: Leverage GPU Anywh...
Alluxio Webinar | What’s new in Alluxio Enterprise AI 3.2: Leverage GPU Anywh...Alluxio Webinar | What’s new in Alluxio Enterprise AI 3.2: Leverage GPU Anywh...
Alluxio Webinar | What’s new in Alluxio Enterprise AI 3.2: Leverage GPU Anywh...
Alluxio, Inc.
 
Transform Your Innovations with Best Product Engineering Services
Transform Your Innovations with Best Product Engineering ServicesTransform Your Innovations with Best Product Engineering Services
Transform Your Innovations with Best Product Engineering Services
David Wilson
 
Viswanath_Cover letter_Scrum Master_10+yrs
Viswanath_Cover letter_Scrum Master_10+yrsViswanath_Cover letter_Scrum Master_10+yrs
Viswanath_Cover letter_Scrum Master_10+yrs
cviswanathsai
 
Mastering MicroStation DGN: How to Integrate CAD and GIS
Mastering MicroStation DGN: How to Integrate CAD and GISMastering MicroStation DGN: How to Integrate CAD and GIS
Mastering MicroStation DGN: How to Integrate CAD and GIS
Safe Software
 
A Guide to the 10 Best HR Analytics Software 2024
A Guide to the 10 Best HR Analytics Software 2024A Guide to the 10 Best HR Analytics Software 2024
A Guide to the 10 Best HR Analytics Software 2024
Frank Austin
 
Availability and Usage of Platform-Specific APIs: A First Empirical Study (MS...
Availability and Usage of Platform-Specific APIs: A First Empirical Study (MS...Availability and Usage of Platform-Specific APIs: A First Empirical Study (MS...
Availability and Usage of Platform-Specific APIs: A First Empirical Study (MS...
Andre Hora
 
Assessing Mock Classes: An Empirical Study (ICSME 2020)
Assessing Mock Classes: An Empirical Study (ICSME 2020)Assessing Mock Classes: An Empirical Study (ICSME 2020)
Assessing Mock Classes: An Empirical Study (ICSME 2020)
Andre Hora
 

Recently uploaded (20)

What is an Construction Equipment Management System?
What is an Construction Equipment Management System?What is an Construction Equipment Management System?
What is an Construction Equipment Management System?
 
Full stack odoo development solutions provided by Fortune 500 trusted supplier
Full stack odoo development solutions provided by Fortune 500 trusted supplierFull stack odoo development solutions provided by Fortune 500 trusted supplier
Full stack odoo development solutions provided by Fortune 500 trusted supplier
 
Understanding Automated Testing Tools for Web Applications.pdf
Understanding Automated Testing Tools for Web Applications.pdfUnderstanding Automated Testing Tools for Web Applications.pdf
Understanding Automated Testing Tools for Web Applications.pdf
 
Cal Girls Fort Chandragupt Jaipur 8445551418 Khusi Top Class Girls Call Jaipu...
Cal Girls Fort Chandragupt Jaipur 8445551418 Khusi Top Class Girls Call Jaipu...Cal Girls Fort Chandragupt Jaipur 8445551418 Khusi Top Class Girls Call Jaipu...
Cal Girls Fort Chandragupt Jaipur 8445551418 Khusi Top Class Girls Call Jaipu...
 
Top 10 ERP Companies in UAE Banibro IT Solutions.pdf
Top 10 ERP Companies in UAE Banibro IT Solutions.pdfTop 10 ERP Companies in UAE Banibro IT Solutions.pdf
Top 10 ERP Companies in UAE Banibro IT Solutions.pdf
 
4. The Build System _ Embedded Android.pdf
4. The Build System _ Embedded Android.pdf4. The Build System _ Embedded Android.pdf
4. The Build System _ Embedded Android.pdf
 
How Odoo Accounting Can Save Your Business, Time and Money.pdf
How Odoo Accounting Can Save Your Business, Time and Money.pdfHow Odoo Accounting Can Save Your Business, Time and Money.pdf
How Odoo Accounting Can Save Your Business, Time and Money.pdf
 
Googling for Software Development: What Developers Search For and What They F...
Googling for Software Development: What Developers Search For and What They F...Googling for Software Development: What Developers Search For and What They F...
Googling for Software Development: What Developers Search For and What They F...
 
CrushFTP 10.4.0.29 PC Software - WhizNews
CrushFTP 10.4.0.29 PC Software - WhizNewsCrushFTP 10.4.0.29 PC Software - WhizNews
CrushFTP 10.4.0.29 PC Software - WhizNews
 
'Build Your First Website with WordPress' Workshop Introduction
'Build Your First Website with WordPress' Workshop Introduction'Build Your First Website with WordPress' Workshop Introduction
'Build Your First Website with WordPress' Workshop Introduction
 
Guide to Improving QA Testing with Gen AI.pdf
Guide to Improving QA Testing with Gen AI.pdfGuide to Improving QA Testing with Gen AI.pdf
Guide to Improving QA Testing with Gen AI.pdf
 
How to Download YouTube Video to MP4 on PC/Mac
How to Download YouTube Video to MP4 on PC/MacHow to Download YouTube Video to MP4 on PC/Mac
How to Download YouTube Video to MP4 on PC/Mac
 
Automating Enterprise Workflows with Node.pdf
Automating Enterprise Workflows with Node.pdfAutomating Enterprise Workflows with Node.pdf
Automating Enterprise Workflows with Node.pdf
 
Alluxio Webinar | What’s new in Alluxio Enterprise AI 3.2: Leverage GPU Anywh...
Alluxio Webinar | What’s new in Alluxio Enterprise AI 3.2: Leverage GPU Anywh...Alluxio Webinar | What’s new in Alluxio Enterprise AI 3.2: Leverage GPU Anywh...
Alluxio Webinar | What’s new in Alluxio Enterprise AI 3.2: Leverage GPU Anywh...
 
Transform Your Innovations with Best Product Engineering Services
Transform Your Innovations with Best Product Engineering ServicesTransform Your Innovations with Best Product Engineering Services
Transform Your Innovations with Best Product Engineering Services
 
Viswanath_Cover letter_Scrum Master_10+yrs
Viswanath_Cover letter_Scrum Master_10+yrsViswanath_Cover letter_Scrum Master_10+yrs
Viswanath_Cover letter_Scrum Master_10+yrs
 
Mastering MicroStation DGN: How to Integrate CAD and GIS
Mastering MicroStation DGN: How to Integrate CAD and GISMastering MicroStation DGN: How to Integrate CAD and GIS
Mastering MicroStation DGN: How to Integrate CAD and GIS
 
A Guide to the 10 Best HR Analytics Software 2024
A Guide to the 10 Best HR Analytics Software 2024A Guide to the 10 Best HR Analytics Software 2024
A Guide to the 10 Best HR Analytics Software 2024
 
Availability and Usage of Platform-Specific APIs: A First Empirical Study (MS...
Availability and Usage of Platform-Specific APIs: A First Empirical Study (MS...Availability and Usage of Platform-Specific APIs: A First Empirical Study (MS...
Availability and Usage of Platform-Specific APIs: A First Empirical Study (MS...
 
Assessing Mock Classes: An Empirical Study (ICSME 2020)
Assessing Mock Classes: An Empirical Study (ICSME 2020)Assessing Mock Classes: An Empirical Study (ICSME 2020)
Assessing Mock Classes: An Empirical Study (ICSME 2020)
 

Python Objects and Data Structure Basics

  • 1. Python Object and Data Structure Basics
  • 3. Complete Python 3 Bootcamp ● In this section of the course we will cover the key data types in Python. ● These are your basic building blocks when constructing larger pieces of code. ● Let’s quickly discuss all of the possible data types, then we’ll have lectures that go into more detail about each one!
  • 4. Complete Python 3 Bootcamp Name Type Description Integers int Whole numbers, such as: 3 300 200 Floating point float Numbers with a decimal point: 2.3 4.6 100.0 Strings str Ordered sequence of characters: "hello" 'Sammy' "2000" "楽しい" Lists list Ordered sequence of objects: [10,"hello",200.3] Dictionaries dict Unordered Key:Value pairs: {"mykey" : "value" , "name" : "Frankie"} Tuples tup Ordered immutable sequence of objects: (10,"hello",200.3) Sets set Unordered collection of unique objects: {"a","b"} Booleans bool Logical value indicating True or False
  • 5. Complete Python 3 Bootcamp Name Type Description Integers int Whole numbers, such as: 3 300 200 Floating point float Numbers with a decimal point: 2.3 4.6 100.0 Strings str Ordered sequence of characters: "hello" 'Sammy' "2000" "楽しい" Lists list Ordered sequence of objects: [10,"hello",200.3] Dictionaries dict Unordered Key:Value pairs: {"mykey" : "value" , "name" : "Frankie"} Tuples tup Ordered immutable sequence of objects: (10,"hello",200.3) Sets set Unordered collection of unique objects: {"a","b"} Booleans bool Logical value indicating True or False
  • 6. Complete Python 3 Bootcamp Name Type Description Integers int Whole numbers, such as: 3 300 200 Floating point float Numbers with a decimal point: 2.3 4.6 100.0 Strings str Ordered sequence of characters: "hello" 'Sammy' "2000" "楽しい" Lists list Ordered sequence of objects: [10,"hello",200.3] Dictionaries dict Unordered Key:Value pairs: {"mykey" : "value" , "name" : "Frankie"} Tuples tup Ordered immutable sequence of objects: (10,"hello",200.3) Sets set Unordered collection of unique objects: {"a","b"} Booleans bool Logical value indicating True or False
  • 7. Complete Python 3 Bootcamp Name Type Description Integers int Whole numbers, such as: 3 300 200 Floating point float Numbers with a decimal point: 2.3 4.6 100.0 Strings str Ordered sequence of characters: "hello" 'Sammy' "2000" "楽しい" Lists list Ordered sequence of objects: [10,"hello",200.3] Dictionaries dict Unordered Key:Value pairs: {"mykey" : "value" , "name" : "Frankie"} Tuples tup Ordered immutable sequence of objects: (10,"hello",200.3) Sets set Unordered collection of unique objects: {"a","b"} Booleans bool Logical value indicating True or False
  • 8. Complete Python 3 Bootcamp Name Type Description Integers int Whole numbers, such as: 3 300 200 Floating point float Numbers with a decimal point: 2.3 4.6 100.0 Strings str Ordered sequence of characters: "hello" 'Sammy' "2000" "楽しい" Lists list Ordered sequence of objects: [10,"hello",200.3] Dictionaries dict Unordered Key:Value pairs: {"mykey" : "value" , "name" : "Frankie"} Tuples tup Ordered immutable sequence of objects: (10,"hello",200.3) Sets set Unordered collection of unique objects: {"a","b"} Booleans bool Logical value indicating True or False
  • 9. Complete Python 3 Bootcamp Name Type Description Integers int Whole numbers, such as: 3 300 200 Floating point float Numbers with a decimal point: 2.3 4.6 100.0 Strings str Ordered sequence of characters: "hello" 'Sammy' "2000" "楽しい" Lists list Ordered sequence of objects: [10,"hello",200.3] Dictionaries dict Unordered Key:Value pairs: {"mykey" : "value" , "name" : "Frankie"} Tuples tup Ordered immutable sequence of objects: (10,"hello",200.3) Sets set Unordered collection of unique objects: {"a","b"} Booleans bool Logical value indicating True or False
  • 10. Complete Python 3 Bootcamp Name Type Description Integers int Whole numbers, such as: 3 300 200 Floating point float Numbers with a decimal point: 2.3 4.6 100.0 Strings str Ordered sequence of characters: "hello" 'Sammy' "2000" "楽しい" Lists list Ordered sequence of objects: [10,"hello",200.3] Dictionaries dict Unordered Key:Value pairs: {"mykey" : "value" , "name" : "Frankie"} Tuples tup Ordered immutable sequence of objects: (10,"hello",200.3) Sets set Unordered collection of unique objects: {"a","b"} Booleans bool Logical value indicating True or False
  • 11. Complete Python 3 Bootcamp Name Type Description Integers int Whole numbers, such as: 3 300 200 Floating point float Numbers with a decimal point: 2.3 4.6 100.0 Strings str Ordered sequence of characters: "hello" 'Sammy' "2000" "楽しい" Lists list Ordered sequence of objects: [10,"hello",200.3] Dictionaries dict Unordered Key:Value pairs: {"mykey" : "value" , "name" : "Frankie"} Tuples tup Ordered immutable sequence of objects: (10,"hello",200.3) Sets set Unordered collection of unique objects: {"a","b"} Booleans bool Logical value indicating True or False
  • 12. Complete Python 3 Bootcamp Name Type Description Integers int Whole numbers, such as: 3 300 200 Floating point float Numbers with a decimal point: 2.3 4.6 100.0 Strings str Ordered sequence of characters: "hello" 'Sammy' "2000" "楽しい" Lists list Ordered sequence of objects: [10,"hello",200.3] Dictionaries dict Unordered Key:Value pairs: {"mykey" : "value" , "name" : "Frankie"} Tuples tup Ordered immutable sequence of objects: (10,"hello",200.3) Sets set Unordered collection of unique objects: {"a","b"} Booleans bool Logical value indicating True or False
  • 15. Complete Python 3 Bootcamp ● There are two main number types we will work with: ○ Integers which are whole numbers. ○ Floating Point numbers which are numbers with a decimal. ● Let’s explore basic math with Python! ● We will also discuss how to create variables and assign them values.
  • 17. Complete Python 3 Bootcamp ● We just saw how to work with numbers, but what do these numbers represent? ● It would be nice to assign these data types a variable name to easily reference them later on in our code! ● For example: ○ my_dogs = 2
  • 18. Complete Python 3 Bootcamp ● Rules for variable names ○ Names can not start with a number. ○ There can be no spaces in the name, use _ instead. ○ Can't use any of these symbols :'",<>/?|()!@#$%^&*~-+
  • 19. Complete Python 3 Bootcamp ● Rules for variable names ○ It's considered best practice (PEP8) that names are lowercase. ○ Avoid using words that have special meaning in Python like "list" and "str"
  • 20. Complete Python 3 Bootcamp ● Python uses Dynamic Typing ● This means you can reassign variables to different data types. ● This makes Python very flexible in assigning data types, this is different than other languages that are “Statically-Typed”
  • 21. Complete Python 3 Bootcamp my_dogs = 2 my_dogs = [ “Sammy” , “Frankie” ] This is okay in Python!
  • 22. Complete Python 3 Bootcamp my_dogs = 2 my_dogs = [ “Sammy” , “Frankie” ] ERROR in other Languages!
  • 23. Complete Python 3 Bootcamp int my_dog = 1; my_dog = “Sammy” ; //RESULTS IN ERROR Example of Static Typing (C++)
  • 24. Complete Python 3 Bootcamp ● Pros of Dynamic Typing: ○ Very easy to work with ○ Faster development time ● Cons of Dynamic Typing: ○ May result in bugs for unexpected data types! ○ You need to be aware of type()
  • 27. Complete Python 3 Bootcamp ● Strings are sequences of characters, using the syntax of either single quotes or double quotes: ○ 'hello' ○ "Hello" ○ " I don't do that "
  • 28. Complete Python 3 Bootcamp ● Because strings are ordered sequences it means we can using indexing and slicing to grab sub-sections of the string. ● Indexing notation uses [ ] notation after the string (or variable assigned the string). ● Indexing allows you to grab a single character from the string...
  • 29. Complete Python 3 Bootcamp ● These actions use [ ] square brackets and a number index to indicate positions of what you wish to grab. Character : h e l l o Index : 0 1 2 3 4
  • 30. Complete Python 3 Bootcamp ● These actions use [ ] square brackets and a number index to indicate positions of what you wish to grab. Character : h e l l o Index : 0 1 2 3 4 Reverse Index: 0 -4 -3 -2 -1
  • 31. Complete Python 3 Bootcamp ● Slicing allows you to grab a subsection of multiple characters, a “slice” of the string. ● This has the following syntax: ○ [start:stop:step] ● start is a numerical index for the slice start
  • 32. Complete Python 3 Bootcamp ● Slicing allows you to grab a subsection of multiple characters, a “slice” of the string. ● This has the following syntax: ○ [start:stop:step] ● start is a numerical index for the slice start ● stop is the index you will go up to (but not include) ● step is the size of the “jump” you take.
  • 37. Complete Python 3 Bootcamp ● Often you will want to “inject” a variable into your string for printing. For example: ○ my_name = “Jose” ○ print(“Hello ” + my_name) ● There are multiple ways to format strings for printing variables in them. ● This is known as string interpolation.
  • 38. Complete Python 3 Bootcamp ● Let’s explore two methods for this: ○ .format() method ○ f-strings (formatted string literals)
  • 39. Lists
  • 40. Complete Python 3 Bootcamp ● Lists are ordered sequences that can hold a variety of object types. ● They use [] brackets and commas to separate objects in the list. ○ [1,2,3,4,5] ● Lists support indexing and slicing. Lists can be nested and also have a variety of useful methods that can be called off of them.
  • 42. Complete Python 3 Bootcamp ● Dictionaries are unordered mappings for storing objects. Previously we saw how lists store objects in an ordered sequence, dictionaries use a key-value pairing instead. ● This key-value pair allows users to quickly grab objects without needing to know an index location.
  • 43. Complete Python 3 Bootcamp ● Dictionaries use curly braces and colons to signify the keys and their associated values. {'key1':'value1','key2':'value2'} ● So when to choose a list and when to choose a dictionary?
  • 44. Complete Python 3 Bootcamp ● Dictionaries: Objects retrieved by key name. Unordered and can not be sorted. ● Lists: Objects retrieved by location. Ordered Sequence can be indexed or sliced.
  • 46. Complete Python 3 Bootcamp Tuples are very similar to lists. However they have one key difference - immutability. Once an element is inside a tuple, it can not be reassigned. Tuples use parenthesis: (1,2,3)
  • 47. Sets
  • 48. Complete Python 3 Bootcamp Sets are unordered collections of unique elements. Meaning there can only be one representative of the same object. Let’s see some examples!
  • 50. Complete Python 3 Bootcamp Booleans are operators that allow you to convey True or False statements. These are very important later on when we deal with control flow and logic!
  • 51. Files
  • 52. Complete Python 3 Bootcamp Before we finish this section, let’s quickly go over how to perform simple I/O with basic .txt files. We’ll also discuss file paths on your computer. Let’s get started!
  • 54. Complete Python 3 Bootcamp Let’s have a quick overview of your first test. You can download the notebooks from GitHub or as a zip file from the Course Overview Lecture.
  • 56. Complete Python 3 Bootcamp ● Numbers: Store numerical information and come in two forms: ○ Integers - Whole Numbers ○ Floating Point - Numbers with a decimal
  • 57. Complete Python 3 Bootcamp ● Strings: Ordered sequence of characters ● Lists: Ordered sequence of objects (mutable) ● Tuples: Ordered sequence of objects (immutable) ● Dictionary: Key-Value pairing that is unordered.