Provides an introductory level understanding of the Python Programming Language and language features. Serves as a guide for beginners and a reference to Python basics and language use cases.
This document provides an introduction to the Python programming language. It covers Python's background, syntax, types, operators, control flow, functions, classes, tools, and IDEs. Key points include that Python is a multi-purpose, object-oriented language that is interpreted, strongly and dynamically typed. It focuses on readability and has a huge library of modules. Popular Python IDEs include Emacs, Vim, Komodo, PyCharm, and Eclipse.
It describe the whole detail of html, CSS , html5 for descibing how to use html tags and where we use html tags. It describe the whole detail of html and CSS.
This document provides an introduction and overview of the Python programming language. It covers Python's history and key features such as being object-oriented, dynamically typed, batteries included, and focusing on readability. It also discusses Python's syntax, types, operators, control flow, functions, classes, imports, error handling, documentation tools, and popular frameworks/IDEs. The document is intended to give readers a high-level understanding of Python.
Python is a versatile, object-oriented programming language that can be used for web development, data analysis, and more. It has a simple syntax and is easy to read and learn. Key features include being interpreted, dynamically typed, supporting functional and object-oriented programming. Common data types include numbers, strings, lists, dictionaries, tuples, and files. Functions and classes can be defined to organize and reuse code. Regular expressions provide powerful string manipulation. Python has a large standard library and is used widely in areas like GUIs, web scripting, AI, and scientific computing.
After the end of lesson you will be able to learn Python basics-What Python is? Its releases. Where we can use Python? Python Features. Tokens, comments variables etc... In out next PPT you will learn how to input and get output in Python
It’s long ago, approx. 30 years, since AI was not only a topic for Science-Fiction writers, but also a major research field surrounded with huge hopes and investments. But the over-inflated expectations ended in a subsequent crash and followed by a period of absent funding and interest – the so-called AI winter. However, the last 3 years changed everything – again. Deep learning, a machine learning technique inspired by the human brain, successfully crushed one benchmark after another and tech companies, like Google, Facebook and Microsoft, started to invest billions in AI research. “The pace of progress in artificial general intelligence is incredible fast” (Elon Musk – CEO Tesla & SpaceX) leading to an AI that “would be either the best or the worst thing ever to happen to humanity” (Stephen Hawking – Physicist).
What sparked this new Hype? How is Deep Learning different from previous approaches? Are the advancing AI technologies really a threat for humanity? Let’s look behind the curtain and unravel the reality. This talk will explore why Sundar Pichai (CEO Google) recently announced that “machine learning is a core transformative way by which Google is rethinking everything they are doing” and explain why "Deep Learning is probably one of the most exciting things that is happening in the computer industry” (Jen-Hsun Huang – CEO NVIDIA).
Either a new AI “winter is coming” (Ned Stark – House Stark) or this new wave of innovation might turn out as the “last invention humans ever need to make” (Nick Bostrom – AI Philosoph). Or maybe it’s just another great technology helping humans to achieve more.
The document provides a revision table comparing the key properties and functions of strings, lists, tuples and dictionaries in Python.
It defines each data type and provides examples of their initialization and use. It also summarizes common operations like indexing, slicing, membership testing, comparison operators and various functions that can be performed on each data type like joining, traversing, modifying and retrieving values. Finally, it lists some practice questions focusing on operations related to these fundamental Python data types.
This presentation provides the information on python including the topics Python features, applications, variables and operators in python, control statements, numbers, strings, print formatting, list and list comprehension, dictionaries, tuples, files, sets, boolean, mehtods and functions, lambda expressions and a sample project using Python.
Python Pandas is a powerful library for data analysis and manipulation. It provides rich data structures and methods for loading, cleaning, transforming, and modeling data. Pandas allows users to easily work with labeled data and columns in tabular structures called Series and DataFrames. These structures enable fast and flexible operations like slicing, selecting subsets of data, and performing calculations. Descriptive statistics functions in Pandas allow analyzing and summarizing data in DataFrames.
This document discusses Python libraries and modules. It defines a library as a collection of modules that provide specific functionality. The standard library contains commonly used modules like math and random. Other important libraries mentioned are NumPy, SciPy, and tkinter. A module is a .py file that contains related variables, classes, functions etc. Modules can be imported using import, from, or from * statements. Namespaces and module aliasing are also covered. The document concludes by explaining how to create Python packages and the role of the __init__.py file in making a directory a package.
The document provides an introduction to Python programming. It discusses key concepts like variables, data types, operators, and sequential data types. Python is presented as an interpreted programming language that uses indentation to indicate blocks of code. Comments and documentation are included to explain the code. Various data types are covered, including numbers, strings, booleans, and lists. Operators for arithmetic, comparison, assignment and more are also summarized.
This Edureka Python Programming tutorial will help you learn python and understand the various basics of Python programming with examples in detail. Below are the topics covered in this tutorial:
1. Python Installation
2. Python Variables
3. Data types in Python
4. Operators in Python
5. Conditional Statements
6. Loops in Python
7. Functions in Python
8. Classes and Objects
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYAMaulik Borsaniya
Introduction to Python:
The basic elements of Python, Objects, expressions and numerical Types, Variables and assignments, IDLE, Branching programs, Strings and Input, Iteration
Structured Types, Mutability and Higher-order Functions:
Tuples, Lists and Mutability, Functions as Objects, Strings, Tuples and Lists, Dictionaries
The document provides an introduction to Python programming. It discusses installing and running Python, basic Python syntax like variables, data types, conditionals, and functions. It emphasizes that Python uses references rather than copying values, so assigning one variable to another causes both to refer to the same object.
A class is a code template for creating objects. Objects have member variables and have behaviour associated with them. In python a class is created by the keyword class.
An object is created using the constructor of the class. This object will then be called the instance of the class.
Youtube Link: https://youtu.be/woVJ4N5nl_s
** Python Certification Training: https://www.edureka.co/data-science-python-certification-course **
This Edureka PPT on 'Python Basics' will help you understand what exactly makes Python special and covers all the basics of Python programming along with examples.
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
This Edureka Python tutorial is a part of Python Course (Python Tutorial Blog: https://goo.gl/wd28Zr) and will help you in understanding what exactly is Python and its various applications. It also explains few Python code basics like data types, operators etc. Below are the topics covered in this tutorial:
1. Introduction to Python
2. Various Python Features
3. Python Applications
4. Python for Web Scraping
5. Python for Testing
6. Python for Web Development
7. Python for Data Analysis
Modules allow grouping of related functions and code into reusable files. Packages are groups of modules that provide related functionality. There are several ways to import modules and their contents using import and from statements. The document provides examples of creating modules and packages in Python and importing from them.
Python is a widely-used and powerful computer programming language that has helped system administrators manage computer networks and problem solve computer systems for decades. Python has also built some popular applications like BitTorrent, Blender, Calibre, Dropbox, and much more. Going further, the “Pi” in Raspberry Pi stands for Python, so learning Python will instill more confidence when working with Raspberry Pi projects. Python is usually the first programming language people learn primarily because it is easy to learn and provides a solid foundation to learn other computer programming languages. In this webinar,
• Learn what Python is and what it is capable of doing.
• Install Python’s IDE for Windows and work in the Python shell.
• Use calculations, variables, strings, lists, and if statements.
• Discover Python’s built-in functions and understand modules.
• Create simple programs to build on later.
The recording is available at https://youtu.be/ThcWmJFf-ho.
This document provides an overview of Python for data analysis using the pandas library. It discusses key pandas concepts like Series and DataFrames for working with one-dimensional and multi-dimensional labeled data structures. It also covers common data analysis tasks in pandas such as data loading, aggregation, grouping, pivoting, filtering, handling time series data, and plotting.
The document provides an introduction to Python programming. It discusses that Python is a high-level, interpreted, object-oriented, and general purpose programming language. It can be used for web development, scientific computing, desktop applications, and more. The document then covers Python basics like data types, variables, literals, operators, control flow statements, functions, modules and packages. It also discusses installing Python on Windows and writing the first Python program.
All data values in Python are encapsulated in relevant object classes. Everything in Python is an object and every object has an identity, a type, and a value. Like another object-oriented language such as Java or C++, there are several data types which are built into Python. Extension modules which are written in C, Java, or other languages can define additional types.
To determine a variable's type in Python you can use the type() function. The value of some objects can be changed. Objects whose value can be changed are called mutable and objects whose value is unchangeable (once they are created) are called immutable.
Pandas is an open source Python library that provides data structures and data analysis tools for working with tabular data. It allows users to easily perform operations on different types of data such as tabular, time series, and matrix data. Pandas provides data structures like Series for 1D data and DataFrame for 2D data. It has tools for data cleaning, transformation, manipulation, and visualization of data.
Python functions allow for reusable code through defining functions, passing arguments, returning values, and setting scopes. Functions can take positional or keyword arguments, as well as variable length arguments. Default arguments allow functions to specify default values for optional parameters. Functions are objects that can be assigned to variables and referenced later.
This document provides an overview of the Python programming language. It discusses what Python is, its key features, who uses it, common applications, and how to download and install Python. It then covers Python syntax concepts like identifiers, keywords, multiline statements, docstrings, indentation, comments, and string formatting. The document also introduces Python data types like numbers, strings, lists, tuples, dictionaries, sets and how to work with them. It describes how to convert between number types and access/update strings and lists. Finally, it discusses Python development environments like Anaconda and Spyder.
The basics of Python are rather straightforward. In a few minutes you can learn most of the syntax. There are some gotchas along the way that might appear tricky. This talk is meant to bring programmers up to speed with Python. They should be able to read and write Python.
The Agenda for the Webinar:
1. Introduction to Python.
2. Python and Big Data.
3. Python and Data Science.
4. Key features of Python and their usage in Business Analytics.
5. Business Analytics with Python – Real world Use Cases.
This presentation provides the information on python including the topics Python features, applications, variables and operators in python, control statements, numbers, strings, print formatting, list and list comprehension, dictionaries, tuples, files, sets, boolean, mehtods and functions, lambda expressions and a sample project using Python.
Python Pandas is a powerful library for data analysis and manipulation. It provides rich data structures and methods for loading, cleaning, transforming, and modeling data. Pandas allows users to easily work with labeled data and columns in tabular structures called Series and DataFrames. These structures enable fast and flexible operations like slicing, selecting subsets of data, and performing calculations. Descriptive statistics functions in Pandas allow analyzing and summarizing data in DataFrames.
This document discusses Python libraries and modules. It defines a library as a collection of modules that provide specific functionality. The standard library contains commonly used modules like math and random. Other important libraries mentioned are NumPy, SciPy, and tkinter. A module is a .py file that contains related variables, classes, functions etc. Modules can be imported using import, from, or from * statements. Namespaces and module aliasing are also covered. The document concludes by explaining how to create Python packages and the role of the __init__.py file in making a directory a package.
The document provides an introduction to Python programming. It discusses key concepts like variables, data types, operators, and sequential data types. Python is presented as an interpreted programming language that uses indentation to indicate blocks of code. Comments and documentation are included to explain the code. Various data types are covered, including numbers, strings, booleans, and lists. Operators for arithmetic, comparison, assignment and more are also summarized.
This Edureka Python Programming tutorial will help you learn python and understand the various basics of Python programming with examples in detail. Below are the topics covered in this tutorial:
1. Python Installation
2. Python Variables
3. Data types in Python
4. Operators in Python
5. Conditional Statements
6. Loops in Python
7. Functions in Python
8. Classes and Objects
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYAMaulik Borsaniya
Introduction to Python:
The basic elements of Python, Objects, expressions and numerical Types, Variables and assignments, IDLE, Branching programs, Strings and Input, Iteration
Structured Types, Mutability and Higher-order Functions:
Tuples, Lists and Mutability, Functions as Objects, Strings, Tuples and Lists, Dictionaries
The document provides an introduction to Python programming. It discusses installing and running Python, basic Python syntax like variables, data types, conditionals, and functions. It emphasizes that Python uses references rather than copying values, so assigning one variable to another causes both to refer to the same object.
A class is a code template for creating objects. Objects have member variables and have behaviour associated with them. In python a class is created by the keyword class.
An object is created using the constructor of the class. This object will then be called the instance of the class.
Youtube Link: https://youtu.be/woVJ4N5nl_s
** Python Certification Training: https://www.edureka.co/data-science-python-certification-course **
This Edureka PPT on 'Python Basics' will help you understand what exactly makes Python special and covers all the basics of Python programming along with examples.
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
This Edureka Python tutorial is a part of Python Course (Python Tutorial Blog: https://goo.gl/wd28Zr) and will help you in understanding what exactly is Python and its various applications. It also explains few Python code basics like data types, operators etc. Below are the topics covered in this tutorial:
1. Introduction to Python
2. Various Python Features
3. Python Applications
4. Python for Web Scraping
5. Python for Testing
6. Python for Web Development
7. Python for Data Analysis
Modules allow grouping of related functions and code into reusable files. Packages are groups of modules that provide related functionality. There are several ways to import modules and their contents using import and from statements. The document provides examples of creating modules and packages in Python and importing from them.
Python is a widely-used and powerful computer programming language that has helped system administrators manage computer networks and problem solve computer systems for decades. Python has also built some popular applications like BitTorrent, Blender, Calibre, Dropbox, and much more. Going further, the “Pi” in Raspberry Pi stands for Python, so learning Python will instill more confidence when working with Raspberry Pi projects. Python is usually the first programming language people learn primarily because it is easy to learn and provides a solid foundation to learn other computer programming languages. In this webinar,
• Learn what Python is and what it is capable of doing.
• Install Python’s IDE for Windows and work in the Python shell.
• Use calculations, variables, strings, lists, and if statements.
• Discover Python’s built-in functions and understand modules.
• Create simple programs to build on later.
The recording is available at https://youtu.be/ThcWmJFf-ho.
This document provides an overview of Python for data analysis using the pandas library. It discusses key pandas concepts like Series and DataFrames for working with one-dimensional and multi-dimensional labeled data structures. It also covers common data analysis tasks in pandas such as data loading, aggregation, grouping, pivoting, filtering, handling time series data, and plotting.
The document provides an introduction to Python programming. It discusses that Python is a high-level, interpreted, object-oriented, and general purpose programming language. It can be used for web development, scientific computing, desktop applications, and more. The document then covers Python basics like data types, variables, literals, operators, control flow statements, functions, modules and packages. It also discusses installing Python on Windows and writing the first Python program.
All data values in Python are encapsulated in relevant object classes. Everything in Python is an object and every object has an identity, a type, and a value. Like another object-oriented language such as Java or C++, there are several data types which are built into Python. Extension modules which are written in C, Java, or other languages can define additional types.
To determine a variable's type in Python you can use the type() function. The value of some objects can be changed. Objects whose value can be changed are called mutable and objects whose value is unchangeable (once they are created) are called immutable.
Pandas is an open source Python library that provides data structures and data analysis tools for working with tabular data. It allows users to easily perform operations on different types of data such as tabular, time series, and matrix data. Pandas provides data structures like Series for 1D data and DataFrame for 2D data. It has tools for data cleaning, transformation, manipulation, and visualization of data.
Python functions allow for reusable code through defining functions, passing arguments, returning values, and setting scopes. Functions can take positional or keyword arguments, as well as variable length arguments. Default arguments allow functions to specify default values for optional parameters. Functions are objects that can be assigned to variables and referenced later.
This document provides an overview of the Python programming language. It discusses what Python is, its key features, who uses it, common applications, and how to download and install Python. It then covers Python syntax concepts like identifiers, keywords, multiline statements, docstrings, indentation, comments, and string formatting. The document also introduces Python data types like numbers, strings, lists, tuples, dictionaries, sets and how to work with them. It describes how to convert between number types and access/update strings and lists. Finally, it discusses Python development environments like Anaconda and Spyder.
The basics of Python are rather straightforward. In a few minutes you can learn most of the syntax. There are some gotchas along the way that might appear tricky. This talk is meant to bring programmers up to speed with Python. They should be able to read and write Python.
The Agenda for the Webinar:
1. Introduction to Python.
2. Python and Big Data.
3. Python and Data Science.
4. Key features of Python and their usage in Business Analytics.
5. Business Analytics with Python – Real world Use Cases.
Python is a general purpose programming language that can be used for both programming and scripting. It was created in the 1990s by Guido van Rossum who named it after the Monty Python comedy troupe. People use Python for a variety of tasks due to its readability, object-oriented capabilities, extensive libraries, and ability to integrate with other languages. To run Python code, it must first be compiled into bytecode which is then interpreted by the Python virtual machine.
Python 101: Python for Absolute Beginners (PyTexas 2014)Paige Bailey
If you're absolutely new to Python, and to programming in general, this is the place to start!
Here's the breakdown: by the end of this workshop, you'll have Python downloaded onto your personal machine; have a general idea of what Python can help you do; be pointed in the direction of some excellent practice materials; and have a basic understanding of the syntax of the language.
Please don't forget to bring your laptop!
Audience: "Python 101" is geared toward individuals who are new to programming. If you've had some programming experience (shell scripting, MATLAB, Ruby, etc.), then you'll probably want to check out the more intermediate workshop, "Python 101++".
This is an introductory presentation to SSL and the basics of secure communication over the web. It walks over the concepts of how SSL works and the various methods for implementing a safe communication channel. It explains the mechanisms of web negotiation, before starting any web transaction between remote hosts.
introduction to Python by Mohamed Hegazy , in this slides you will find some code samples , these slides first presented in TensorFlow Dev Summit 2017 Extended by GDG Helwan
Have you heard "Python" being thrown around a bit more lately? You weren't mistaken. Python Programming Language, who deems itself as self-governing and slow-moving, has ironically reached celebrity status in countless disciplines. Brian Ray, well known for building the Python community, will give a fair assessment on: who uses Python, where this came from, what all the fuss is about, and what to expect to see next.
A 12 hour workshop on Introduction to PythonSatyaki Sikdar
This document outlines an upcoming two-day workshop on programming in Python taught by Satyaki Sikdar. The workshop will cover Python basics like variables, data types, functions, conditionals, lists, loops, tuples, dictionaries, errors and exceptions, and object-oriented programming concepts like inheritance and classes over the course of its 12 hours. The document provides Satyaki Sikdar's background and expectations for the workshop, as well as intended takeaways for participants to gain fluency in Python code and an understanding of how Python works.
Python was created in the late 1980s by Guido van Rossum and first released in 1991. It gained popularity and saw new releases in 2000 and 2008. Python is an open source, general purpose, interpreted, object-oriented programming language used widely for web development, science, and more due to its large community and support. Performance depends more on frameworks and architecture than language alone.
This document provides an introduction to the Python programming language. It begins with an overview of Python's history and development timeline. It then discusses Python's key features such as being high-level, interpreted, object-oriented, and having extensive libraries. The document outlines Python's main programming paradigms and discusses its growing popularity. It provides details on getting started with Python, different integrated development environments (IDEs), and Python basics like variables, data types, operators, and input/output. The document also covers Python syntax and structures such as control flow, functions, classes, and exceptions handling.
Python is a widely used general purpose programming language that was created in the late 1980s by Guido van Rossum. It emphasizes code readability and has a large standard library. It supports multiple programming paradigms like object oriented, imperative, and functional programming. Compared to other languages, Python programs are typically shorter than equivalent programs in languages like Java due to features like dynamic typing.
This document outlines an introduction to object oriented programming in Python. It discusses Python's support for multiple programming paradigms including procedural, object-oriented, and functional. Python allows programmers to choose the paradigm best suited to the problem. The document then covers Python classes, stating that a class is a Python object that returns a new instance when called. Classes contain attributes that can be descriptors like functions or normal data. Inheritance allows classes to delegate attribute lookup to parent classes.
Python Advanced – Building on the foundationKevlin Henney
This is a two-day course in Python programming aimed at professional programmers. The course material provided here is intended to be used by teachers of the language, but individual learners might find some of this useful as well.
The course assume the students already know Python, to the level taught in the Python Foundation course: http://www.slideshare.net/Kevlin/python-foundation-a-programmers-introduction-to-python-concepts-style)
The course is released under Creative Commons Attribution 4.0. Its primary location (along with the original PowerPoint) is at https://github.com/JonJagger/two-day-courses/tree/master/pa
Introduction about Python by JanBask Training, we are offering Online Pyton Training. You should visit: http://www.janbasktraining.com/python/ for Pyton Training.
This document outlines a Python-Django training course held at HCMUT in summer 2012. It provides details on the instructors, tools used in the training including Notepad++ and command line, and covers 13 parts that make up the content of the course including introductions to Python, Django, HTML/CSS, installation, models, views, templates and deployment. Exercises are provided to help reinforce learning concepts in Python and using HTML, CSS, and JavaScript to create a form.
Python is an interpreted, object-oriented programming language created by Guido van Rossum in 1990. It has a clear, readable syntax and is designed to be highly extensible. Python code is often much shorter than equivalent code in other languages like C++ or Java due to features like indentation-based blocks and dynamic typing. It is used for web development, scientific computing, and more.
This document summarizes Daniel Greenfeld's presentation on Python worst practices and fixed practices. The presentation covers various topics like fundamentals, classes, and presentation styles. For each worst practice, there is a corresponding fixed practice shown side by side. Some examples of worst practices discussed include using single-letter variable names, not using enumerate, and implementing Java-style getters and setters in Python classes. The fixed practices demonstrate more readable Python code that follows PEP 8 style guidelines and leverages Python features like properties.
This document discusses several neurodegenerative disorders including multiple sclerosis, Alzheimer's disease, Huntington's disease, and Parkinson's disease. It provides information on the causes, symptoms, stages, assessments, management, and nursing considerations for each condition. The document is intended to educate about these diseases and how their manifestations can be managed.
This document provides an introduction to object-oriented programming (OOP) concepts. It discusses problem solving using both structured programming and OOP approaches. The key concepts of OOP covered include objects, classes, methods, encapsulation, and inheritance. It also provides examples of defining a Rectangle class with attributes like length and width, and methods to calculate the area and perimeter. The document demonstrates how to create Rectangle objects, call methods on them to get the area, and use them in an application class.
This document provides an overview of the Python programming language. It begins by explaining what Python is, noting that it is a general purpose programming language that is often used for scripting. The key differences between program and scripting languages are then outlined. The history and creation of Python by Guido van Rossum are summarized, along with Python's scope in fields like science, system administration, and web development. Various uses of Python are listed, followed by who commonly uses Python today such as Google and YouTube. Reasons for Python's popularity include being free, powerful, and portable. The document concludes by covering installing Python, running and executing Python code, and some basic Python concepts like strings, variables, data types, and loops/
This document provides an overview of the Python programming language. It begins by explaining what Python is - a general purpose, interpreted programming language that can be used as both a programming and scripting language. It then discusses the differences between programs and scripting languages. The history and creator of Python, Guido van Rossum, are outlined. The document explores the scope of Python and what tasks it can be used for. Popular companies and industries that use Python today are listed. Reasons why people use Python, such as it being free, powerful, and portable, are provided. Instructions for installing Python and running Python code are included. The document covers Python code execution and introduces basic Python concepts like variables, strings, data types, lists
This document provides an introduction and overview of the Python programming language course CSE 120 handled by G.Gandhi Jaba Kumar. It discusses that Python is an interpreted, object-oriented, and interactive programming language used for web development, software development, mathematics, and system scripting. The document then covers Python syntax including indentation, comments, keywords, variables, data types, operators, and basic programming concepts like conditionals and loops. It provides examples to illustrate Python code and best practices.
Python is a general purpose programming language that can be used for web development, system administration, science and more. It is interpreted rather than compiled, and was created in the 1990s by Guido van Rossum to be highly readable. Python is widely used by companies like Google, YouTube, Intel and more due to its power, flexibility and readability. It supports key programming concepts like variables, conditionals, loops, lists, tuples and more.
The document provides instructions for downloading and installing Python and PyCharm on Mac and Windows systems. It outlines the steps to download each program from their respective websites, then guides the user through installing Python and PyCharm on their device by navigating folders and clicking through installation windows. It also briefly introduces some basic programming concepts that will be covered in an upcoming Python tutorial, such as variables, data types, conditional statements, and loops.
This document provides an outline and overview of a presentation on learning Python for beginners. The presentation covers what Python is, why it is useful, how to install it and common editors used. It then discusses Python variables, data types, operators, strings, lists, tuples, dictionaries, conditional statements, looping statements and real-world applications. Examples are provided throughout to demonstrate key Python concepts and how to implement various features like functions, methods and control flow. The goal is to give attendees an introduction to the Python language syntax and capabilities.
The document provides an introduction to Python programming and application development. It discusses that Python is an interpreted, high-level and object-oriented programming language. It then covers key Python concepts like data types, variables, operators, expressions and statements. The document also lists some common Python applications like data science, web development, AI and more.
This document provides instructions on how to install Python, Sublime Text, and set up a development environment on Windows and Mac operating systems. It discusses downloading and running Python from its official website, downloading and opening Sublime Text, creating and running a simple Python file within Sublime Text, and using common Python syntax and concepts like variables, functions, conditionals and loops. The document also covers working with files, regular expressions, exceptions, and installing PyMySQL to connect to a MySQL database.
This document provides an introduction to Python programming basics for beginners. It discusses Python features like being easy to learn and cross-platform. It covers basic Python concepts like variables, data types, operators, conditional statements, loops, functions, OOPs, strings and built-in data structures like lists, tuples, and dictionaries. The document provides examples of using these concepts and recommends Python tutorials, third-party libraries, and gives homework assignments on using functions like range and generators.
Python is an interpreted, object-oriented, high-level programming language with dynamic typing and dynamic binding. Its simple, easy to learn syntax emphasizes readability and it uses significant indentation to delimit code blocks rather than curly braces or keywords. Python supports modules and packages, which encourages program modularity and code reuse. It also has a large standard library.
Introduction To Programming with PythonSushant Mane
The document provides an introduction to the Python programming language. It discusses Python's core features like being an interpreted, object-oriented, and dynamic language. It covers basic Python concepts like data types, variables, operators, control flow, functions, modules, file handling, and object-oriented programming. The document contains examples and explanations of built-in types like numbers, strings, lists, tuples, and dictionaries. It also discusses control structures, functions, modules, and classes in Python.
Python is a general purpose programming language that can be used for both programming and scripting. It was created in the 1990s by Guido van Rossum. Python is an interpreted language that is free, powerful, and portable. It can be used for tasks like web development, data analysis, and system scripting. The document provides an overview of Python including its history, uses, data types like strings and lists, and basic programming concepts like variables, conditionals, and loops. It recommends Python as a principal teaching language due to its free and easy installation, flexibility, use in academia and industry, and ability to offer a more rapid and enjoyable learning experience for students.
This document provides an overview of the Python programming language. It discusses Python's history, versions, paradigms, data types, control flow statements, functions, classes, and applications. Key points include that Python was created in the late 1980s and influenced by other languages, it supports multiple programming paradigms like object-oriented and functional programming, and it is widely used for web development, science, and data analysis.
Mastering AI Workflows with FME - Peak of Data & AI 2025Safe Software
Harness the full potential of AI with FME: From creating high-quality training data to optimizing models and utilizing results, FME supports every step of your AI workflow. Seamlessly integrate a wide range of models, including those for data enhancement, forecasting, image and object recognition, and large language models. Customize AI models to meet your exact needs with FME’s powerful tools for training, optimization, and seamless integration
Discover 7 best practices for Salesforce Data Cloud to clean, integrate, secure, and scale data for smarter decisions and improved customer experiences.
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....Jasper Oosterveld
Sensitivity labels, powered by Microsoft Purview Information Protection, serve as the foundation for classifying and protecting your sensitive data within Microsoft 365. Their importance extends beyond classification and play a crucial role in enforcing governance policies across your Microsoft 365 environment. Join me, a Data Security Consultant and Microsoft MVP, as I share practical tips and tricks to get the full potential of sensitivity labels. I discuss sensitive information types, automatic labeling, and seamless integration with Data Loss Prevention, Teams Premium, and Microsoft 365 Copilot.
FME Beyond Data Processing Creating A Dartboard Accuracy AppSafe Software
At Nordend, we want to push the boundaries of FME and explore its potential for more creative applications. In our office, we have a dartboard, and while improving our dart-throwing skills was an option, we took a different approach: What if we could use FME to calculate where we should aim to achieve the highest possible score, based on our accuracy? Using FME’s Geometry User parameter, we designed a custom solution. When launching the FME Flow app, the map is now a dartboard. The centre of the map is always fixed on the same area of the world, where we pinned a PNG picture of a dartboard as a basemap through a self-created WMS. This visual setup allowed us to draw polygons—each with three points—where our darts landed, using the Geometry parameter. These polygons get processed through an FME workspace, which translates the coordinates from the map into exact X and Y positions on the dartboard. With this accurate data, we calculate all sorts of statistics: rolling averages, best scores, and even standard deviations. The results get displayed on a dashboard in FME Flow, giving us insights into how we could maximize our scores, based purely on where we actually tend to throw. Join us for a live demonstration of the app! The takeaway? FME isn’t just a powerful data processing tool; with a bit of imagination, it can be used for far more creative and unconventional applications. This project demonstrates that the only limit to what FME can do is the creativity you bring to it.
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfRejig Digital
Unlock the future of oil & gas safety with advanced environmental detection technologies that transform hazard monitoring and risk management. This presentation explores cutting-edge innovations that enhance workplace safety, protect critical assets, and ensure regulatory compliance in high-risk environments.
🔍 What You’ll Learn:
✅ How advanced sensors detect environmental threats in real-time for proactive hazard prevention
🔧 Integration of IoT and AI to enable rapid response and minimize incident impact
📡 Enhancing workforce protection through continuous monitoring and data-driven safety protocols
💡 Case studies highlighting successful deployment of environmental detection systems in oil & gas operations
Ideal for safety managers, operations leaders, and technology innovators in the oil & gas industry, this presentation offers practical insights and strategies to revolutionize safety standards and boost operational resilience.
👉 Learn more: https://www.rejigdigital.com/blog/continuous-monitoring-prevent-blowouts-well-control-issues/
Presentation given at the LangChain community meetup London
https://lu.ma/9d5fntgj
Coveres
Agentic AI: Beyond the Buzz
Introduction to AI Agent and Agentic AI
Agent Use case and stats
Introduction to LangGraph
Build agent with LangGraph Studio V2
Bridging the divide: A conversation on tariffs today in the book industry - T...BookNet Canada
A collaboration-focused conversation on the recently imposed US and Canadian tariffs where speakers shared insights into the current legislative landscape, ongoing advocacy efforts, and recommended next steps. This event was presented in partnership with the Book Industry Study Group.
Link to accompanying resource: https://bnctechforum.ca/sessions/bridging-the-divide-a-conversation-on-tariffs-today-in-the-book-industry/
Presented by BookNet Canada and the Book Industry Study Group on May 29, 2025 with support from the Department of Canadian Heritage.
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Anish Kumar
Presented by: Anish Kumar
LinkedIn: https://www.linkedin.com/in/anishkumar/
This lightning talk dives into real-world GenAI projects that scaled from prototype to production using Databricks’ fully managed tools. Facing cost and time constraints, we leveraged four key Databricks features—Workflows, Model Serving, Serverless Compute, and Notebooks—to build an AI inference pipeline processing millions of documents (text and audiobooks).
This approach enables rapid experimentation, easy tuning of GenAI prompts and compute settings, seamless data iteration and efficient quality testing—allowing Data Scientists and Engineers to collaborate effectively. Learn how to design modular, parameterized notebooks that run concurrently, manage dependencies and accelerate AI-driven insights.
Whether you're optimizing AI inference, automating complex data workflows or architecting next-gen serverless AI systems, this session delivers actionable strategies to maximize performance while keeping costs low.
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc
How does your privacy program compare to your peers? What challenges are privacy teams tackling and prioritizing in 2025?
In the sixth annual Global Privacy Benchmarks Survey, we asked global privacy professionals and business executives to share their perspectives on privacy inside and outside their organizations. The annual report provides a 360-degree view of various industries' priorities, attitudes, and trends. See how organizational priorities and strategic approaches to data security and privacy are evolving around the globe.
This webinar features an expert panel discussion and data-driven insights to help you navigate the shifting privacy landscape. Whether you are a privacy officer, legal professional, compliance specialist, or security expert, this session will provide actionable takeaways to strengthen your privacy strategy.
This webinar will review:
- The emerging trends in data protection, compliance, and risk
- The top challenges for privacy leaders, practitioners, and organizations in 2025
- The impact of evolving regulations and the crossroads with new technology, like AI
Predictions for the future of privacy in 2025 and beyond
In this talk, Elliott explores how developers can embrace AI not as a threat, but as a collaborative partner.
We’ll examine the shift from routine coding to creative leadership, highlighting the new developer superpowers of vision, integration, and innovation.
We'll touch on security, legacy code, and the future of democratized development.
Whether you're AI-curious or already a prompt engineering, this session will help you find your rhythm in the new dance of modern development.
Jeremy Millul - A Talented Software DeveloperJeremy Millul
Jeremy Millul is a talented software developer based in NYC, known for leading impactful projects such as a Community Engagement Platform and a Hiking Trail Finder. Using React, MongoDB, and geolocation tools, Jeremy delivers intuitive applications that foster engagement and usability. A graduate of NYU’s Computer Science program, he brings creativity and technical expertise to every project, ensuring seamless user experiences and meaningful results in software development.
If You Use Databricks, You Definitely Need FMESafe Software
DataBricks makes it easy to use Apache Spark. It provides a platform with the potential to analyze and process huge volumes of data. Sounds awesome. The sales brochure reads as if it is a can-do-all data integration platform. Does it replace our beloved FME platform or does it provide opportunities for FME to shine? Challenge accepted
DevOps in the Modern Era - Thoughtfully Critical PodcastChris Wahl
https://youtu.be/735hP_01WV0
My journey through the world of DevOps! From the early days of breaking down silos between developers and operations to the current complexities of cloud-native environments. I'll talk about my personal experiences, the challenges we faced, and how the role of a DevOps engineer has evolved.
מכונות CNC קידוח אנכיות הן הבחירה הנכונה והטובה ביותר לקידוח ארונות וארגזים לייצור רהיטים. החלק נוסע לאורך ציר ה-x באמצעות ציר דיגיטלי מדויק, ותפוס ע"י צבת מכנית, כך שאין צורך לבצע setup (התאמות) לגדלים שונים של חלקים.
Improving Developer Productivity With DORA, SPACE, and DevExJustin Reock
Ready to measure and improve developer productivity in your organization?
Join Justin Reock, Deputy CTO at DX, for an interactive session where you'll learn actionable strategies to measure and increase engineering performance.
Leave this session equipped with a comprehensive understanding of developer productivity and a roadmap to create a high-performing engineering team in your company.
3. 3
Introduction
Python is a clear and powerful object-oriented programming language.
Uses an elegant syntax, making the programs you write easier to read.
Comes with a large standard library that supports many common programming
tasks.
Python's interactive mode makes it easy to test short snippets of code.
Runs on many different computers and operating systems: Windows, MacOS,
many brands of Unix, OS/2.
Is free software in two senses. It doesn't cost anything to download or use
Python, or to include it in your application. Python can also be freely modified
and re-distributed.
5. 5
A Code Sample
x = 34 – 23 # A comment
y = “Hello” # Another one.
z = 3.45
if z == 3.45 or y == “Hello”:
x = x + 1
y = y + “ World” # String concat.
print x
print y
6. 6
Enough to Understand the Code
Assignment uses = and comparison uses ==.
For numbers + - * / % are as expected.
Special use of + for string concatenation.
Special use of % for string formatting (as with printf in C)
Logical operators are words (and, or, not) not symbols
The basic printing command is “print”
The first assignment to a variable creates it.
Variables types don’t need to be declared.
Python figures out the variables types on its own.
7. 7
Whitespace
Whitespace is meaningful in Python: especially indentation and placement of
newlines.
Use a newline to end a line of code.
Use ‘’ when must go to next line prematurely
No braces { } to mark blocks of code in Python…
Use consistent indentation instead.
The first line with less indentation is outside of the block
The first line with more indentation starts a nested block.
Often a colon appears at the start of a new block. (Eg. For function and class
definitions.)
8. 8
Comments
Start comments with # - the rest of line is ignored.
Can include a “documentation string” as the first line of any new function or
class that you define.
The development environment, debugger, and other tools use it: it’s good
style to include one.
def my_function(x, y):
“””This is the docstring. This
function does …..”””
# The code would go here…
9. 9
Assignment Statements
Binding a variable in Python means setting a name to hold a reference to
some object.
Assignment creates references, not copies.
Names in Python do not have an intrinsic type. Objects have types.
A reference is deleted via garbage collection after any names bound to it have
passed out of scope.
10. 10
Multiple Assignment
One can also assign to multiple names at the same time.
>>> x, y = 2, 3
>>> x
2
>>> y
3
11. 11
Naming Rules
Names are case sensitive and cannot start with a number. They can contain
letters, numbers, and underscores.
Bob bob _bob _2_bob_ bob_2 BoB
There are some reserved words. Those words cannot be used to label
identifiers in a Python program.
12. 12
Variables in Python
A variable stores a piece of data, and gives it a specific name.
Python is a dynamically typed language.
Variables need not be declared in Python before using them.
Variables can be used on the fly and Python infers its type based on the value
stored by the variable.
Example: Set the variable “age” equal to the value 20.
>>> age = 20
Now “age” can be used in any arithmetic operations, such as,
>>> age_after_10 = age + 10 # 30
13. 13
Basic Data Types
Python supports the usual data types, such as,
Integers
Floats
Strings
If both operands are of type int, floor division is performed and an int is
returned.
If either operand is a float, classic division is performed and a float is
returned.
In addition to int and float, Python supports other types of numbers, such as
Decimal, Fraction and Complex numbers.
14. 14
Fun with Python Arithmetic
>>> 17 / 3 # int / int -> int
5
>>> 17 / 3.0 # int / float -> float
5.666666666666667
>>> 17 % 3 # the % operator returns the remainder
2
>>> 5 ** 2 # 5 squared
25
15. 15
Python Strings
Besides numbers, Python can also manipulate strings, which can be expressed
in several ways.
Strings can be enclosed in single quotes ('...') or double quotes ("…").
The string is enclosed in double quotes if the string contains a single quote and
no double quotes, otherwise it is enclosed in single quotes.
String literals can span multiple lines. One way is using triple-quotes:
"""...""" or '''...'''.
Strings can be concatenated (glued together) with the + operator, and repeated
with *.
>>> 3 * ‘un’ + ‘ium’
‘unununium’
16. 16
String Examples
>>> 'doesn't' # use ' to escape the single quote...
"doesn't"
>>> "doesn't" # ...or use double quotes instead
"doesn't"
>>> '"Isn't," she said.'
'"Isn't," she said.'
>>> print '"Isn't," she said.'
"Isn't," she said.
17. 17
Strings Continued…
Strings can be indexed (subscripted), with the first character having index 0.
There is no separate character type; a character is simply a string of size one.
Indices may also be negative numbers, while counting from the right.
Say, word = ‘Python’
>>> word[-1] # last character
‘n’
>>> word[-2] # second last character
‘o’
18. 18
Strings Continued…
In addition to indexing, slicing is also supported. While indexing is used to
obtain individual characters, slicing allows you to obtain a substring.
In slicing, the start is always included, and the end always excluded. This
makes sure that s[:i] + s[i:] is always equal to s.
20. 20
Python Decision Structures
Decision making is anticipation of conditions occurring while execution of the
program and specifying actions taken to the conditions.
Decision structures evaluate multiple expressions which produce TRUE or
FALSE as outcome.
Python programming language assumes any non-zero and non-null values as
TRUE, and if it is either zero or null, then it is assumed as FALSE value.
If the suite of an if clause consists of a single line, it may go on the same line as
the header statement.
23. 23
Loop Statements
Programming languages provide various control structures that allow for more
complicated execution paths.
A loop statement allows us to execute a statement or group of statements
multiple times.
Python provides the following looping constructs:
While loop
For loop
Loop Control Statements change execution from its normal sequence. When
execution leaves a scope, all automatic objects that were created in that scope
are destroyed.
Eg:. Break, continue, pass.
24. 24
While Loop
A while loop statement in Python, repeatedly executes a target statement as
long as a given condition is true.
Syntax:
while expression:
statement(s)
Eg: #!/usr/bin/python
count = 0
while count < 9:
print “The count is:”, count
count = count + 1
25. 25
For loop
It has the ability to iterate over the items of any sequence, such as list or a
string.
Syntax:
for iterating_var in sequence:
statement(s)
If a sequence contains an expression list, it is evaluated first. Then, the first
item in the sequence is assigned to the iterating varaiable iterating_var.
Each item in the sequence is iterated over, until the entire sequence is
exhausted.
26. 26
For loop in action…
● Eg:.
#!usr/bin/python
for letter in ‘Python’: # First Example
print ‘Current letter:’, letter
Fruits = [‘banana’, ‘apple’, ‘mango’]
for fruit in fruits: # Second Example
print “Current Fruit:”, fruit
27. 27
Iterating by sequence index
An alternative way of iterating through each item is by index offset into the
sequence itself.
Eg:.
fruits = [“banana”, “apple”, “mango”]
for index in range(len(fruits)):
print “Current fruit:”, fruits[index]
In the above example, we took assistance of the len() built-in function, which
provides the total number of elements in the tuple as well as the range() built-in
function to give us the actual sequence to iterate over.
28. 28
Using else statements with Loops
Python supports to have an else statement associated with a loop
If the else statement is used with a for loop, the else statement is executed
when the loop has exhausted the sequence.
If the else statement is used with a while loop, the else statement is executed
when the condition becomes false.
29. 29
Else with loops Example
● The following example illustrates the combination of an else statement with
statement that searches for prime numbers from 10 through 20.
for num in range(10, 20): # to iterate between 10 to 20
for i in range(2, num): # to iterate on the factors of the number
if num % i == 0: # To determine the first factor
j = num / i # To calculate the second factor
print ‘%d equals %d * %d’ % (num, i, j)
break
else:
print num, ‘is a prime number’
31. 31
Sequence Types
Tuple
A simple immutable ordered sequence of items
Items can be of mixed types, including collection types
Strings
Immutable
Conceptually very much like a tuple
List
Mutable ordered sequence of items of mixed types.
32. 32
Similar Syntax
All three sequence types (tuples, strings, and lists) share much of the same
syntax and functionality.
Key Difference:
Tuples and strings are immutable
Lists are mutable
The operations shown in this section can be applied to all sequence types
Most examples will just show the operation performed on one.
33. 33
Sequence Types 1
Tuples are defined using parentheses (and commas).
>>> tu = (23, ‘abc’, 4.56, (2,3), ‘def’)
Lists are defined using square brackets (and commas).
>>> li = [“abc”, 34, 4.34, 23]
Strings are defined using quotes (“, ‘, or “””).
>>> st = “Hello World”
>>> st = ‘Hello World’
>>>st = “””This is a multi-line string that
uses triple quotes.”””
34. 34
Sequence Types 2
We can access individual members of a tuple, list, or string using square
bracket “array” notation.
Note that all are 0 based…
>>> tu[1] # Second item in the tuple.
‘abc’
>>> li[1] # Second item in the list.
34
>>> st[1] # Second character in string.
‘e’
35. 35
Positive and Negative Indices
>>> t = (23, ‘abc’, 4.56, 2,3), ‘def’)
Positive index: count from left, starting with 0.
>>> t[1]
‘abc’
Negative lookup: count from right, starting with -1.
>>> t[-3]
4.56
36. 36
Slicing: Return Copy of a Subset 1
>>> t = (23, ‘abc’, 4.56, (2,3), ‘def’)
Return a copy of the container with a subset of the original members. Start
copying at the first index, and stop copying before the second index.
>>> t[1:4]
(‘abc’, 4.56, (2,3))
You can also use negative indices when slicing.
>>> t[1:-1]
(‘abc’, 4.56, (2,3))
37. 37
Slicing: Return Copy of a Subset 2
>>> t = (23, ‘abc’, 4.56, (2,3), ‘def’)
Omit the first index to make a copy starting from the beginning of the
container.
>>> t[:2]
(23, ‘abc’)
Omit the second index to make a copy starting at the first index and going to
the end of the container.
>>> t[2:]
(4.56, (2,3), ‘def’)
38. 38
Copying the Whole Sequence
To make a copy of an entire sequence, you can use [:].
>>> t[:]
(23, ‘abc’, 4.56, (2,3), ‘def’)
Note the difference between these two lines for mutable sequences:
>>> list2 = list1 # 2 names refer to 1 ref
# Changing one affects both
>>> list2 = list1[:] # Two independent copies, two refs
39. 39
The ‘in’ Operator
Boolean test whether a value is inside a container:
>>> t = [1, 2, 3, 4, 5]
>>> 3 in t
False
>>> 4 in t
True
>>> 4 not in t
False
40. 40
‘in’ Operator Continued…
For strings, tests for substrings
>>> a = ‘abcde’
>>> ‘c’ in a
True
>>> ‘cd’ in a
True
>>> ‘ac’ in a
False
Be careful: the in keyword is also used in the syntax of for loops and list
comprehensions.
41. 41
The + Operator
The + operator produces a new tuple, list, or string whose value is the
concatenation of its arguments.
>>> (1, 2, 3) + (4, 5, 6)
(1, 2, 3, 4, 5, 6)
>>> [1, 2, 3] + [4, 5, 6]
[1, 2, 3, 4, 5, 6]
>>> “Hello” + “ “ + “World”
‘Hello World’
42. 42
The * Operator
The * operator produces a new tuple, list, or string that “repeats” the
original content.
>>> (1, 2, 3) * 3
(1, 2, 3, 1, 2, 3, 1, 2, 3)
>>> [1, 2, 3] * 3
[1, 2, 3, 1, 2, 3, 1, 2, 3]
>>> “Hello” * 3
‘HelloHelloHello’
44. 44
Tuples: Immutable
>>> t = (23, ‘abc’, 4.56, (2,3), ‘def)
>>> t[2] = 3.14
You can’t change a tuple.
You can make a fresh tuple and assign its reference to a previously used
name.
>>> t = (23, ‘abc’, 3.14, (2,3), ‘def’)
45. 45
Lists: Mutable
>>> li = [‘abc’, 23, 4.34, 23]
>>> li[1] = 45
>>> li
[‘abc’, 45, 4.34, 23]
We can change lists in place.
Name li still points to the same memory reference when we’re done.
The mutability of lists means that they aren’t as fast as tuples.
46. 46
Operations on lists Only 1
>>> li = [1, 11, 3, 4, 5]
>>> li.append(‘a’) # Our first exposure to method syntax
>>> li
[1, 11, 3, 4, 5, ‘a’]
>>> li.insert(2, ‘i’)
>>> li
[1, 11, ‘i’, 3, 4, 5, ‘a’]
47. 47
The extend method vs the + operator
‘+’ creates a fresh list (with a new memory reference)
Extend operates on list li in place.
>>> li.extend([9, 8, 7])
>>> li
[1, 2, ‘i’, 3, 4, 5, ‘a’, 9, 8, 7]
Confusing:
• Extend takes a list as an argument.
• Append takes a singleton as an argument.
>>> li.append([10, 11, 12])
48. 48
Operations on Lists Only 3
>>> li = [‘a’, ‘b’, ‘c’, ‘b’]
>>> li.index(‘b’) # index of first occurrence
1
>>> li.count(‘b’) # number of occurences
2
>>> li.remove(‘b’) # remove first occurrence
>>> li
[‘a’, ‘c’, ‘b’]
49. 49
Operations on Lists Only 4
>>> li = [5, 2, 6, 8]
>>> li.reverse() # reverse the list *in place*
>>> li
[8, 6, 2, 5]
>>> li.sort() # sort the list *in place*
>>> li
[2, 5, 6, 8]
>>> li.sort(some_function)
# sort in place using user-defined comparison
50. 50
Tuples vs. Lists
Lists slower but more powerful than tuples.
Lists can be modified, and they have lots of handy operations we can perform
on them.
Tuples are immutable and have fewer features.
To convert between tuples and lists use the list() and tuple() functions:
>>> li = list(tu)
>>> tu = tuple(li)
51. 51
Python Dictionary
Each key is separated from its value by a colon ( : ), the items are separated by
commas, and the whole thing is enclosed in curly braces.
An empty dictionary without any items is written with just two curly braces,
like this { }.
Keys are unique within a dictionary while values my not be.
The values can be of any type, but the keys must be of an immutable data type
such as strings, numbers, or tuples.
52. 52
Accessing Values in a Dictionary
To access dictionary elements, we can use the familiar square brackets along
with the key to obtain its value.
Eg:. dict = {‘Name’: ‘Zara’, ‘Age’: 7, ‘Class’: ‘First’}
print dict[‘Name’]
print dict[‘Age’]
If we attempt to access a data item with a key, which is not part of the
dictionary, we will get an error.
53. 53
Updating Dictionary
We can update a dictionary by adding a new entry or key-value pair,
modifying an existing entry, or deleting an existing entry.
Eg:.
dict = {‘Name’: ‘Zara’, ‘Age’: 7, ‘Class’: ‘First’}
dict[‘Age’] = 8 # Update existing entry
dict[‘School’] = “DPS School” # Add new entry
54. 54
Delete Dictionary Elements
We can either remove individual dictionary elements or clear the entire
contents of a dictionary.
We can also delete the entire dictionary in a single operation.
To explicitly remove an entire dictionary, just use the del statement.
dict = {‘Name’: ‘Zara’, ‘Age’: 7, ‘Class’: ‘First’}
del dict[‘Name’] # Delete an element
dict.clear() # Clear the contents of the dictionary
del dict # Remove the entire dictionary structure.
56. 56
Function as a Concept
A function is a block of organized, reusable code that is used to perform a
single, related action.
Functions provide better modularity for an application and a high degree of
code reusing.
Python gives us may built-in functions like print(), etc.
We can also create our own functions. These are called user-defined functions.
57. 57
Defining a Function
Function blocks begin with the keyword def followed by the function
name and parentheses.
Any input parameters or arguments should be placed within these
parentheses. We can also define parameters inside these parentheses.
The first statement of a function can be an optional statement – the
documentation string of the function or docstring.
The code block within every function starts with a colon ( : ) and is
indented.
The statement return [expression] exits a function, optionally passing
back an expression to the caller. A return statement with no arguments
is the same as return None.
58. 58
Function Structure
def function_name ( parameters ):
“function_docstring”
function_suite
return [expression]
Eg:.
def printme (str):
“This prints a passed string into this function”
print str
return
59. 59
Function Arguments
Required arguments are the arguments passed to a function in correct
positional order. Here, the number of arguments in the function call should
match exactly with the function definition.
Keyword arguments are related to the function calls. When we use keyword
arguments in a function call, the caller identifies the arguments by the
parameter name.
Default arguments are arguments that assume a default value if a value is not
provided in the function call for that argument.
When we may need to process a function for more arguments than we specified
while defining the function, we use variable-length arguments. They are also
known as splat-arguments
61. 61
Python File Manipulation
Python provides basic functions and methods necessary to manipulate files by
default.
Most of the file manipulation is done using a file object.
The various file handling methods supported are:
open()
close()
write()
read()
tell()
62. 62
The open() Function
Before we can read or write to a file, we have to open it.
This function creates a file object, which would be utilized to call other support
methods associated with it.
Syntax:
file_object = open(file_name [, access_mode][, buffering])
The commonly used access modes are ‘r’, ‘rb’, ‘r+’, ‘rb+’, ‘w’, ‘wb’, ‘w+’,
‘wb+’ and ‘a’.
Eg:.
fo = open(“foo.txt”, “wb”)
63. 63
The close() Method
The close() method of a file object flushes any unwritten information and
closes the file object, after which no more I/O can be done.
Python automatically closes a file when the reference object of a file is
reassigned to another file.
Syntax:
file_object.close()
64. 64
The write() Method
The write() method writes any string to an open file. It is important to note that
Python strings can have binary data and not just text.
The write() method does not add a newline character(‘n’) to the end of the
string.
Syntax:
File_object.write(string)
65. 65
The read() Method
The read() method reads a string from an open file.
Syntax:
file_object.read ( [count] )
Here, the passed parameter is the number of bytes to be read from the opened
file.
This method starts reading from the beginning of the file and if count is
missing, then it tries to read as much as possible, maybe until the end of file.
66. 66
An Example…
fo = open(“foo.txt”, “r+”) # Open a file
str = fo.read(10)
print “Read string is: “, str
position = fo.tell() # Check current position
print “Current file position: “, position
position = fo.seek(0,0) # Reposition pointer to the beginning
str = fo.read(10)
print “Again read string is: “, str
fo.close()
67. 67
Renaming and Deleting Files
Python os module provides methods that helps us perform file-processing
operations, such as renaming and deleting files.
To use this module, we need to import it first and then only we can call any
related functions.
Rename Method – os.rename (curr_file_name, new_file_name)
Remove Method – os.remove (file_name)
In order to import a module, we just type: import module_name
68. 68
Directory Manipulation in Python
The os module has several methods that help us create, remove and change
directories.
Some of the commonly used methods are:
mkdir() - os.mkdir(“dir_name”)
chdir() - os.chdir(“new_dir)
getcwd() – os.getcwd()
rmdir() – os.rmdir(‘dir_name’)