SoftPython
dev
  • Home
    • News
    • Intended audience
    • Contents
      • A - Foundations
      • A.1 Data Types
      • A.2 Control Flow
      • A.3 Basic Algorithms
      • B - Data Analysis
      • C - Applications
      • D - Projects
        • Worked projects
          • Text data worked projects
          • Tabular data worked projects
          • Relational data worked projects
      • E - Appendix
    • Author
      • Contributors
    • License
    • Acknowledgments
  • Overview
    • Chapters
    • Why Python?
    • Approach and goals
    • Doesn’t work, what should I do?
      • How to ask questions
    • Installation and tools
    • Let’s start !
  • Installation
    • Installing Python
      • Windows installation
      • Mac installation
      • Linux installation
    • Installing packages
    • Jupyter Notebook
      • Run Jupyter notebook
      • Saving Jupyter notebooks
      • Turning off Jupyter server
      • Navigating notebooks
      • Installing Jupyter notebook - all operating systems
    • Projects with virtual environments
      • Creating virtual environments
      • Activate a virtual environment
      • Executing environments inside Jupyter
        • With Anaconda
        • Without Anaconda
    • Further readings
  • A - Foundations
    • Quick Python intro
      • Download exercises zip
        • What to do
      • Let’s try Jupyter
      • Main types of data in Python
      • Integer and floating point numbers
      • Booleans - bool
        • and operator
        • or operator
        • not operator
        • Beyond True and False
      • Strings - str
        • Using object methods
      • Lists - list
        • Ordering lists
      • Dictionaries - dict
      • Visualizing execution with Python Tutor
        • Debugging code in Jupyter
          • Python Tutor : Limitation 1
          • Python Tutor : Limitation 2
      • Iteration
        • for in range
      • Functions
        • Lambda functions
      • List transformations
        • Trasfomations with a for
        • Transformations with list comprehensions
        • Transformations with map
      • Matrices
        • Zip function
      • Furhter readings
    • Tools and scripts
      • Download exercises zip
      • Python interpreter
        • Let’s open system console
        • Listing files and folders
        • Let’s launch the Python interpreter
        • Exiting the interpreter
      • Modules
        • Simple text editor
        • IDE
      • Jupyter
        • Printing an expression
        • Exercise - Castles in the air
      • Visualizing the execution with Python Tutor
        • Debugging code in Jupyter
          • Python Tutor : Limitation 1
          • Python Tutor : Limitation 2
        • Exercise - tavern
      • Python Architecture
        • Python is a high level language
        • Performance
  • A1 Data Types
    • Basics
      • Integers
        • Download exercises zip
        • Jupyter
        • Objects
        • Variables
          • Detect the type of a variable
          • Reassign a variable
          • Reusing a variable
          • Assignments - questions
          • Exercise - exchange
          • Exercise - cycling
          • Changing type during execution
          • Multiple commands on the same line
          • Multiple initializations
          • Exercise - exchange like a ninja
          • Names of variables
          • Names of variables - questions
        • Numerical types
        • Integer numbers
          • Exercise - deadline 1
          • Modulo operator
          • Exercise - deadline 2
          • min and max
          • Exercise - transportation
          • Exercise - armchairs
        • Continue
      • Booleans
        • Download exercises zip
        • Boolean operators
          • and
          • or
          • not
        • Questions with costants
        • Questions with variables
        • De Morgan
        • Conversion
        • Questions - what is a boolean?
        • Evaluation order
        • Evaluation errors
        • Comparison operators
        • Joining comparisons
        • Exercise - The Lawnmower 1
        • Exercise - The Lawnmower 2
        • Exercise - The Lawnmower 3
        • Exercise - The Lawnmower 4
        • Exercise - The Lava Temple
        • Exercise - The Tower of Gradius I
        • Exercise - The Pipe Jump
        • Exercise - The Tower of Gradius II
        • Continue
      • Floats
        • Download exercises zip
        • Real numbers
          • Scientifical notation
          • Too big or too small numbers
          • Exercise - circle
          • Exercise - The golf club
          • Exercise - fractioning
          • Exercise - summation
          • Reals - conversion
          • Exercise - Invigorate
          • Exercise - roundminder
          • Reals - equality
          • Exercise - quadratic
          • Exercise - trendy
        • Decimal numbers
        • Continue
      • Challenges
        • Download exercises zip
        • Challenge - which booleans 1?
        • Challenge - which booleans 2?
        • Challenge - airport
        • Challenge - Holiday trip
        • Challange - The Tunnel of Time
    • Strings
      • Intro
        • Download exercises zip
        • What to do
        • Creating strings
        • Printing - the cells
        • The empty string
        • Printing many strings
        • Length of a string
        • Printing - escape sequences
          • Example - line feed
          • Example - tabulation
        • Encodings
          • ASCII characters
          • Unicode characters
        • Strings are immutable
          • Reassign variables
          • Reassign a variable to itself
        • Strings and numbers
        • Conversions - from string to number
        • Conversions - from number to string
        • Formatting strings
          • Formatting with %
          • Formatting with f-strings
          • Exercise - supercars
        • Continue
      • Operators
        • Download exercises zip
        • What to do
        • Reading characters
          • Exercise - alternate
          • Negative indexes
        • Substitute characters
        • Slices
          • Exercise - garalampog
          • Exercise - ifEweEfav lkSD lkWe
          • Slices - limits
          • Slice - Omitting limits
          • Exercise - ysterymyster
          • Slice - negative limits
          • Exercise - javarnanda
          • Slice - modifying
          • Exercise - the run
        • Inclusion operator
          • Do not abuse in
          • Exercise - contained 1
          • Exercise - contained 2
        • Comparisons
          • Equality operators
          • Exercise - statist
          • Comparing characters
          • Comparing different lengths
          • Exercise - Character intervals
          • Exercise - The Library of Encodicus
        • Replication operator
          • Exercise - za za za
        • Continue
      • Basic methods
        • Download exercises zip
        • What to do
        • Example - upper
          • Exercise - walking
        • lower method
          • Exercise - lowermid
        • capitalize method
          • Exercise - Your Excellence
        • startswith method
          • Exercise - by Jove
        • endswith method
          • Exercise - Snobbonis
        • isalpha method
          • Exercise - Fighting the hackers
        • isdigit method
          • Exercise - Selling numbers
        • isupper and islower methods
          • Exercise - dwarves and GIANTS
        • Continue
      • Search methods
        • Download exercises zip
        • What to do
        • strip method
          • Specificying character to strip
          • Exercise - Biblio bank
        • lstrip method
        • rstrip method
          • Exercise - Bad to the bone
        • count method
          • Do not abuse count
          • Exercise - astro money
        • find method
        • rfind method
          • Do not abuse find
          • Exercise - The port of Monkey Island
          • Exercise - bananas
        • replace method
          • Do not abuse replace
          • Exercise - Do not open that door
          • Exercise - The Kingdom of Stringards
        • Other exercises
        • Continue
      • Challenges
        • Download exercises zip
        • Challenge - a strange zoo
        • Challenge - nuclear fusion
        • Challenge - gold
    • Lists
      • Intro
        • Download exercises zip
        • What to do
        • Creating lists
          • Empty list
          • Exercise - list swaps
          • Tables
          • Question - list creation
          • Exercise - domino
          • Exercise - create lists 2
          • Exercise - create lists 3
          • Exercise - create lists 4
        • Convert sequences into lists
          • Exercise - gulp
          • Exercise - garaga
        • Continue
      • Operators
        • Download exercises zip
        • What to do
        • Length of a list
        • Reading an element
          • Exercise - Gutenberg apprentice
        • Writing an element
          • Exercise - a jammed parking lot
        • Mutating shared lists
        • List of strings
          • Exercise - province codes
          • Exercise - games
        • Slices
          • Slice - limits
          • Exercise - The ‘treccia mochena’
          • Slices - omitting limits
          • Exercise - An out of tune guitar
          • Slices - negative limits
          • Exercise - The NonsenShop
          • Slice - step
          • Slices - modifying
          • Exercise - The railway outlaws
        • List of lists
          • Exercise - couples
          • Exercise - Glory to Gladiators!
        • Membership
          • Do not abuse in
          • not in
          • Exercise - vegetables
        • List concatenation with +
          • Exercise - concatenation
        • min and max
        • sum
          • Exercise - balance
        • List replication
        • Equality
        • Continue
      • Basic methods
        • Download exercises zip
        • What to do
        • append method
          • Exercise - augmenting a list 1
        • extend method
          • Extending with sequences
          • Exercise: augmenting a list 2
          • Exercise - zslice
          • Exercise - Zebarerun
        • insert method
          • Exercise - insertando
          • Exercise - insappend
        • pop method
          • Exercise - popcorn
          • Exercise - zonzo
        • reverse method
          • Exercise - good manners
        • Exercise - precious things
        • Exercise - powers
        • sort method
          • Custom sorting
          • Exercise - numlist
        • join - build strings from lists
          • Exercise - barzoletta
          • Exercise - dub dab dib dob
          • Exercise - ghirigori
          • Exercise - welldone
        • copy method
          • copy is shallow
          • deepcopy function
        • Continue
      • Search methods
        • Download exercises zip
        • What to do
        • split method - from strings to lists
          • Exercise - trash dance
          • Exercise - Trash in tour
          • Exercise - manylines
          • Exercise - takechars
        • count method
          • Do not abuse count
          • Exercise - country life
        • index method
          • Do not abuse index
          • Exercise - Spatoč
        • remove method
          • Do not abuse remove
          • Exercise - nob
        • Continue
      • Challenges
        • Download exercises zip
        • Challenge - super DUPER sorted
        • Challenge - What a nasty problem
        • Challenge - Toys in the Attic
    • Tuples
      • Intro
        • Download exercise zip
        • What to do
        • Creating tuples
          • Empty tuple
          • Tuples without brackets
          • Heterogenous elements
          • Creating tuples from sequences
          • Creating sequences from tuples
        • Operators
          • len
          • Reading an element
          • Exercise - animals
          • Slices
          • Concatenation
          • Membership
          • Replication
          • Exercise - welcome
        • Write an element
          • Exercise - badmod
          • Exercise - abde
          • Exercise - charismatic
          • Exercise - sorting
        • Methods
          • index method
          • Do not abuse index
          • Exercise - The chinese boxes
          • count method
          • Do not abuse count
          • Exercise - fruits
        • Continue
      • Challenges
        • Download exercises zip
        • Challenge - The Temple Of Rounded Doom
    • Sets
      • Intro
        • Download exercises zip
        • What to do
        • Creating a set
          • Converting sequences to sets
          • Mutable elements and hashes
          • Empty set
          • Exercise - dedup
          • Frozenset
        • Operators
          • len
          • Exercise - distincts
          • Membership
          • Union
          • Exercise - everythingbut 1
          • Intersection
          • Difference
          • Symmetric difference
          • Equality
        • Methods like operators
          • union
          • update
          • Exercise - everythingbut 2
        • Other methods
          • add method
          • remove method
          • Exercise - bababiba
          • discard method
          • Exercise - trash
          • issubset method
          • issuperset method
          • isdisjoint method
        • Exercise - matrioska
        • Continue
      • Challenges
        • Download exercises zip
    • Dictionaries
      • Intro
        • Download exercises zip
        • What to do
        • Creating a dictionary
          • The keys
          • The values
          • Empty dictionary
          • Keys and heterogenous values
          • Exercise - barone
        • Dictionary from a sequence of couples
          • Exercise - galattico veramente
        • Dictionary from keyword arguments
        • Copying a dictionary
          • Shallow copy
          • Deep copy
        • Continue
      • Operators
        • Download exercise zip
        • What to do
        • len
        • Reading a value
          • Fast disorder
          • Exercise - z7
        • Writing in the dictionary
          • Writing - adding key/value
          • Writing - reassociate a key
          • Exercise - workshop
          • Writing - deleting
          • Exercise - desktop
          • Exercise - garden
          • Exercise - translations
        • Membership with in
          • not in
          • Exercise - The Helmsman
        • Dictionaries of sequences
          • Exercise - loans
          • Exercise - Shark Bay
          • Exercise - The Storm Sea
        • Equality
          • Equality and order
          • Equality and copies
          • Exercise - Zoom Doom
        • Continue
      • Methods
        • Download exercise zip
        • What to do
        • keys method
          • Exercise - messy keys
          • Exercise - sorted keys
          • Exercise - keyring
        • values method
          • Exercise - one by one
          • Exercise - bag
          • Exercise - common values
          • Exercise - small big
        • items method
          • Exercise - union without update
        • update method
          • Exercise - axby
        • Continue
      • Special dictionaries
        • Download exercise zip
        • What to do
        • OrderedDict
          • Exercise - phonebook
          • Exercise - OrderedDict copy
        • Counter
          • Exercise - saddened
        • Continue
      • Challenges
        • Download exercises zip
        • Challenge - The Institute for Advanced Technotronics
        • Challenge - Incredible Machines contest
        • Challenge - Going nuts
        • Challenge - Galactic storm
  • A2 Control Flow
    • If command
      • Intro
        • Download exercises zip
        • What to do
        • The basic command if else
        • else is optional
        • Exercise - no fuel
        • The command if - elif - else
          • Questions
        • Questions - Are they equivalent?
          • Are they equivalent? - strawberries
          • Are they equivalent? - max
          • Are they equivalent? - min
          • Are they equivalent? - big small
          • Are they equivalent? - Cippirillo
          • Exercise - farm
          • Exercise - accents
          • Exercise - Arcana
        • Nested ifs
          • Exercise - abscissae and ordinates 1
          • Esercise - abscissae and ordinates 2
          • Exercise - bus
          • Exercise - chronometer
        • Questions - Are they equivalent?
          • Are they equivalent? - inside outside 1
          • Are they equivalent? - stars planets
          • Are they equivalent? - green red
          • Are they equivalent? - circles squares
          • Are they equivalent? - inside outside 2
          • Are they equivalent? - Ciabanga
          • Exercise - The maximum
        • Ternary operator
          • Questions ternary ifs
          • Exercise - shoes
          • Exercise - the little train
        • Continue
      • Challenges
        • Download exercises zip
        • Treasure Island
    • For loops
      • Intro
        • Download exercises zip
        • What to do
        • Iteration by element
          • Names of variables in for
          • Iterating strings
          • Iterating tuples
          • Questions - iteration
          • Exercise - magic carpet
          • Esercise - evensum
          • Exercise - birbantello
          • Exercise - articulate
          • Exercise - gala
          • Exercise - balance
        • Counting with range
          • Questions - range
          • Exercise - printdoubles
          • Exercise - multiples or not
          • Exercise - ab interval
          • Exercise - FizzBuzz
        • Iterating by index
          • Exercise - kitchen
          • Exercise - neon
          • Exercise - emotions
          • Exercise - organetto
          • Exercise - sghiribizzo
          • Exercise - dna
          • Exercise - sportello
          • Exercise - farm
          • Exercise - pokemon
        • Modifying during iteration
          • Exercise - duplicate
          • Exercise - hammers
          • Exercise - Orangutan
          • Exercise - basket
        • break and continue commands
          • Terminate with break
          • Jumping with continue
          • Combining break and continue
          • Questions - break and continue
          • Exercise - autonomous walking
          • Exercise - breaking bad
          • Exercise - breaking point
          • Exercise - breakdance
        • Continue
      • Iterating strings
        • Download exercises zip
        • Exercise - Impertinence
        • Exercise - rosco
        • Continue
      • Iterating lists
        • Download exercises zip
        • Exercise - The contest
        • Exercise - babbà
        • Exercise - The Temple of Fortune
        • Exercise - the longest word
        • Exercise - desert
        • Exercise - splash
        • Continue
      • Iterating tuples
        • Download exercises zip
        • Exercise - double couples
        • Exercise - carpet
        • Continue
      • Iterating sets
        • Download exercises zip
          • Questions - sets
        • Exercise - Screwed
        • Continue
      • Iterating dictionaries
        • Download exercises zip
        • Iterating keys
        • Iterating key-value pairs
        • Iterating values
        • Questions - iteration
        • Questions - Are they equivalent?
          • Are they equivalent ? postin
          • Are they equivalent ? cortel
          • Are they equivalent ? - gel
          • Are they equivalent ? - giri
          • Are they equivalent? - Found
        • Iteration exercises
          • Exercise - color of hearts
          • Exercise - jewels
          • Exercise - powers
          • Exercise - flowers
          • Exercise - art
          • Exercise - stationery stores
          • Exercise - legumes
          • Exercise - smog
          • Exercise - sports
          • Exercise - green lizard
        • Modifying a dictionary during iteration
          • Exercise - zazb
          • Exercise - DIY
          • Exercise - mine
        • Continue
      • Nested fors
        • Download exercises zip
        • Nested for
        • Questions - nested for
        • Exercise - casting
        • Exercise - cover the plane
        • Exercise - triangular
        • Exercise - port
        • Exercise - polygons
        • Exercise - bon jour
        • Continue
      • Challenges
        • Download exercises zip
        • Challenge - Faceborg
          • Faceborg 1. Ingestion
          • Faceborg 2. Selling your soul
          • Faceborg 3. Go where the money is
        • Challenge - The informant
    • While loops
      • Intro
        • Download exercises zip
        • What to do
        • Counting with a while
          • Terminating while
          • Non-terminating while
          • Questions
          • Esercises
          • Exercise - printeven
          • Exercise - average
        • break and continue commands
          • Terminate with a break
          • Jumping with continue
          • Questions about break and continue
        • Questions - Are they equivalent?
          • Are they equivalent? - BORG
          • Are they equivalent? - until 3
          • Are they equivalent? - by chance
          • Are they equivalent? - until six
          • Are they equivalent? - countdown 1
          • Are they equivalent? - countdown 2
          • Are they equivalent? - sorcery
          • Are they equivalent? - ping pong
          • Are they equivalent? - zanna
          • Are they equivalent? - pasticcio
        • Exercises - counters
          • Exercise - don’t break 1
          • Exercise - don’t break 2
          • Exercise - Give me a break
          • Exercise - paperboard
          • Exercise - until ten
          • Exercise - cccc
          • Exercise - converge
        • Searching a sequence
          • What we need
          • How to check
          • Exercise - Turbolenz with a break
          • Exercise - Turbulenz without break
          • Exercise - hangar
          • Exercise - Wild West
          • Exercise - The Balance of Language
          • Exercise - the tree shaker
          • Exercise - the ghost castle
        • Modifying sequences
          • Stack - Drawing from a card deck
          • Stack - Drawing until condition
          • Exercise - Don’t break my heart
          • Questions - what happens?
          • Questions - are they equivalent?
          • Are they equivalent? - train
          • Are they equivalent? - append nx
        • Exercises - stack
          • Exercise - break sum
          • Exercise - travelbook
          • Exercise - BANG !
          • Exercise - Growing or degrowing?
        • Continue
      • Challenges
        • Download exercises zip
        • Challenge - Consecutive letters
        • Challenge - Failed casinos
    • Sequences
      • Intro
        • Download exercises zip
        • What to do
        • Iterables - lists
        • iterables - range
        • Materializing a sequence
          • Questions - range
        • reversed
          • Iterating with next
          • Exercise - sconcerto
          • Materializing an iterator
        • sorted
          • Exercise - reversort
        • zip
          • Exercise - ladder
        • List comprehensions
          • List comprehensions on strings
        • Questions - List comprehensions
        • Exercises - list comprehension
          • Exercise - Bubble bubble
          • Exercise - root
          • Exercise - When The Telephone Rings
          • Exercise - don’t worry
          • Exercise - greater than 3
          • Exercise - even
          • Exercise - both ends
          • Exercise - dashes
          • Exercise - lollosa
          • Exercise - dog cat
          • Exercise - smurfs
          • Exercise - precious metals
        • Filtered list comprehensions
        • Questions - filtered list comprehensions
        • Exercises - filtered list comprehensions
          • Exercise - savannah
          • Exercise - puZZled
        • Exercise - Data science
        • Continue
      • Challenges
        • Download exercises zip
        • Challenge - ppulsar
        • Challenge - broken wisdom
        • Challenge - rupture
        • Challenge - cyclone
  • A3 Basic Algorithms
    • Functions, error handling and testing
      • Intro
        • Download exercises zip
        • Introduction
          • What to do
        • Why functions?
        • Function definition - questions
        • Different function kinds
          • SIDE EFFECTS
          • RETURN
          • MODIFY
          • MODIFY and RETURN
          • MODIFY AND RETURN A PART
        • Remember the commandments
          • III COMMANDMENT
          • IV COMMANDMENT
          • V COMMANDMENT
        • Immutable values
          • Changing the world: fail / 1
          • Changing the world: fail / 2
          • Changing the world: success!
          • global keyword
        • Mutable values
          • Doubling: fail / 1
          • Doubling: fail / 2
          • Doubling: fail / 3
          • Doubling: fail / 4
          • Doubling success!
        • Modifying parameters - Questions
        • Exercises - Changing music
          • Exercise - show
          • Exercise - authors
          • Exercise - record
          • Exercise - great
          • Exercise - shorten
        • Lambda functions
          • Exercise - apply_borders
          • Exercise - process
        • Continue
      • Error handling and testing
        • Download exercises zip
        • Introduction
          • What to do
        • Unforeseen situations
          • make_problematic_pie
        • Check with the return
        • Exceptions
          • Manage exceptions
          • Particular exceptions
        • assert
          • When to use assert?
        • Testing
          • Where Is Your Software?
          • Testing with asserts
          • Exercise structure
          • Exercise - gre3
          • Exercise - final_price
          • Exercise - arrival_time
        • Continue
      • Functions with strings
        • Download exercises zip
        • First functions
          • length
          • contains
          • invertlet
          • nspace
          • startend
          • swap
        • Verify comprehension
          • has_char
          • count
          • has_lower
          • dialect
          • countvoc
          • extract_email
          • canon_phone
          • phone_prefix
          • palindrome
        • Continue
      • Functions with lists
        • Download exercises zip
        • Introduction
          • Exercise - printwords
          • Exercise - printeven
          • Exercise - find26
          • Exercise - firstsec
          • Exercise - threeven
          • Exercise - separate_ip
          • Exercise - average
          • Exercise - Fake news generator
        • Functions with assert
          • Mapping
          • Exercise - newdoublef
          • Exercise - doublemod
          • Exercise - newdoublec
          • Exercise - up
          • Filtering
          • Exercise - remall
          • Exercise - only_capital_for
          • Exercise - only_capital_comp
          • Reducing
          • Exercise - sum_all
          • Exercise - sumevenf
          • Exercise - sumevenc
        • Other exercises
          • Exercise - contains
          • Exercise - firstn
          • Exercise - firstlast
          • Exercise - dup
          • Exercise - hasdup
          • Exercise - ord3
          • Exercise - filterab
          • Exercise - hill
          • Exercise - peak
          • Exercise - even
          • Exercise - mix
          • Exercise - fill
          • Exercise - nostop
          • Exercise - threez
        • Exercises with numbers
          • Exercise - listoint
          • Exercise - intolist
          • Exercise - add one
          • Exercise - collatz
        • Continue
      • Functions with tuples
        • Download exercises zip
          • Exercise - joined
          • nasty
        • Continue
      • Functions with sets
        • Download exercises zip
          • Exercise - syllabs
          • Exercise - distinguish
          • Exercise - intersectron
    • Matrices of lists
      • Intro
        • Download exercises zip
        • Introduction
        • What to do
        • Overview
        • Matrix dimensions
        • Visiting with style
          • Question - A matter of style 1
          • Question - A matter of style 2
          • Question - A matter of style 3
        • How to solve the exercises
        • Extracting rows and columns
          • How to extract a row
          • Extracting row pointers
          • Extract row with a for
          • Extract row with range
          • Extract row with a slice
          • Extract row with list comprehension
          • Extract column with a for
          • Extract column with a list comprehension
        • Creating new matrices
          • empty matrix
          • empty_matrix the elegant way
          • deep_clone
        • Modifying matrices
          • fillc
          • fillx
          • fillz
          • stitch_down
          • stitch_up
          • stitch_right
          • insercol
          • threshold
          • swap_rows
          • swap_cols
        • Continue
      • More exercises
        • Download exercises zip
        • What to do
        • Exercise - diag
        • Exercise - anti_diag
        • Exercise - is_utriang
        • Exercise - stitch_left_mod
        • Exercise - transpose_1
        • Exercise - transpose_2
        • Exercise - cirpillino
        • Exercise - flag
        • Exercise - avoid_diag
        • Exercise - no_diag
        • Exercise - no_anti_diag
        • Exercise - repcol
        • Exercise - matinc
        • Exercise - flip
        • Exercise - wall
        • Exercise - sortlast
        • Exercise - skyscraper
        • Exercise - school lab
        • Exercise - dump
        • Esercizio - toepliz
        • Exercise - matrix multiplication
        • Exercise - check_nqueen
        • Continue
      • Challenges
        • Download exercises zip
        • Challenge - Tiles
        • Challenge - The Ark
          • The Ark 1. Sort the herd
          • The Ark 2. Enter the Farm
          • The Ark 3. Enter the Ark
          • The Ark 4. Aurora
        • Challenge - Go camping
    • Mixed structures
      • Intro
        • Download exercises zip
        • Exercise - Luxury Holding
          • Exercise - extract_managers
          • Exercise - extract_companies
          • Exercise - avg_age
          • Exercise - sectors
        • Exercise - averages
        • Exercise - has_pref
        • Exercise - festival
        • Exercise - actorswap
        • Continue
      • Challenges
        • Download exercises zip
        • Challenge - Guilty!
    • Numpy matrices
      • Intro
        • Download exercises zip
        • Introduction
          • What to do
        • np.array
        • Creating a matrix filled with ones
        • Creating a matrix filled with a number k
        • Dimensions of a matrix
        • Reading and writing
          • Filling the whole matrix
          • Slices
          • Writing a constant in a slice
          • Writing a matrix into a slice
        • Assignment and copy
        • Calculations
          • Scalar multiplication
          • Scalar sum
          • Multiplication
          • Dividing by a scalar
        • Aggregation
          • Aggregating by row or column
        • Filtering
          • Finding indexes with np.where
          • Writing into cells which satisfy a criteria
        • arange and linspace sequences
        • NaNs and infinities
          • NaNs
          • Detecting NaN
          • Sequences with NaNs
          • Exercise NaN: two vars
          • Operations on NaNs
          • NaN and Numpy
          • Where are the NaNs ?
          • Infinities
          • Positive infinity np.inf
          • Negative infinity
          • Combining infinities and NaNs
          • Negative zero
          • Exercise: detect proper numbers
          • Exercise: guess expressions
        • Continue
      • Exercises
        • Download exercises zip
        • Introduction
          • frame
        • Exercise - frameslices
        • Exercise - framefill
        • Exercise - avg_rows
        • Exercise - matrot
        • Exercise - odd
        • Exercise - doublealt
        • Exercise - chessboard
        • Exercise - altsum
        • Exercise - avg_half
        • Exercise - matxarr
        • Exercise - colgap
        • Exercise - substmax
        • Exercise - quadrants
        • Exercise - downup
        • Exercise - stairsteps
        • Exercise - vertstairs
        • Exercise - comprescol
        • Exercise - revtriang
        • Exercise - walkas
        • Exercise - walkaz
        • Continue
        • References
  • B - Data Analysis
    • Data formats
      • Line files
        • Download exercises zip
        • Introduction
          • What to do
        • Line files
          • open command
          • The encoding
          • with block
        • people-complex line file
        • Exercise - line file immersione-in-python-toc
        • Continue
      • CSV files
        • Download exercises zip
          • Why parsing a CSV ?
          • Reading a CSV
          • What’s a reader ?
          • Consuming a file
          • Reading as dictionaries
        • Writing a CSV
        • Reading and writing a CSV
        • CSV Botteghe storiche
          • Problem: wrong characters ??
          • Botteghe storiche in Python
          • Botteghe storiche - rank_categories
          • Botteghe storiche - enrich
        • CSV Air quality
          • load_air_quality
          • calc_avg_pollution
        • Continue
      • JSON files
        • Download exercises zip
          • JSONL
        • Continue
      • Challenges
        • Download exercises zip
        • Parsing challenge - Spam killer
          • Spam killer 1. mail reader
          • Spam killer 2. running filters
        • Parsing challenge - Markdown
        • Parsing challenge - Other languages
        • CSV Challenge - Over the top
          • Over the top 1. reading OpenStreetMap data
          • Over the top 2. extract peak
          • Over the top 3. write file
    • Visualization
      • Intro
        • Download exercises zip
        • Introduction
          • What to do
        • First example
          • Plot style
          • x power 2 exercise
          • Axis limits
          • Axis size
          • Changing tick labels
        • Multiple lines
        • Numpy
          • Example without numpy
          • Example with numpy
          • Exercise - sin(x) + 3
        • Bar plots
          • Exercise - goleadors
          • Exercise - chemical elements
          • Exercise - superheroes
        • Showing plots side by side
          • Exercise - sin(kx)
        • Other plots
          • Pie chart
        • Fancy plots
          • Background color
          • Text
          • Images
          • Color intensity
          • Exercise - Be fancy
        • Continue
      • Challenges
        • Download exercises zip
        • The variables
        • 1. plot_sheet
        • 2. plot_pentagram
        • 3. plot_notes
        • Final result 1:
        • Final result 2
      • Images
        • Download exercises zip
          • What to do
        • Introduction
          • Monochrome
        • Focus
          • Exercise - Head focus
        • hstack and vstack
          • Exercise - Passport
        • flip
          • Exercise - Hall of mirrors
          • Exercise - The nose from above
        • Writing arrays
        • Writing into images
          • Exercise - Stripes
        • In a dark integer night
          • The Integer Shining
          • Exercise - Be bright
        • RGB - Get colorful
        • Exercise - Focus - top left
        • Exercise - Focus - bottom - left
        • Exercise - Focus - bottom - right
        • Exercise - Focus - top - right
        • Exercise - Look the other way
        • Exercise - Upside down world
        • Exercise - Shrinking Walls - X
        • Exercise - Shrinking Walls - Y
        • Exercise - Shrinking World
        • Exercise - Pixellate
        • Exercise - Feeling Red
        • Exercise - Feeling Green
        • Exercise - Feeling Blue
        • Exercise - No Red
        • Exercise - No Green
        • Exercise - No Blue
        • Exercise - Feeling Gray again
        • Exercise - Beyond the limit
        • Exercise - Gimme light
        • Exercise - When the darkness comes - with a warning
        • Exercise - When the darkness comes - without a warning
        • Exercise - Fade to black
        • Exercise - vertical fade
    • Pandas
      • Intro
        • Download exercises zip
        • 1. What to do
          • Check installation
          • Which pandas should I use?
        • 2. Data analysis of Astro Pi
          • 2.1 Let’s import the file
          • 2.2 Memory
          • 2.3 Dimensions
          • 2.4 Let’s explore!
          • 2.5 Some stats
          • 2.6 Guardiamo le colonne
          • 2.7 What is a column?
          • 2.8 Exercise - meteo info
        • 3. MatPlotLib review
          • 3.1 An example
          • 3.2 Matplotlib plots from pandas datastructures
        • 4. Operations on rows
          • 4.1 Indexing integers
          • Difference between iloc and loc
          • 4.2 Filtering
          • 4.3 Sorting
          • 4.4 Exercise - Meteo stats
          • 4.5 Exercise - meteo plot
          • 4.6 Exercise - Meteo pressure and raining
        • 5. Object values and strings
          • 5.1 Filter by textual values
          • 5.2 Extracting strings
        • 6. Operations on columns
          • 6.1 - Selecting columns
          • 6.2 - Adding columns
          • 6.2.1 Exercise: Meteo temperature in Fahrenheit
          • 6.2.2 Exercise - Pressure vs Temperature
          • 6.3 Scrivere in colonne filtrate con loc
          • 6.3 Transforming columns
        • 7. Other exercises
          • 7.1 Exercise - Air pollutants
          • 7.2 Exercise - Game of Thrones
          • 7.3 Exercise - Healthcare facilities
        • Continue
      • Advanded operations
        • Download exercises zip
        • 1. Grouping
          • 1.1 Let’s see a group
          • 1.2 groupby
          • 1.3 Modifying a dataframe by plugging in the result of a grouping
          • 1.4 Exercise - meteo pressure intervals
          • 1.5 Exercise - meteo average temperature
        • 2. Merging tables
          • Exercise 2.1 - better merge
        • 3. GeoPandas
        • Continue
      • Challenges
        • Download exercises
          • What to do
        • Load the dataset
        • Tell me more
        • Getting in shape
        • 10 rows
        • Born in Verona
        • How many people in Verona
        • Python is everywhere
        • Verona after 1500
        • First Antonio
        • Some Antonio
        • Cesares during 1800
        • The old ones
        • Cities of poets
        • Most duplicated poets
        • All duplicated poets
        • Northern poets
        • Papers please
        • Unknown poets
        • Better unknown poets
    • Relational data
      • Intro
        • Download exercises zip
          • Required libraries
        • What to do
          • Graph definition
          • Edge weights
        • Matrices
          • Visualization examples
          • Saving a graph to an image file
          • Saving a graph to an dot file
          • Minimal graph
          • Graph with two nodes example
          • Distance matrix
          • Boolean matrix example
          • Matrix exercises
          • Exercise - line
          • Exercise - cross
          • union
          • Exercise - union
          • Subgraphs
          • Exercise - is_subgraph
          • Exercise - remove_node
          • Exercise - utriang
          • Edge difference
          • Exercise - ediff
          • Exercise - pyramid
        • Adjacency lists
          • Exercise - mat_to_adj
          • Exercise - mat_ids_to_adj
          • Exercise - adj_to_mat
          • Exercise - table_to_adj
        • Networkx
          • Fancy networkx graphs
          • Converting networkx graphs
          • Exercise - mat_to_nx
        • Continue
      • Binary relations
        • Download exercises zip
        • What to do
        • Reflexive relations
          • Exercise - is_reflexive_mat
          • Exercise - is_reflexive_adj
        • Symmetric relations
          • Exercise - is_symmetric_mat
          • Exercise - is_symmetric_adj
        • Surjective relations
          • Exercise - surjective
        • Further resources
        • Continue
      • Simple statistics
        • Download exercises zip
        • What to do
        • Outdegrees and indegrees
          • Exercise - outdegree_adj
          • Exercise - outdegree_mat
          • Exercise - outdegree_avg
          • Exercise - indegree_adj
          • Exercise - indegree_mat
          • Exercise - indegree_avg
          • Was it worth it?
          • networkx Indegrees and outdegrees
        • Visualizing distributions
        • indegree per node
          • indegree per node bar plot
          • indegree per node sorted alphabetically
          • indegree per node sorted
          • out degrees per node sorted
          • degrees per node
          • In out degrees per node
        • Frequency histogram
          • Exercise - better histogram display
        • Graph models
          • Exercise - Erdős–Rényi model
        • Continue
      • Challenges
        • Download exercises zip
        • Matrices
          • Challenge - trichain
          • Challenge - Bipartite
          • Challenge - Luna park
          • Challenge - Factory
          • Challenge - Sharing is caring
          • Challenge - Hexagons
          • Challenge - Trust your tribe
        • Adjacency lists
          • Challenge - From matrices to adjacency lists
          • Challenge - Friends
          • Challenge - Counter Intelligence
        • Networkx
          • Challenge - Offshore
          • Challenge - Cashflow
  • C - Applications
    • Database
      • Downlod exercises zip
      • What to do
      • A first look to the database
      • SQLStudio connection
      • Python connection
      • Performance
      • Passing parameters to the query
      • Execute query function
        • Table structure
        • DDL
        • Query to metadata
      • ORDER BY
      • JOIN
      • Track Table
      • Aggregating data
        • COUNT
        • GROUP BY and COUNT
      • Pandas
  • D - Projects
    • Text data
      • Phone calls
        • Download worked project
        • What to do
        • 1. canonical
        • 2. prefix
        • 3. hist
        • 4. display calls
      • Music sequencer
        • Download worked project
        • What to do
        • 1. parse_melody
        • 2. parse_tunes
        • 3. sequencer
        • 4. plot_tune
    • Tabular data
      • Bus speed
        • Download worked project
        • What to do
        • The dataset
        • to_float_hour
        • plot
      • Town events
        • Download worked project
        • What to do
        • The dataset
        • 1. leap_year
        • 2. full_date
        • 3. partial_date
        • 4. parse_dates_and
      • What’s your business?
        • Download worked project
        • What to do
        • NACE Sections
          • Section detail
          • Specifications
          • NACE CSV
        • 1. Extracting codes
        • 1.1 is_nace
        • 1.2 extract_codes
        • 2. build_db
        • 3. plot
      • Zoom surveillance
        • Download worked project
        • What to do
        • CSV format
        • 1. time24
        • 2. load
        • 3.1 duration
        • 3.2 calc_stats
        • 4. viz
      • I CHING Divination
        • Download worked project
        • What to do
        • The dataset
        • 1. load_db
        • 2. divine
        • 3. plot_divination
      • Witchcraft
        • Download worked project
        • What to do
        • The dataset
        • 1. parse_bool_cols
        • 2. fix_date
        • 3. parse_db
        • 4. plot_cases
      • Galactic love
        • Download worked project
        • What to do
        • parse_stars
        • plot_stars 1
        • plot_stars 2 - new_center
        • parse_zodiac
        • plot_love
      • University staff
        • Download worked project
        • What to do
        • load_data
        • 1. calc_uid_to_abbr
        • 2.1 calc_prof_roles
        • 2.2 plot_profs
        • 3.1 calc_roles
        • 3.2 plot_roles
        • 4.1 calc_shared
        • 4.2 plot_shared
      • ITEA Real Estate
        • Download worked project
        • What to do
        • load_itea
        • calc_types_hist
        • calc_types_series
        • Real estates plot
      • Price catalog
        • Download worked project
        • What to do
        • The dataset
        • A1 extract_bounds
        • A2 extract_product
        • A3 plot_product
      • EURES job offers
        • Download worked project
          • What to do
        • Introduction
        • offerte dataset
        • rename columns
        • 1. Rename countries
          • 1.1 countries_to_list
          • 1.2 Filling column Workplace Country
        • 2. Work dates
          • 2.1 from_to function
          • 2.2. From To columns
        • 3. Required languages
          • 3.1 function reqlan
          • 3.2 Languages column
        • Continue
    • Relational data
      • Trans-Atlantic Slave Trade
        • Download worked project
        • What to do
        • 1. read_trade
        • 2. Deportation
        • 3. The time to stop
      • Bud Spencer and Terence Hill movies
        • Download worked project
        • What to do
        • The datasets
        • 1. load
        • 2. save_table
        • 3. show_graph
      • Bus network
        • Download worked project
        • What to do
        • Introduction
          • Colors and additional attributes
          • load_stops
        • 1. extract_routes
        • 2. to_int_min
        • 3. get_legend_edges
        • 4. calc_nx
        • 5. Hubs
          • Implement color_hubs
        • 6. plot_timings
      • Wikispeedia
        • Download worked project
        • What to do
        • The dataset
        • 1. filter_back
        • 2. load_db
        • 3. calc_stats
        • 4. plot_network
      • Mexican Drug Wars
        • Download worked project
        • What to do
        • Election attacks dataset
        • 1. load_mexico
        • 2. show_attacks
        • 3. Cartels
      • Wordnet
        • Download worked project
        • What to do
        • 1. parse_db
          • Field description
          • Parsing the db
        • 2. to_adj
          • Check results
        • 3. hist
      • Metamath
        • Download worked project
        • What to do
        • Metamath db
        • 1. Metamath db
        • 2.1 Metamath proof
        • 2. Checking proof
          • Overview plot
          • Detail plot
        • 3. Top statements
  • E - Appendix
    • Commandments
      • I COMMANDMENT
      • II COMMANDMENT
      • III COMMANDMENT
      • IV COMMANDMENT
      • V COMMANDMENT
      • VI COMMANDMENT
      • VII COMMANDMENT
      • VIII COMMANDMENT
      • IX COMMANDMENT
      • X COMMANDMENT
    • Revisions
      • July 2020
    • References
      • Foundations of Python Programming
      • W3Resources website
      • Software Carpentry
      • Edabit
        • Edabit - Basics
        • Edabit - Strings
        • Edabit - Lists
        • Edabit - Dictionaries
        • Edabit - Matrices
      • LeetCode
        • LeetCode - Strings
        • LeetCode - Lists
        • LeetCode - Sets and Dictionaries
      • LeetCode - Matrices
        • Leet code - Graphs
      • HackerRank
      • Geeks for Geeks
      • Dive into Python 3
      • Introduction to Scientific Programming with Python
  • Index
SoftPython

© Copyright # CC-BY 2017 - 2023, David Leoni, Alessio Zamboni, Marco Caresia.

Built with Sphinx using a theme provided by Read the Docs.