Python Functions, Files, and Dictionaries

This course introduces the basics of Python 3, including conditional execution and iteration as control structures, and strings and lists as data structures. Course outline and certification by University of Michigan

Enroll Now

Online Training

Certification offered by

The mission of the University of Michigan is to serve the people of Michigan and the world through preeminence in creating, communicating, preserving and applying knowledge, art, and academic values, and in developing leaders and citizens who will challenge the present and enrich the future.

Key Points About This Course

Duration: 3 Days
Time: 9.00am-5.00pm
Public Class Fee: RM 3,500.00
Virtual Class Fee: RM 2,975.00
HRDF Claimable

Course Overview

This course introduces the dictionary data structure and user-defined functions. You’ll learn about local and global variables, optional and keyword parameter-passing, named functions and lambda expressions. You’ll also learn about Python’s sorted function and how to control the order in which it sorts by passing in another function as an input. For your final project, you’ll read in simulated social media data from a file, compute sentiment scores, and write out .csv files. It covers chapters 10-16 of the textbook “Fundamentals of Python Programming,” which is the accompanying text for this course.

The course is well-suited for you if you have already taken the “Python Basics” course and want to gain further fundamental knowledge of the Python language. Together, both courses are geared towards newcomers to Python programming, those who need a refresher on Python basics, or those who may have had some exposure to Python programming but want a more in-depth exposition and vocabulary for describing and reasoning about programs.

Course Content

Part 1: Files and CSV Output

In part one the lectures and the Runestone textbook will introduce you to the idea of incorporating files into your programs as an additional source of data. You will learn how to read from a file, write to a file, and how to work with the .csv data format.

  • Introduction: Working with Data Files
  • Reading a File
  • Alternative File Reading Methods
  • Iterating Over Lines in a File
  • Finding a File in Your File System
  • Writing to a File
  • Using With to Open Files
  • Conclusion: Files
  • Introduction: .csv Format
  • Reading a .csv File
  • Writing Data to a .csv File
  • Tips on Handling Files
  • Tips on File Naming
  • Conclusion: .csv Format

Part 2: Dictionaries and Dictionary Accumulation

In part two the lectures and the Runestone textbook will focus on a new data type, dictionaries. You will be introduced to the mechanics of dictionaries and then get practice using them in accumulation patterns, both to build a dictionary using the pattern as well as find the best, or worst, result using the pattern.

  • Dictionaries
  • Demonstration: Dictionary Basics
  • Dictionary Operations
  • Dictionary Methods
  • Demonstration: Dictionary Methods
  • Aliasing and Copying with Dictionaries
  • Dictionary Accumulation
  • Demonstration: Dictionary Accumulation
  • Introduction: Accumulating Multiple Results in a Dictionary
  • Accumulating Results From a Dictionary
  • Demonstration: Accumulating Results From a Dictionary
  • Accumulating the Best Key
  • When to Use a Dictionary
  •  

Part 3: Functions and Tuples

In part three you will be introduced to the construction of functions. Up to this point, you have used functions in the programs before, but have not had a chance to write your own functions, including how to define a function, how to incorporate parameters, how to return data from a function, the local or global scope of variables, and potential side effects that could occur from function execution. Finally, we look at tuples more in depth, and how automatic packing and unpacking of tuples can be used in functions and in for loops.

  • Introduction: Functions
  • Defining Functions
  • Function Invocation
  • Positional Parameter Passing
  • Returning Values
  • Way of the Programmer: Decoding a Function
  • A Function that Accumulates
  • Conclusion: Functions
  • Introduction: Variable Scoping and Side Effects
  • Local and Global Variables
  • Function Composition
  • Flow of Execution Summary
  • Print vs. Return
  • Mutable Objects and Side Effects
  • Conclusion: Variable Scoping and Side Effects
  • Introduction: Tuple Packing and Unpacking
  • Tuple Packing
  • Tuple as Return Values
  • Tuple Assignment with Unpacking
  • Unpacking Into Iterator Variables
  • Conclusion: Tuple Packing and Unpacking

Part 4: More Iteration and Advanced Functions

In part four, the lectures and the Runestone textbook will outline a more advanced iteration mechanism, the while loop. You will be introduced to using it when getting feedback from users, as well as applying it to the turtle module to draw images. Additionally, you will also be exposed to more advanced function concepts such as the idea of parameters being optional, not required, and anonymous functions using lambda.

  • The While Statement
  • The Listener Loop
  • Randomly Walking Turtles
  • Break and Continue
  • Way of the Programmer: Infinite Loops
  • Optional Parameters
  • Keyword Parameters
  • Anonymous Functions with Lambda Expressions

Part 5: Sorting

In part five the videos and Runestone textbook will detail how to sort python objects – both the basics and more advanced forms of sorting for dictionaries and how to break a tie (if that occurs). The final course assessment will be a project that asks you to read fake, auto-generated data from a social media site to analyze social media post sentiments. You will submit a csv file as well as images of graphs that demonstrate your findings.

  • Introduction: Sorting Basics
  • Invoking .Sort and Sorted
  • Optional Reverse Parameter
  • Optional Key Parameter
  • Conclusion – Sorting Basics
  • Introduction: Advanced Sorting
  • Sorting a Dictionary’s Keys
  • Breaking Ties
  • Way of the Programmer: When to Use a Lambda Expression
  • When to Use Lambda vs. Function
  • Conclusion: Advanced Sorting

Training Schedule

15 – 17 Feb 2021
19 – 21 Apr 2021
21 – 23 Jun 2021
2 – 4 Aug 2021
11 – 13 Oct 2021
13 – 15 Dec 2021

  • Public Class Training

  • Date Format: DD slash MM slash YYYY
  • Date Format: DD slash MM slash YYYY
  • Your Information

  • Participant List

  • NameContact NumberDesignation 
  • Examination (Optional)

Enquiry Form

Call Us : 03-21165778