This document provides an introduction and overview of the Python programming language. It describes Python as a general-purpose, object-oriented programming language with features like high-level programming capabilities, an easily understandable syntax, portability, and being easy to learn. It then discusses Python's characteristics like being an interpreted language, supporting object-oriented programming, being interactive and easy to use, having straightforward syntax, being portable, extendable, and scalable. The document also outlines some common uses of Python like for creating web and desktop applications, and provides examples of using Python's interactive and script modes.
- Python is an interpreted, object-oriented programming language that is beginner friendly and open source. It was created in the 1990s and named after Monty Python.
- Python is very suitable for natural language processing tasks due to its built-in string and list datatypes as well as libraries like NLTK. It also has strong numeric processing capabilities useful for machine learning.
- Python code is organized using functions, classes, modules, and packages to improve structure. It is interpreted at runtime rather than requiring a separate compilation step.
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.
The document provides an overview of the Python programming language. It discusses why Python is useful for students and professionals, its major features like being object-oriented and having a large standard library. The document also covers Python's history, how to install it and set the environment variables, basic syntax like variables and data types, operators, and common programming constructs like conditionals and loops.
Python is an interpreted, general-purpose, high-level programming language. It allows programmers to define functions for reusing code and scoping variables within functions. Key concepts covered include objects, expressions, conditionals, loops, modules, files, and recursion. Functions can call other functions, allowing for modular and reusable code.
The document provides an overview of the Python programming language. It discusses what Python is, its history and naming, features like being dynamically typed and interpreted, popular applications like web development, machine learning, and its architecture. It also covers Python constructs like variables, data types, operators, and strings. The document compares Python to other languages and provides examples of common Python concepts.
The document discusses Python variables and operators. It covers:
1) Different ways to write Python programs interactively or as scripts. Variables can be created and assigned values in Python.
2) Various Python data types including numbers, strings, Booleans, and different operators like arithmetic, relational, logical and assignment operators.
3) Input and output functions like print() and input() allow user interaction and display of results. Comments, identifiers, keywords, tokens and literals are also explained.
- Python is an interpreted, object-oriented programming language that is beginner friendly and open source. It was created in the 1990s and named after Monty Python.
- Python is very suitable for natural language processing tasks due to its built-in string and list datatypes as well as libraries like NLTK. It also has strong numeric processing capabilities useful for machine learning.
- Python code is organized using functions, classes, modules, and packages to improve structure. It is interpreted at runtime rather than requiring a separate compilation step.
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.
The document provides an overview of the Python programming language. It discusses why Python is useful for students and professionals, its major features like being object-oriented and having a large standard library. The document also covers Python's history, how to install it and set the environment variables, basic syntax like variables and data types, operators, and common programming constructs like conditionals and loops.
Python is an interpreted, general-purpose, high-level programming language. It allows programmers to define functions for reusing code and scoping variables within functions. Key concepts covered include objects, expressions, conditionals, loops, modules, files, and recursion. Functions can call other functions, allowing for modular and reusable code.
The document provides an overview of the Python programming language. It discusses what Python is, its history and naming, features like being dynamically typed and interpreted, popular applications like web development, machine learning, and its architecture. It also covers Python constructs like variables, data types, operators, and strings. The document compares Python to other languages and provides examples of common Python concepts.
The document discusses Python variables and operators. It covers:
1) Different ways to write Python programs interactively or as scripts. Variables can be created and assigned values in Python.
2) Various Python data types including numbers, strings, Booleans, and different operators like arithmetic, relational, logical and assignment operators.
3) Input and output functions like print() and input() allow user interaction and display of results. Comments, identifiers, keywords, tokens and literals are also explained.
The document discusses Python programming language. It provides an overview of what Python is, what it can be used for, and why it is a popular language. Specifically, it notes that Python was created by Guido van Rossum and released in 1991. It is used for web development, software development, mathematics, and system scripting. The document then covers Python syntax, basic data types, operators, decision making and control flow statements like if/else and loops.
Gurukul Skills Schedule for the Month of March
Time Cohort-10 Cohort-11 Cohort-12
8.00 to 09.25 Revision Revision Revision
5 Minutes Short Break
9.30 to 11.30 Chartered Accountants Chartered Accountants ENGLISH/SOFT SKILLS
15 Minutes Short Break
11.45 to 01.45 ICT ENGLISH/SOFT SKILLS R&A
45 Minutues Lunch Break
2.30 to 04.30 ENGLISH/SOFT SKILLS R&A ICT
15 Minutes Short Break
4.45 to 06.30 R&A ICT ACCOUNTS
5 Minutes Short Break
6.35 to 08.00 Assingments Assingments Assingments
Basic concept of Python.pptx includes design tool, identifier, variables.supriyasarkar38
This document discusses Python programming concepts including data types, variables, operators, and functions. It provides examples of Python syntax for writing and executing code as well as built-in data types like strings, integers, and lists. Key concepts covered include variables, data type casting, comments, arithmetic and comparison operators, and functions.
Python (Data Analysis) cleaning and visualizeIruolagbePius
This document provides an overview of Python programming language. It discusses Python features, uses, variables, data types, operators, decision making statements, and loops. Specifically, it covers:
- Python features like being easy to learn and read, having an interactive mode, and being portable.
- Python variables, naming rules, and basic data types like numbers, strings, booleans.
- Operators for arithmetic, comparison, assignment, and logic.
- Conditional statements like if, elif, else for decision making.
- Looping structures like while and for loops, with examples of using break, continue, else, range().
- How to write comments, take user input, and
This document discusses variables, data types, expressions, and functions in Python. It defines a variable as a name that represents a stored value in memory. It describes different data types in Python including integers, floats, strings, Booleans, and others. It also discusses expressions, which represent computations that evaluate to a value, and different expression types like arithmetic, relational, logical, and compound expressions. Finally, it introduces functions as blocks of code that perform tasks and can return values.
This document discusses programming languages, compilers vs interpreters, and introduces Python. It explains that a programming language communicates instructions to a machine and can be used to create programs. An interpreter reads and executes code directly, while a compiler converts source code into machine code. Python is an interpreted, object-oriented language that is easy to learn yet powerful. It can be used for web, enterprise, and other applications. The document also provides basic information on Python syntax and data types.
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...DRVaibhavmeshram1
Python
Language
is uesd in engineeringStory adapted from Stephen Covey (2004) “The Seven Habits of Highly Effective People” Simon & Schuster).
“Management is doing things right, leadership is doing the right things”
(Warren Bennis and Peter Drucker)
Story adapted from Stephen Covey (2004) “The Seven Habits of Highly Effective People” Simon & Schuster).
“Management is doing things right, leadership is doing the right things”
(Warren Bennis and Peter Drucker)
Story adapted from Stephen Covey (2004) “The Seven Habits of Highly Effective People” Simon & Schuster).
“Management is doing things right, leadership is doing the right things”
(Warren Bennis and Peter Drucker)
The Sponsor:
Champion and advocates for the change at their level in the organization.
A Sponsor is the person who won’t let the change initiative die from lack of attention, and is willing to use their political capital to make the change happen
The Role model:
Behaviors and attitudes demonstrated by them are looked upon by everyone else. . Hence, they must be willing to go first.
Employees watch leaders for consistency between words and actions to see if they should believe the change is really going to happen.
The decision maker:
Leaders usually control resources such as people, budgets, and equipment, and thus have the authority to make decisions (as per their span of control) that affect the initiative.
During change, leaders must leverage their decision-making authority and choose the options that will support the initiative.
The Decision-Maker is decisive and sets priorities that support change.
The Sponsor:
Champion and advocates for the change at their level in the organization.
A Sponsor is the person who won’t let the change initiative die from lack of attention, and is willing to use their political capital to make the change happen
The Role model:
Behaviors and attitudes demonstrated by them are looked upon by everyone else. . Hence, they must be willing to go first.
Employees watch leaders for consistency between words and actions to see if they should believe the change is really going to happen.
The decision maker:
Leaders usually control resources such as people, budgets, and equipment, and thus have the authority to make decisions (as per their span of control) that affect the initiative.
During change, leaders must leverage their decision-making authority and choose the options that will support the initiative.
The Decision-Maker is decisive and sets priorities that support change.
The Sponsor:
Champion and advocates for the change at their level in the organization.
A Sponsor is the person who won’t let the change initiative die from lack of attention, and is willing to use their political capital to make the change happen
The Role model:
Behaviors and attitudes demonstrated by them are looked upon by everyone else. . Hence, they must be willing to go first.
Employees watch leaders for consistency between words and actions to see if they s
Today, Python is one of the most popular programming languages. Although it is a general-purpose language, it is used in various areas of applications such as Machine Learning, Artificial Intelligence, web development, IoT, and more.
The document provides an overview of basic Python programming concepts including the structure of a Python program, data types, variables, operators, expressions, statements, functions, modules, and libraries. It discusses Python syntax elements like indentation, keywords, identifiers, literals, and escape sequences. It also covers basic Python programming concepts like input/output, operators, variables, and data types. The document is intended as an introductory guide to the basics of Python programming.
What is Python? | Uses, features & flavours of Python | Running Python | Identifiers | key words | values & types | Type casting | Operators | Functions | Types of arguments
This document provides an overview of Python basics training. It covers installing Python, running Python code through various methods like the command line, IDLE, and Jupyter notebooks. It also discusses Python syntax, variables, data types, operators, conditional statements, and loops. Key Python data types include integers, floats, strings, lists, and dictionaries. The document is intended as an introduction to Python for beginners.
This document provides an overview and introduction to learning Python. It discusses Python programming concepts like data science, machine learning, data visualizations, and web development. It also outlines benefits of Python like job opportunities, large community, being cross-platform, and free. The document then describes the Anaconda distribution tool for scientific computing projects. It introduces the Spyder IDE and its features like source code area, IPython console, and variable/file explorers. Basic Python syntax is covered such as printing, strings, variables, and conditionals. Finally, it discusses lists, loops, and common list methods.
This document provides an introduction and overview of the Python programming language. It discusses Python's key features such as being an interpreted, object-oriented, high-level programming language with dynamic typing and a large standard library. It also covers Python's use as both a scripting and general purpose language. The document then discusses Python's data types, operators, control flow statements, functions, and lambda expressions. It provides examples of using Python interactively and in script mode.
This document provides an overview of Python programming concepts across 5 units. Unit 1 introduces Python installation, data types, variables, expressions, statements and functions. It covers integers, floats, Booleans, strings, lists and the basics of writing Python code. Unit 2 discusses control flow statements like conditionals and loops. Unit 3 covers functions, strings, arrays and lists in more detail. Unit 4 focuses on lists, tuples, dictionaries and their methods. Unit 5 discusses files, exceptions, modules and packages in Python.
This document provides an overview of the basics of the Python programming language. It discusses Python's history and features, data types like numbers, strings, lists, tuples and dictionaries. It also covers Python concepts like variables, operators, control flow statements and functions. Specific topics covered include Python interpreters, comments, variables and scopes, data structures, conditional statements like if/else, and exceptions handling.
Guido van Rossum emphasized the importance of code readability in Python. He introduced significant whitespace as a core feature of the language, aiming to enforce a clean and readable code structure. This emphasis on readability is evident in the presentation's mention of Python's design philosophy that highlights code readability.Van Rossum emphasized the importance of Python in enabling developers to write clear and logical code, which is scalable for both small and large-scale projects. The presentation mentions Python's language constructs and object-oriented approach designed to assist programmers in achieving this goal.
Though not explicitly attributed to van Rossum, Python's dynamically typed nature and built-in garbage collection contribute to its ease of use and simplification of memory management, reflecting the language's user-centric design principles.
Overall, Guido van Rossum's vision and design choices for Python resonate with the attributes and philosophies outlined in the presentation. His influence is seen in Python's core principles, which prioritize readability, versatility, and ease of use for programmers.
This document provides a quick tour of the Python programming language. It introduces basic Python concepts like data types, variables, operators, conditional statements, loops, and functions. It explains how to get user input, perform type conversions, and work with common data types like integers, floats, strings, and booleans. It also demonstrates how to define functions, use default arguments and keyword arguments, and handle global variables. The document uses examples to illustrate concepts like arithmetic operations, string slicing, indexing, concatenation, and repetition.
This document provides an overview of Python basics including statements, expressions, loops, strings, functions, and more. It discusses what a program is and how it runs. It explains how to get input from the user, import modules like math, use assignment statements, and print output. It also covers syntax, side effects vs returns, whitespace, operators, loops, range function, strings, indexes, basic string operations, len function, and functions. The document is from a Python training institute in Bangalore and is intended to teach Python fundamentals.
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc
How does your privacy program stack up against your peers? What challenges are privacy teams tackling and prioritizing in 2024?
In the fifth annual Global Privacy Benchmarks Survey, we asked over 1,800 global privacy professionals and business executives to share their perspectives on the current state of privacy inside and outside of their organizations. This year’s report focused on emerging areas of importance for privacy and compliance professionals, including considerations and implications of Artificial Intelligence (AI) technologies, building brand trust, and different approaches for achieving higher privacy competence scores.
See how organizational priorities and strategic approaches to data security and privacy are evolving around the globe.
This webinar will review:
- The top 10 privacy insights from the fifth annual Global Privacy Benchmarks Survey
- The top challenges for privacy leaders, practitioners, and organizations in 2024
- Key themes to consider in developing and maintaining your privacy program
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
The document discusses Python programming language. It provides an overview of what Python is, what it can be used for, and why it is a popular language. Specifically, it notes that Python was created by Guido van Rossum and released in 1991. It is used for web development, software development, mathematics, and system scripting. The document then covers Python syntax, basic data types, operators, decision making and control flow statements like if/else and loops.
Gurukul Skills Schedule for the Month of March
Time Cohort-10 Cohort-11 Cohort-12
8.00 to 09.25 Revision Revision Revision
5 Minutes Short Break
9.30 to 11.30 Chartered Accountants Chartered Accountants ENGLISH/SOFT SKILLS
15 Minutes Short Break
11.45 to 01.45 ICT ENGLISH/SOFT SKILLS R&A
45 Minutues Lunch Break
2.30 to 04.30 ENGLISH/SOFT SKILLS R&A ICT
15 Minutes Short Break
4.45 to 06.30 R&A ICT ACCOUNTS
5 Minutes Short Break
6.35 to 08.00 Assingments Assingments Assingments
Basic concept of Python.pptx includes design tool, identifier, variables.supriyasarkar38
This document discusses Python programming concepts including data types, variables, operators, and functions. It provides examples of Python syntax for writing and executing code as well as built-in data types like strings, integers, and lists. Key concepts covered include variables, data type casting, comments, arithmetic and comparison operators, and functions.
Python (Data Analysis) cleaning and visualizeIruolagbePius
This document provides an overview of Python programming language. It discusses Python features, uses, variables, data types, operators, decision making statements, and loops. Specifically, it covers:
- Python features like being easy to learn and read, having an interactive mode, and being portable.
- Python variables, naming rules, and basic data types like numbers, strings, booleans.
- Operators for arithmetic, comparison, assignment, and logic.
- Conditional statements like if, elif, else for decision making.
- Looping structures like while and for loops, with examples of using break, continue, else, range().
- How to write comments, take user input, and
This document discusses variables, data types, expressions, and functions in Python. It defines a variable as a name that represents a stored value in memory. It describes different data types in Python including integers, floats, strings, Booleans, and others. It also discusses expressions, which represent computations that evaluate to a value, and different expression types like arithmetic, relational, logical, and compound expressions. Finally, it introduces functions as blocks of code that perform tasks and can return values.
This document discusses programming languages, compilers vs interpreters, and introduces Python. It explains that a programming language communicates instructions to a machine and can be used to create programs. An interpreter reads and executes code directly, while a compiler converts source code into machine code. Python is an interpreted, object-oriented language that is easy to learn yet powerful. It can be used for web, enterprise, and other applications. The document also provides basic information on Python syntax and data types.
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...DRVaibhavmeshram1
Python
Language
is uesd in engineeringStory adapted from Stephen Covey (2004) “The Seven Habits of Highly Effective People” Simon & Schuster).
“Management is doing things right, leadership is doing the right things”
(Warren Bennis and Peter Drucker)
Story adapted from Stephen Covey (2004) “The Seven Habits of Highly Effective People” Simon & Schuster).
“Management is doing things right, leadership is doing the right things”
(Warren Bennis and Peter Drucker)
Story adapted from Stephen Covey (2004) “The Seven Habits of Highly Effective People” Simon & Schuster).
“Management is doing things right, leadership is doing the right things”
(Warren Bennis and Peter Drucker)
The Sponsor:
Champion and advocates for the change at their level in the organization.
A Sponsor is the person who won’t let the change initiative die from lack of attention, and is willing to use their political capital to make the change happen
The Role model:
Behaviors and attitudes demonstrated by them are looked upon by everyone else. . Hence, they must be willing to go first.
Employees watch leaders for consistency between words and actions to see if they should believe the change is really going to happen.
The decision maker:
Leaders usually control resources such as people, budgets, and equipment, and thus have the authority to make decisions (as per their span of control) that affect the initiative.
During change, leaders must leverage their decision-making authority and choose the options that will support the initiative.
The Decision-Maker is decisive and sets priorities that support change.
The Sponsor:
Champion and advocates for the change at their level in the organization.
A Sponsor is the person who won’t let the change initiative die from lack of attention, and is willing to use their political capital to make the change happen
The Role model:
Behaviors and attitudes demonstrated by them are looked upon by everyone else. . Hence, they must be willing to go first.
Employees watch leaders for consistency between words and actions to see if they should believe the change is really going to happen.
The decision maker:
Leaders usually control resources such as people, budgets, and equipment, and thus have the authority to make decisions (as per their span of control) that affect the initiative.
During change, leaders must leverage their decision-making authority and choose the options that will support the initiative.
The Decision-Maker is decisive and sets priorities that support change.
The Sponsor:
Champion and advocates for the change at their level in the organization.
A Sponsor is the person who won’t let the change initiative die from lack of attention, and is willing to use their political capital to make the change happen
The Role model:
Behaviors and attitudes demonstrated by them are looked upon by everyone else. . Hence, they must be willing to go first.
Employees watch leaders for consistency between words and actions to see if they s
Today, Python is one of the most popular programming languages. Although it is a general-purpose language, it is used in various areas of applications such as Machine Learning, Artificial Intelligence, web development, IoT, and more.
The document provides an overview of basic Python programming concepts including the structure of a Python program, data types, variables, operators, expressions, statements, functions, modules, and libraries. It discusses Python syntax elements like indentation, keywords, identifiers, literals, and escape sequences. It also covers basic Python programming concepts like input/output, operators, variables, and data types. The document is intended as an introductory guide to the basics of Python programming.
What is Python? | Uses, features & flavours of Python | Running Python | Identifiers | key words | values & types | Type casting | Operators | Functions | Types of arguments
This document provides an overview of Python basics training. It covers installing Python, running Python code through various methods like the command line, IDLE, and Jupyter notebooks. It also discusses Python syntax, variables, data types, operators, conditional statements, and loops. Key Python data types include integers, floats, strings, lists, and dictionaries. The document is intended as an introduction to Python for beginners.
This document provides an overview and introduction to learning Python. It discusses Python programming concepts like data science, machine learning, data visualizations, and web development. It also outlines benefits of Python like job opportunities, large community, being cross-platform, and free. The document then describes the Anaconda distribution tool for scientific computing projects. It introduces the Spyder IDE and its features like source code area, IPython console, and variable/file explorers. Basic Python syntax is covered such as printing, strings, variables, and conditionals. Finally, it discusses lists, loops, and common list methods.
This document provides an introduction and overview of the Python programming language. It discusses Python's key features such as being an interpreted, object-oriented, high-level programming language with dynamic typing and a large standard library. It also covers Python's use as both a scripting and general purpose language. The document then discusses Python's data types, operators, control flow statements, functions, and lambda expressions. It provides examples of using Python interactively and in script mode.
This document provides an overview of Python programming concepts across 5 units. Unit 1 introduces Python installation, data types, variables, expressions, statements and functions. It covers integers, floats, Booleans, strings, lists and the basics of writing Python code. Unit 2 discusses control flow statements like conditionals and loops. Unit 3 covers functions, strings, arrays and lists in more detail. Unit 4 focuses on lists, tuples, dictionaries and their methods. Unit 5 discusses files, exceptions, modules and packages in Python.
This document provides an overview of the basics of the Python programming language. It discusses Python's history and features, data types like numbers, strings, lists, tuples and dictionaries. It also covers Python concepts like variables, operators, control flow statements and functions. Specific topics covered include Python interpreters, comments, variables and scopes, data structures, conditional statements like if/else, and exceptions handling.
Guido van Rossum emphasized the importance of code readability in Python. He introduced significant whitespace as a core feature of the language, aiming to enforce a clean and readable code structure. This emphasis on readability is evident in the presentation's mention of Python's design philosophy that highlights code readability.Van Rossum emphasized the importance of Python in enabling developers to write clear and logical code, which is scalable for both small and large-scale projects. The presentation mentions Python's language constructs and object-oriented approach designed to assist programmers in achieving this goal.
Though not explicitly attributed to van Rossum, Python's dynamically typed nature and built-in garbage collection contribute to its ease of use and simplification of memory management, reflecting the language's user-centric design principles.
Overall, Guido van Rossum's vision and design choices for Python resonate with the attributes and philosophies outlined in the presentation. His influence is seen in Python's core principles, which prioritize readability, versatility, and ease of use for programmers.
This document provides a quick tour of the Python programming language. It introduces basic Python concepts like data types, variables, operators, conditional statements, loops, and functions. It explains how to get user input, perform type conversions, and work with common data types like integers, floats, strings, and booleans. It also demonstrates how to define functions, use default arguments and keyword arguments, and handle global variables. The document uses examples to illustrate concepts like arithmetic operations, string slicing, indexing, concatenation, and repetition.
This document provides an overview of Python basics including statements, expressions, loops, strings, functions, and more. It discusses what a program is and how it runs. It explains how to get input from the user, import modules like math, use assignment statements, and print output. It also covers syntax, side effects vs returns, whitespace, operators, loops, range function, strings, indexes, basic string operations, len function, and functions. The document is from a Python training institute in Bangalore and is intended to teach Python fundamentals.
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc
How does your privacy program stack up against your peers? What challenges are privacy teams tackling and prioritizing in 2024?
In the fifth annual Global Privacy Benchmarks Survey, we asked over 1,800 global privacy professionals and business executives to share their perspectives on the current state of privacy inside and outside of their organizations. This year’s report focused on emerging areas of importance for privacy and compliance professionals, including considerations and implications of Artificial Intelligence (AI) technologies, building brand trust, and different approaches for achieving higher privacy competence scores.
See how organizational priorities and strategic approaches to data security and privacy are evolving around the globe.
This webinar will review:
- The top 10 privacy insights from the fifth annual Global Privacy Benchmarks Survey
- The top challenges for privacy leaders, practitioners, and organizations in 2024
- Key themes to consider in developing and maintaining your privacy program
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceIndexBug
Imagine a world where machines not only perform tasks but also learn, adapt, and make decisions. This is the promise of Artificial Intelligence (AI), a technology that's not just enhancing our lives but revolutionizing entire industries.
Unlocking Productivity: Leveraging the Potential of Copilot in Microsoft 365, a presentation by Christoforos Vlachos, Senior Solutions Manager – Modern Workplace, Uni Systems
In the rapidly evolving landscape of technologies, XML continues to play a vital role in structuring, storing, and transporting data across diverse systems. The recent advancements in artificial intelligence (AI) present new methodologies for enhancing XML development workflows, introducing efficiency, automation, and intelligent capabilities. This presentation will outline the scope and perspective of utilizing AI in XML development. The potential benefits and the possible pitfalls will be highlighted, providing a balanced view of the subject.
We will explore the capabilities of AI in understanding XML markup languages and autonomously creating structured XML content. Additionally, we will examine the capacity of AI to enrich plain text with appropriate XML markup. Practical examples and methodological guidelines will be provided to elucidate how AI can be effectively prompted to interpret and generate accurate XML markup.
Further emphasis will be placed on the role of AI in developing XSLT, or schemas such as XSD and Schematron. We will address the techniques and strategies adopted to create prompts for generating code, explaining code, or refactoring the code, and the results achieved.
The discussion will extend to how AI can be used to transform XML content. In particular, the focus will be on the use of AI XPath extension functions in XSLT, Schematron, Schematron Quick Fixes, or for XML content refactoring.
The presentation aims to deliver a comprehensive overview of AI usage in XML development, providing attendees with the necessary knowledge to make informed decisions. Whether you’re at the early stages of adopting AI or considering integrating it in advanced XML development, this presentation will cover all levels of expertise.
By highlighting the potential advantages and challenges of integrating AI with XML development tools and languages, the presentation seeks to inspire thoughtful conversation around the future of XML development. We’ll not only delve into the technical aspects of AI-powered XML development but also discuss practical implications and possible future directions.
HCL Notes and Domino License Cost Reduction in the World of DLAUpanagenda
Webinar Recording: https://www.panagenda.com/webinars/hcl-notes-and-domino-license-cost-reduction-in-the-world-of-dlau/
The introduction of DLAU and the CCB & CCX licensing model caused quite a stir in the HCL community. As a Notes and Domino customer, you may have faced challenges with unexpected user counts and license costs. You probably have questions on how this new licensing approach works and how to benefit from it. Most importantly, you likely have budget constraints and want to save money where possible. Don’t worry, we can help with all of this!
We’ll show you how to fix common misconfigurations that cause higher-than-expected user counts, and how to identify accounts which you can deactivate to save money. There are also frequent patterns that can cause unnecessary cost, like using a person document instead of a mail-in for shared mailboxes. We’ll provide examples and solutions for those as well. And naturally we’ll explain the new licensing model.
Join HCL Ambassador Marc Thomas in this webinar with a special guest appearance from Franz Walder. It will give you the tools and know-how to stay on top of what is going on with Domino licensing. You will be able lower your cost through an optimized configuration and keep it low going forward.
These topics will be covered
- Reducing license cost by finding and fixing misconfigurations and superfluous accounts
- How do CCB and CCX licenses really work?
- Understanding the DLAU tool and how to best utilize it
- Tips for common problem areas, like team mailboxes, functional/test users, etc
- Practical examples and best practices to implement right away
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
Communications Mining Series - Zero to Hero - Session 1DianaGray10
This session provides introduction to UiPath Communication Mining, importance and platform overview. You will acquire a good understand of the phases in Communication Mining as we go over the platform with you. Topics covered:
• Communication Mining Overview
• Why is it important?
• How can it help today’s business and the benefits
• Phases in Communication Mining
• Demo on Platform overview
• Q/A
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfMalak Abu Hammad
Discover how MongoDB Atlas and vector search technology can revolutionize your application's search capabilities. This comprehensive presentation covers:
* What is Vector Search?
* Importance and benefits of vector search
* Practical use cases across various industries
* Step-by-step implementation guide
* Live demos with code snippets
* Enhancing LLM capabilities with vector search
* Best practices and optimization strategies
Perfect for developers, AI enthusiasts, and tech leaders. Learn how to leverage MongoDB Atlas to deliver highly relevant, context-aware search results, transforming your data retrieval process. Stay ahead in tech innovation and maximize the potential of your applications.
#MongoDB #VectorSearch #AI #SemanticSearch #TechInnovation #DataScience #LLM #MachineLearning #SearchTechnology
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Best 20 SEO Techniques To Improve Website Visibility In SERPPixlogix Infotech
Boost your website's visibility with proven SEO techniques! Our latest blog dives into essential strategies to enhance your online presence, increase traffic, and rank higher on search engines. From keyword optimization to quality content creation, learn how to make your site stand out in the crowded digital landscape. Discover actionable tips and expert insights to elevate your SEO game.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...Neo4j
Leonard Jayamohan, Partner & Generative AI Lead, Deloitte
This keynote will reveal how Deloitte leverages Neo4j’s graph power for groundbreaking digital twin solutions, achieving a staggering 100x performance boost. Discover the essential role knowledge graphs play in successful generative AI implementations. Plus, get an exclusive look at an innovative Neo4j + Generative AI solution Deloitte is developing in-house.
2. Python Overview
• Python is a general-purpose, object-oriented programming language
with high-level programming capabilities.
• It has become famous because of its apparent and easily
understandable syntax, portability, and easy to learn.
• Python is a programming language that includes features of C and
Java. It provides the style of writing an elegant code like C, and for
object-oriented programming, it offers classes and objects like Java.
• Python is an open-source scripting language.
• Python is one of the official languages at Google.
3. Characteristics and Features of Python
• Interpreted Language: Python is processed at runtime by Python Interpreter.
• Object-Oriented Language: It supports object-oriented features and techniques of programming.
• Interactive Programming Language: Users can interact with the python interpreter directly for
writing programs.
• Easy language: Python is easy to learn, especially for beginners.
• Straightforward Syntax: The formation of python syntax is simple and straightforward, which also
makes it popular.
• Easy to read: Python source-code is clearly defined and visible to the eyes.
• Portable: Python codes can be run on a wide variety of hardware platforms having the same
interface.
• Extendable: Users can add low level-modules to Python interpreter.
• Scalable: Python provides an improved structure for supporting large programs then shell-scripts.
4. What You Can Do with Python
• Python is used to create web and desktop applications, and some of
the most popular web applications like Instagram, YouTube, Spotify all
have been developed in Python.
5. • Script Mode : Alternatively, programmers can store Python script
source code in a file with the .py extension, and use the interpreter to
execute the contents of the file. To execute the script by the
interpreter, you have to tell the interpreter the name of the file.
• Working with the interactive mode is better when Python
programmers deal with small pieces of code as you can type and
execute them immediately, but when the code is more than 2-4 lines,
using the script for coding can help to modify and use the code in
future.
6. • There are two modes for using the Python interpreter:
1. Interactive Mode
2. Script Mode
• Interactive Mode : Without passing the python script file to the
interpreter, directly execute code to Python prompt.
8. PYTHON PROGRAMS
a program is a sequence of definitions and commands
◦ definitions evaluated
◦ commands executed by Python interpreter in a shell
commands (statements) instruct interpreter to do
something
can be typed directly in a shell or stored in a file that
is read into the shell and evaluated
◦
6.0001 LECTURE 1 23
9. Variable Declaration
• x = 100 # x is integer
• pi = 3.14 # pi is float
• course = "python" # course is string
• a = b = c = 100 # this statement assign 100 to c, b and a.
• print(x) # print the value of variable x
• print(pi) # print the value of variable pi
• print(course) # print the value of variable course
• print(a, b, c) # print the value of variable a, b, and c, simultaneously
10. Simultaneous Assignment
• The simultaneous assignment or multiple assignment allows us to
assign values to multiple variables at once. The syntax of
simultaneous assignment is as follows:
• var1, var2, ..., varn = exp1, exp2, ..., expn
• This statement tells the Python to evaluate all the expression on the
right and assign them to the corresponding variables on the left. For
e.g:
a, b = 10, 20
print(a)
print(b)
11. Swapping values of two Variables
x = 1 # initial value of x is 1
y = 2 # initial value of y is 2
y, x = x, y # assign y value to x and x value to y
print(x) # final value of x is 2
print(y) # final value of y is 1
12. Importing modules
• Python organizes codes using modules. Python comes with many
built-in modules ready to use for e.g there is a math module for
mathematical related functions, re module for regular expression, os
module for operating system related functions.
• Syntax : import module_name
import math, os
print(math.pi)
print(math.e)
print(os.getcwd()) # print current working directory
13. Python Numbers
• This data type supports only numerical values like 1, 31.4, -1000,
0.000023, 88888888.
• Python supports 3 different numerical types.
• int - for integer values like 1, 100, 2255, -999999, 0, 12345678.
• float - for floating-point values like 2.3, 3.14, 2.71, -11.0.
• complex - for complex numbers like 3+2j, -2+2.3j, 10j, 4.5+3.14j.
• complex number consists of two parts real and imaginary, and is denoted by j.
x = 2 + 3j # where 2 is the real part and 3 is imaginary
15. COMPARISON OPERATORS ON
int, float,string
6.0001 LECTURE2 1
i and j are variable names
comparisons below evaluate to a Boolean
i > j
i >= j
i < j
i <= j
i == j equality test, True if i is the same as j
i != j inequality test, True if i not the same as j
16. LOGIC OPERATORS ON bools
6.0001 LECTURE2 1
a and b are variable names (with Boolean values)
True if a is False
False if a is True
not a
a and b
a or b
True if both are True
True if either or both are True
A B A and B A or B
True True True True
True False False True
False True False True
False False False False
17. COMPARISON EXAMPLE
6.0001 LECTURE2 1
pset_time = 15
sleep_time = 8
> pset_time)
print(sleep_time
derive = True
drink = False
both = drink and derive
print(both)
18. INPUT/OUTPUT: print
6.0001 LECTURE2 1
used to output stuff to console
keyword is print
x = 1
print(x)
x_str = str(x)
print("my fav num is", x, ".", "x =", x)
print("my fav num is " + x_str + ". " + "x = " + x_str)
19. INPUT/OUTPUT: input("")
6.0001 LECTURE2 1
prints whatever is in the quotes
user types in something and hits enter
binds that value to a variable
text = input("Type anything... ")
print(5*text)
input gives you a string so must cast if working
with numbers
num = int(input("Type a number... "))
print(5*num)
20. Receiving input from Console
• The input() function accepts an optional string argument called
prompt and returns a string.
name = input("Enter your name: ")
print(name)
• input() function always returns a string even if you entered a number.
To convert it to an integer you can use int() or eval() functions.
age = int(input("Enter your age: "))
print(age)
print(type(age))
21. CONTROL FLOW - BRANCHING
6.0001 LECTURE2 2
if <condition>:
<expression>
<expression>
...
if <condition>:
<expression>
<expression>
...
else:
<expression>
<expression>
...
if <condition>:
<expression>
<expression>
...
elif <condition>:
<expression>
<expression>
...
else:
<expression>
<expression>
...
<condition> has a value True or False
evaluate expressions in that block if <condition> is True
22. Python Control Statements
if boolean-expression:
#statements
else:
#statements
i = 10
if i % 2 == 0:
print("Number is even")
else:
print("Number is odd")
23. • If your programs needs to check long list of conditions
then you need to use if-elif-else statements.
if boolean-expression:
#statements
elif boolean-expression:
#statements
elif boolean-expression:
#statements
elif boolean-expression:
#statements
else:
#statements
24. IF-Elif Example
today = "monday"
if today == "monday":
print("this is monday")
elif today == "tuesday":
print("this is tuesday")
elif today == "wednesday":
print("this is wednesday")
elif today == "thursday":
print("this is thursday")
elif today == "friday":
print("this is friday")
elif today == "saturday":
print("this is saturday")
elif today == "sunday":
print("this is sunday")
else:
print("something else")
25. INDENTATION
print("x and y are equal"
if y != 0
print("therefore, x / y is", x/y
print("x is smaller"
else:
print("y is smaller"
print("thanks!")
matters in Python
how you denote blocks of code
x = float(input("Enter a number for x: "))
y = float(input("Enter a number for y: "))
if x == y:
print("x and y are equal")
if y != 0:
print("therefore, x / y is", x/y)
elif x < y:
6.0001 LECTURE2 2
print("x s smaller")
print("y s smaller")
26. =vs ==
x = float(input("Enter a number for x: "))
y = float(input("Enter a number for y: "))
if x == y:
print("x and y are equal")
if y != 0:
print("therefore, x / y is", x/y)
elif x < y:
print("x is smaller")
else:
print("y is smaller")
print("thanks!")
6.0001 LECTURE2 2
27. CONTROL FLOW:
whileLOOPS
6.0001 LECTURE2 2
while <condition>:
<expression>
<expression>
...
<condition> evaluates to a Boolean
if <condition> is True, do all the steps inside the
while code block
check <condition> again
repeat until <condition> is False
28. whileLOOP EXAMPLE
6.0001 LECTURE2 2
You are in the Lost Forest.
************
************
************
************
Go left or right?
PROGRAM:
n = input("You're in the Lost Forest. Go left or right? ")
while n == "right":
n = input("You're in the Lost Forest. Go left or right? ")
print("You got out of the Lost Forest!")
29. CONTROL FLOW:
while and forLOOPS
6.0001 LECTURE2 2
iterate through numbers in a sequence
# more complicated with while loop
n = 0
while n < 5:
print(n)
n = n+1
# shortcut with for loop
for n in range(5):
print(n)
30. CONTROL FLOW: forLOOPS
6.0001 LECTURE2 3
for <variable> in range(<some_num>):
<expression>
<expression>
...
each time through the loop, <variable> takes a value
first time, <variable> starts at the smallest value
next time, <variable> gets the prev value + 1
etc.
31. range(start,stop,step)
6.0001 LECTURE2 3
default values are start = 0 and step = 1 and optional
loop until value is stop - 1
mysum = 0
for i in range(7, 10):
mysum += i
print(mysum)
mysum = 0
for i in range(5, 11, 2):
mysum += i
print(mysum)
32. breakSTATEMENT
6.0001 LECTURE2 3
immediately exits whatever loop it is in
skips remaining expressions in code block
exits only innermost loop!
while <condition_1>:
while <condition_2>:
<expression_a>
break
<expression_b>
<expression_c>
33. break STATEMENT
mysum += i
if mysum == 5
break
mysum = 0
for i in range(5, 11, 2): mysum
f mysum == 5: break
mysum += 1
print(mysum)
what happens in this program?
34. for
6.0001 LECTURE2 3
VS while LOOPS
for loops
know number of
iterations
can end early via
break
uses a counter
can rewrite a for loop
using a while loop
while loops
unbounded number of
iterations
can end early via break
can use a counter but
must initialize before loop
and increment it inside loop
may not be able to rewrite
a while loop using a for
loop
35. STRINGS
6.0001 LECTURE2 3
letters, special characters, spaces, digits
enclose in quotation marks or single quotes
hi = "hello there"
concatenate strings
name = "ana"
greet = hi + name
greeting = hi + " " + name
do some operations on a string as defined in Python docs
silly = hi + " " + name * 3
36. STRINGS
6.0001 LECTURE3 36
think of as a sequence of case sensitive characters
can compare strings with ==, >, < etc.
len() is a function used to retrieve the length of the
string in the parentheses
s = "abc"
len(s) evaluates to 3
37. STRINGS
6.0001 LECTURE3 37
square brackets used to perform indexing into a string
to get the value at a certain index/position
s = "abc"
s[0] evaluates to "a"
s[1] evaluates to "b"
s[2] evaluates to "c"
s[3] trying to index out of bounds, error
s[-1] evaluates to "c"
s[-2] evaluates to "b"
s[-3] evaluates to "a"
index:
index:
0 1 2 indexing always starts at 0
-3 -2 -1 last element always at index -1
38. STRINGS
strings are “immutable” – cannot be modified
s = "hello"
s[0] = 'y'
s = 'y'+s[1:len(s)]
gives an error
is allowed,
s bound to new object
s
"hello"
"yello"
6.0001 LECTURE3 38
39. for LOOPS RECAP
6.0001 LECTURE3 39
for loops have a loop variable that iterates over a set of
values
for var in range(4):
<expressions>
var iterates over values 0,1,2,3
expressions inside loop executed
with each value for var
for var in range(4,6): var iterates over values 4,5
<expressions>
range is a way to iterate over numbers, but a for loop
variable can iterate over any set of values, not just numbers!
40. STRINGS AND LOOPS
6.0001 LECTURE3 40
these two code snippets do the same thing
bottom one is more “pythonic”
s = "abcdefgh"
for index in range(len(s)):
if s[index] == 'i' or s[index] == 'u':
print("There is an i or u")
for char in s:
if char == 'i' or char
print("There is an
== 'u':
i or u")
41. CODE EXAMPLE:
ROBOT CHEERLEADERS
an_letters = "aefhilmnorsxAEFHILMNORSX"
word = input("I will cheer for you! Enter a word: ")
times = int(input("Enthusiasm level (1-10): "))
i = 0
while i < len(word):
char = word[i]
if char in an_letters:
print("Give me an " + char + "! " + char)
else:
print("Give me a " + char + "! " + char)
i += 1
print("What does that spell?")
for i in range(times):
print(word, "!!!")
for char in word:
6.0001 LECTURE3 41
42. EXERCISE
6.0001 LECTURE3 42
s1 = "mit u rock"
s2 = "i rule mit"
if len(s1) == len(s2):
for char1 in s1:
for char2 in s2:
if char1 == char2:
print("common letter")
break
43. GOOD PROGRAMMING
6.0001 LECTURE4 43
more code not necessarily a good thing
measure good programmers by the amount of
functionality
introduce functions
mechanism to achieve decomposition and abstraction
44. EXAMPLE – PROJECTOR
6.0001 LECTURE4 44
a projector is a black box
don’t know how it works
know the interface: input/output
connect any electronic to it that can communicate
with that input
black box somehow converts image from input source
to a wall, magnifying it
ABSTRACTION IDEA: do not need to know how
projector works to use it
45. EXAMPLE – PROJECTOR
6.0001 LECTURE4 45
projecting large image for Olympics decomposed into
separate tasks for separate projectors
each projector takes input and produces separate
output
all projectors work together to produce larger image
DECOMPOSITION IDEA: different devices work
together to achieve an end goal
47. CREATE STRUCTURE with
6.0001 LECTURE4 47
DECOMPOSITION
in projector example, separate devices
in programming, divide code into modules
• are self-contained
• used to break up code
• intended to be reusable
• keep code organized
• keep code coherent
this lecture, achieve decomposition with functions
in a few weeks, achieve decomposition with classes
48. SUPRESS DETAILS with
6.0001 LECTURE4 48
ABSTRACTION
in projector example, instructions for how to use it are
sufficient, no need to know how to build one
in programming, think of a piece of code as a black box
• cannot see details
• do not need to see details
• do not want to see details
• hide tedious coding details
achieve abstraction with function specifications or
Docstrings
A docstring is simply a multi-line string, that is not assigned to anything. It is specified in
source code that is used to document a specific segment of code. Unlike conventional
source code comments, the docstring should describe what the function does, not how.
49. FUNCTIONS
6.0001 LECTURE4 49
write reusable pieces/chunks of code, called functions
functions are not run in a program until they are
“called” or “invoked” in a program
function characteristics:
• has a name
• has parameters (0 or more)
• has a docstring (optional but recommended)
• has a body
• returns something
50. def is_even( i ):
"""
Input: i, a positive int
Returns True if i is even, otherwise False
"""
print("inside is_even")
return i%2 == 0
is_even(3)
HOW TO WRITE and CALL/INVOKE A
FUNCTION
6.0001 LECTURE4 50
51. def is_even( i ):
"""
Input: i, a positive int
Returns True if i is even, otherwise False
"""
IN THE FUNCTIONBODY
print("inside is_even")
return i%2 == 0
6.0001 LECTURE4 51
52. formal parameter gets bound to the value of
actual parameter when function is called
new scope/frame/environment created when enter a function
scope is mapping of names to objects
def f( x ):
x = x + 1
print('in f(x): x =', x)
return x
VARIABLE SCOPE
x = 3
z = f( x )
6.0001 LECTURE4 52
53. def f( x ):
x = x + 1
print('in f(x): x =', x)
return x
6.0001 LECTURE4 53
x = 3
z = f( x )
VARIABLE SCOPE
Global scope
f
x
z
Some
code
f scope
x 3
3
56. VARIABLE SCOPE
6.0001 LECTURE4 56
Global scope
f
x
z
Some
code
3
4
def f( x ):
x = x + 1
print('in f(x): x =', x)
return x
x = 3
z = f( x )
57. ONE WARNING IF NO
returnSTATEMENT
def is_even( i ):
"""
Input: i, a positive int
Does not return anything
"""
i%2 == 0
Python returns the value None, if no return given
represents the absence of a value
6.0001 LECTURE4 57
58. return vs. print
return only has meaning
• inside a function
only one return executed inside a
function
code inside function but after
return statement not executed
has a value associated with it,
given to function caller
print can be used outside functions
can execute many print statements
inside a function
code inside function can be executed
after a print statement
has a value associated with it,
outputted to the console
6.0001 LECTURE4
59. FUNCTIONS AS ARGUMENTS
arguments can take on any type, even functions
def func_a():
print 'inside func_a'
def func_b(y):
print 'inside func_b'
return y
def func_c(z):
print 'inside func_c'
return z()
print func_a()
print 5 + func_b(2)
print func_c(func_a)
6.0001 LECTURE4 59
60. FUNCTIONS AS ARGUMENTS
def func_a():
print 'inside func_a'
def func_b(y):
print 'inside func_b'
return y
def func_c(z):
print 'inside func_c'
return z()
print func_a()
func_a
func_b
func_c
Some
code
Some
code
Some
code
Global scope func_a scope
returns None
None
print 5 + func_b(2)
print func_c(func_a)
6.0001 LECTURE4
60
61. func_a
func_b
func_c
FUNCTIONS AS ARGUMENTS
def func_a():
print 'inside func_a'
def func_b(y):
print 'inside func_b'
return y
def func_c(z):
print 'inside func_c'
return z()
print func_a()
Some
code
Some
code
Some
code
Global scope func_b scope
y 2
returns 2
None
print 5 + func_b(2)
print func_c(func_a)
6.0001 LECTURE4
61
7
62. FUNCTIONS AS ARGUMENTS
def func_a():
print 'inside func_a'
def func_b(y):
print 'inside func_b'
return y
def func_c(z):
print 'inside func_c'
return z()
print func_a()
print 5 + func_b(2)
print func_c(func_a)
func_c scope
z func_a
func_a scope
returns None
returns None
Global scope
func_a Some
code
Some
func_b code
Some
func_c code
None
7
None
6.0001 LECTURE4
63. SCOPE EXAMPLE
x = 5
g(x)
print(x)
print(x) x += 1
print(x + 1)
x = 5
h(x)
print(x)
inside a function, can access a variable defined outside
inside a function, cannot modify a variable defined outside -- can u
global variables, but frowned upon
• def f(y): def g(y): def h(y):
x = 1
x += 1
print(x)
x = 5
f(x)
print(x)
6.0001 LECTURE4 63
64. inside a function, can access a variable defined outside
inside a function, cannot modify a variable defined outside -- can u
global variables, but frowned upon
SCOPE EXAMPLE
def g(y):
print(x)
x = 5
g(x)
print(x)
def h(y):
x += 1
x = 5
h(x)
print(x)
def f(y):
x = 1
x += 1
print(x)
x = 5
f(x)
print(x)
6.0001 LECTURE4 64
65. def g(x):
def h():
x = 'abc'
x = x + 1
print('g: x =', x)
h()
return x
x
z
=
=
3
g(x)
SCOPE DETAILS
Global scope
g
x
z
Some
code
3
6.0001 LECTURE4 65
66. SCOPE DETAILS
6.0001 LECTURE4 66
g scope
x
h Some
code
3
Global scope
g
x
z
Some
code
3
def g(x):
def h():
x = 'abc'
x = x + 1
print('g: x =', x)
h()
return x
x
z
=
=
3
g(x)
67. SCOPE DETAILS
g scope
x
h Some
code
4
3
6.0001 LECTURE4 67
Global scope
g
x
z
Some
code
3
def g(x):
def h():
x = 'abc'
x = x + 1
print('g: x =', x)
h()
return x
x
z
=
=
3
g(x)
68. SCOPE DETAILS
Global scope
g
x
z
Some
code
3
g scope
x
h Some
code
3 “abc”
4
def g(x):
def h():
6.0001 LECTURE4 68
x = 'abc'
x = x + 1
print('g: x =', x)
h()
return x
x = 3
z = g(x)
h scope
x
returns None
69. SCOPE DETAILS
g scope
x
h Some
code
None
4
Global scope
g
x
z
Some
code
3
def g(x):
def h():
6.0001 LECTURE4 69
x = 'abc'
x = x + 1
print('g: x =', x)
h()
return x
x
z
=
=
3
g(x)
returns 4
70. SCOPE DETAILS
6.0001 LECTURE4 70
Global scope
g
x
z
Some
code
3
4
def g(x):
def h():
x = 'abc'
x = x + 1
print('g: x =', x)
h()
return x
x
z
=
=
3
g(x)
72. TUPLES
an ordered sequence of elements, can mix element types
cannot change element values, immutable
represented with parentheses
te = ()
t = (2,"mit",3)
t[0]
(2,"mit",3) + (5,6)
evaluates to 2
evaluates to (2,"mit",3,5,6)
slice tuple, evaluates to ("mit",)
t[1:2]
t[1:3]
len(t)
slice tuple, evaluates to ("mit",3)
evaluates to 3
t[1] = 4 gives error, can’t modify object
6.0001 LECTURE5 72
73. TUPLES
conveniently used to swap variable values
(x, y) = (y, x)
x = y
y = x
temp = x
x = y
y = temp
used to return more than one value from a function
def quotient_and_remainder(x, y):
q = x // y
r = x % y
return (q, r)
(quot, rem) = quotient_and_remainder(4,5)
6.0001 LECTURE5 73
74. MANIPULATING TUPLES
can iterate over tuples
def get_data(aTuple):
nums = ()
words = ()
for t in aTuple:
nums = nums + (t[0],)
if t[1] not in words:
words = words + (t[1],)
min_n = min(nums)
max_n = max(nums)
unique_words = len(words)
return (min_n, max_n, unique_words)
aTuple:(( ),( ),( ))
nums( )
words( ? ? ? )
if not already in words
i.e. unique strings from aTuple
6.0001 LECTURE5 74
75. LISTS
6.0001 LECTURE5 75
ordered sequence of information, accessible by index
a list is denoted by square brackets, []
a list contains elements
• usually homogeneous (ie, all integers)
• can contain mixed types (not common)
list elements can be changed so a list is mutable
76. INDICES AND ORDERING
a_list = []
L = [2, 'a', 4, [1,2]]
evaluates to 4
evaluates to 2
evaluates to 5
len(L)
L[0]
L[2]+1
L[3]
L[4]
i = 2
L[i-1]
evaluates to [1,2], another list!
gives an error
evaluates to ‘a’ since L[1]='a' above
6.0001 LECTURE5 76
77. CHANGING ELEMENTS
lists are mutable!
assigning to an element at an index changes the value
L = [2, 1, 3]
L[1] = 5
L is now [2, 5, 3], note this is the same object L
L
[2,5,3]
6.0001 LECTURE5 77
78. ITERATING OVER A LIST
compute the sum of elements of a list
common pattern, iterate over list elements
to len(L)-1
• range(n) goes from 0 to n-1
total = 0
for i in range(len(L)):
total += L[i]
print total
notice
• list elements are indexed 0
total = 0
for i in L:
total += i
print total
6.0001 LECTURE5 78
79. OPERATIONS ON LISTS - ADD
add elements to end of list with L.append(element)
mutates the list!
L = [2,1,3]
L.append(5) L is now [2,1,3,5]
what is the dot?
• lists are Python objects, everything in Python is an object
• objects have data
• objects have methods and functions
• access this information by object_name.do_something()
• will learn more about these later
6.0001 LECTURE5 79
80. OPERATIONS ON LISTS - ADD
6.0001 LECTURE5 80
to combine lists together use concatenation, + operator,
to give you a new list
mutate list with L.extend(some_list)
L1 = [2,1,3]
L2 = [4,5,6]
L3 = L1 + L2 L3 is [2,1,3,4,5,6]
L1, L2 unchanged
L1.extend([0,6]) mutated L1 to [2,1,3,0,6]
81. OPERATIONS ON LISTS-
REMOVE
delete element at a specific index with del(L[index])
remove element at end of list with L.pop(), returns the
removed element
remove a specific element with L.remove(element)
• looks for the element and removes it
• if element occurs multiple times, removes first occurrence
• if element not in list, gives an error
L = [2,1,3,6,3,7,0] # do below in order
L.remove(2) mutates L = [1,3,6,3,7,0]
L.remove(3) mutates L = [1,6,3,7,0]
del(L[1])
L.pop()
mutates L = [1,3,7,0]
returns 0 and mutates L = [1,3,7]
6.0001 LECTURE5 81
82. CONVERT LISTS TO STRINGS
AND BACK
6.0001 LECTURE5 82
convert string to list with list(s), returns a list with every
character from s an element in L
can use s.split(), to split a string on a character parameter,
splits on spaces if called without a parameter
use ''.join(L) to turn a list of characters into a string, can
give a character in quotes to add char between every element
s = "I<3 cs"
list(s)
s.split('<')
L = ['a','b','c']
''.join(L)
'_'.join(L)
s is a string
returns ['I','<','3',' ','c','s']
returns ['I', '3 cs']
L is a list
returns "abc"
returns "a_b_c"
83. OTHER LIST OPERATIONS
6.0001 LECTURE5 83
sort() and sorted()
reverse()
and many more!
https://docs.python.org/3/tutorial/datastructures.html
L=[9,6,0,3]
sorted(L)
L.sort()
L.reverse()
returns sorted list, does not mutate L
mutates L=[0,3,6,9]
mutates L=[9,6,3,0]
84. LISTS IN MEMORY
6.0001 LECTURE5 84
lists are mutable
behave differently than immutable types
is an object in memory
variable name points to object
any variable pointing to that object is affected
key phrase to keep in mind when working with lists is
side effects
85. AN ANALOGY
attributes of a person
◦ singer, rich
he is known by many names
all nicknames point to the same person
• add new attribute to one nickname …
Justin Bieber singer rich troublemaker
• … all his nicknames refer to old attributes AND all new ones
The Bieb singer rich troublemaker
JBeebs singer rich troublemaker
6.0001 LECTURE5 85
86. ALIASES
hot is an alias for warm – changing one changes the
other!
append() has a side effect
6.0001 LECTURE5 86
87. CLONING A LIST
create a new list and copy every element using
chill = cool[:]
6.0001 LECTURE5 87
88. SORTING LISTS
calling sort() mutates the list, returns nothing
calling sorted()
does not mutate
list, must assign
result to a variable
6.0001 LECTURE5 88
89. LISTS OF LISTS OF LISTSOF….
can have nested lists
side effects still
possible after mutation
6.0001 LECTURE5 89
90. MUTATION AND ITERATION
Try this in Python Tutor!
avoid mutating a list as you are iterating over it
def remove_dups(L1, L2):
for e in L1:
if e in L2:
L1.remove(e)
L1 = [1, 2, 3, 4]
L2 = [1, 2, 5, 6]
remove_dups(L1, L2)
L1 is [2,3,4] not [3,4] Why?
• Python uses an internal counter to keep track of index it is in the loop
• mutating changes the list length but Python doesn’t update the counter
• loop never sees element 2
def remove_dups(L1, L2):
L1_copy = L1[:]
for e in L1_copy:
if e in L2:
L1.remove(e)
6.0001 LECTURE5 90
91. RECURSION
Recursion is the process of repeating items in a self-similar
way.
recursion – divide/decrease and conquer
9
1
92. WHAT IS RECURSION?
9
2
Algorithmically: a way to design solutions to problems
by divide-and-conquer or decrease-and-conquer
◦ reduce a problem to simpler versions of the same
problem
Semantically: a programming technique where a
function calls itself
◦ in programming, goal is to NOT have infinite recursion
◦ must have 1 or more base cases that are easy to solve
◦ must solve the same problem on some other input with the goal
of simplifying the larger problem input
93. ITERATIVE ALGORITHMS SO
FAR
9
3
looping constructs (while and for loops) lead to
iterative algorithms
can capture computation in a set of state variables
that update on each iteration through loop
94. MULTIPLICATION – ITERATIVE
SOLUTION
“multiply a * b” is equivalent to “add a to itself b times”
a + a + a + a + … + a
capture state by
◦ an iteration number (i) starts at b
i i-1 and stop when 0 0a 1a 2a 3a 4a
◦ a current value of computation (result)
result result + a
def mult_iter(a, b):
result = 0
return result
while b > 0:
result += a
b -= 1
9
4
95. MULTIPLICATION – RECURSIVE
SOLUTION
recursive step
• think how to reduce problem to a
simpler/ smaller version of same
problem
base case
• keep reducing problem until reach
a simple case that can be solved
directly
• when b = 1, a*b = a
a*b = a + a + a + a + … + a
= a + a + a + a + … + a
= a + a * (b-1)
def mult(a, b):
if b == 1:
return a
else:
return a + mult(a, b-1)
6.0001 LECTURE6
9
5
96. FACTORIAL
n! = n*(n-1)*(n-2)*(n-3)* … * 1
for what n do we know the factorial?
n = 1 if n == 1:
return 1
how to reduce problem? Rewrite in terms of
something simpler to reach base case
n*(n-1)! else:
return n*factorial(n-1)
98. SOME OBSERVATIONS
each recursive call to a function creates its
own scope/environment
bindings of variables in a scope are not
changed by recursive call
flow of control passes back to previous
scope once function call returns value
99. ITERATION
vs
.
RECURSION
def factorial_iter(n):
prod = 1
for i in range(1,n+1):
prod *= i
return prod
def factorial(n):
if n == 1:
return 1
else:
return n*factorial(n-1)
recursion may be simpler, more intuitive
recursion may be efficient from programmer POV
recursion may not be efficient from computer POV
100. INDUCTIVE REASONING
100
6.0001 LECTURE6
How do we know that our
recursive code will work?
mult_iter terminates
because b is initially positive,
and decreases by 1 each time
around loop; thus must
eventually become less than 1
mult called with b = 1 has no
recursive call and stops
mult called with b > 1 makes
a recursive call with a smaller
version of b; must eventually
reach call with b = 1
def mult_iter(a, b):
result = 0
while b > 0:
result += a b -=
1
return result
def mult(a, b): if b
== 1:
return a else:
return a + mult(a, b-1)
101. MATHEMATICAL INDUCTION
To prove a statement indexed on integers is true for all
values of n:
◦ Prove it is true when n is smallest value (e.g. n = 0 or n = 1)
◦ Then prove that if it is true for an arbitrary value of n, one
can show that it must be true for n+1
102. EXAMPLE OF INDUCTION
0 + 1 + 2 + 3 + … + n = (n(n+1))/2
Proof:
◦ If n = 0, then LHS is 0 and RHS is 0*1/2 = 0, so true
◦ Assume true for some k, then need to show that
0 + 1 + 2 + … + k + (k+1) = ((k+1)(k+2))/2
◦ LHS is k(k+1)/2 + (k+1) by assumption that property holds for
problem of size k
◦ This becomes, by algebra, ((k+1)(k+2))/2
◦ Hence expression holds for all n >= 0
103. RELEVANCE TO CODE?
Same logic applies
def mult(a, b):
if b == 1:
return a
else:
return a + mult(a, b-1)
Base case, we can show that mult must return correct answer
For recursive case, we can assume that mult correctly returns an
answer for problems of size smaller than b, then by the addition step, it
must also return a correct answer for problem of size b
Thus by induction, code correctly returns answer
104. TOWERS OF HANOI
The story:
◦ 3 tall spikes
◦ Stack of 64 different sized discs – start on one spike
◦ Need to move stack to second spike (at which point
universe ends)
◦ Can only move one disc at a time, and a larger disc can
never cover up a small disc
105. TOWERS OF HANOI
Having seen a set of examples of different sized stacks,
how would you write a program to print out the right
set of moves?
Think recursively!
◦ Solve a smaller problem
◦ Solve a basic problem
◦ Solve a smaller problem
106. def printMove(fr, to):
print('move from ' + str(fr) + ' to ' +
str(to))
def Towers(n, fr, to, spare):
if n == 1:
printMove(fr, to)
else:
Towers(n-1, fr, spare, to)
Towers(1, fr, to, spare)
Towers(n-1, spare, to, fr)
107. RECURSION WITH MULTIPLE BASE CASES
Fibonacci numbers
◦ Leonardo of Pisa (aka Fibonacci) modeled the following
challenge
◦ Newborn pair of rabbits (one female, one male) are put in a pen
◦ Rabbits mate at age of one month
◦ Rabbits have a one month gestation period
◦ Assume rabbits never die, that female always produces one new
pair (one male, one female) every month from its second month
on.
◦ How many female rabbits are there at the end of one year?
118. FIBONACCI
Ayer one month (call it 0) – 1 female
Ayer second month – still 1 female(now
pregnant)
Ayer third month – two females, onepregnant,
one not
In general, females(n) = females(n-1) +
females(n-2)
◦ Every female alive at month n-2 will produce one
female in month n;
◦ These can be added those alive in month n-1 to
get total alive in month n
Month Females
0 1
1 1
2 2
3 3
4 5
5 8
6 13
11
8
121. RECURSION ON NON- NUMERICS
how to check if a string of characters is a palindrome, i.e.,
reads the same forwards and backwards
◦ “Able was I, ere I saw Elba” – attributed to Napoleon
◦ “Are we not drawn onward, we few, drawn onward to new era?” –
attributed to Anne Michaels
Image courtesy of wikipedia, in the public domain. By Larth_Rasnal (Own work) [GFDL (https://www.gnu.org/licenses/fdl-1.3.en.html) or
CC BY 3.0 (https://creativecommons.org/licenses/by/3.0)], via Wikimedia Commons.
12
1
122. SOLVING RECURSIVELY?
12
2
First, convert the string to just characters, by stripping
out punctuation, and converting upper case to lower
case
Then
◦ Base case: a string of length 0 or 1 is a palindrome
◦ Recursive case:
◦ If first character matches last character, then is a palindrome if
middle section is a palindrome
123. EXAMPLE
‘Able was I, ere I saw Elba’ ‘ablewasiereisawleba’
isPalindrome(‘ablewasiereisawleba’)
is same as
◦ ‘a’ == ‘a’ and
isPalindrome(‘blewasiereisawleb’)
12
3
124. def isPalindrome(s):
def toChars(s):
s = s.lower()
ans = ''
for c in s:
if c in
'abcdefghijklmnopqrstuvwxyz':
ans = ans + c
return ans
def isPal(s):
if len(s) <= 1:
return True
else:
return s[0] == s[-1] and isPal(s[1:-1])
return isPal(toChars(s))
12
4
125. DIVIDE AND CONQUER
an example of a “divide and conquer” algorithm
solve a hard problem by breaking it into a set of sub-
problems such that:
◦ sub-problems are easier to solve than the original
◦ solutions of the sub-problems can be combined to solve
the original
6.0001 LECTURE 6 39
127. HOW TO STORE
STUDENT INFO
so far, can store using separate lists for every info
names = ['Ana', 'John', 'Denise', 'Katy']
grade = ['B', 'A+', 'A', 'A']
course = [2.00, 6.0001, 20.002, 9.01]
a separate list for each item
each list must have the same length
info stored across lists at same index, each index refers to
info for a different person
12
7
128. HOW TO UPDATE/RETRIEVE STUDENT
INFO
12
8
• def get_grade(student, name_list, grade_list, course_list):
• i = name_list.index(student)
• grade = grade_list[i]
• course = course_list[i] return
(course, grade)
messy if have a lot of different info to keep track of
must maintain many lists and pass them as arguments
must always index using integers
129. A BETTER AND CLEANER WAY– A
DICTIONARY
nice to index item of interest directly (not always int)
nice to use one data structure, no separate lists
A list A dictionary
Key 1 Val 1
Key 2 Val 2
Key 3 Val 3
Key 4 Val 4
… …
0 Elem 1
1 Elem 2
2 Elem 3
3 Elem 4
… …
12
9
130. A PYTHON DICTIONARY
store pairs of data
• key
• value
my_dict = {}
grades = {'Ana':'B', 'John':'A+', 'Denise':'A', 'Katy':'A'}
Key 1
Key 2
Key 3
…
Val 1
Val 2
Val 3
…
key1 val1 key2 val2 key3 val3 key4 val4
'Ana' 'B'
'Denise' 'A'
'John' 'A+'
'Katy' 'A'
13
0
131. 'Ana' 'B'
'Denise' 'A'
'John' 'A+'
'Katy' 'A'
13
1
DICTIONARY LOOKUP
similar to indexing into a list
looks up the key
returns the value associated
with the key
if key isn’t found, get an error
grades = {'Ana':'B', 'John':'A+', 'Denise':'A', 'Katy':'A'}
grades['John']
grades['Sylvan']
evaluates to 'A+'
gives a KeyError
132. DICTIONAR
Y
OPERATION
S
'Ana' 'B'
'Denise' 'A'
'John' 'A+'
'Katy' 'A'
'Sylvan' 'A'
13
2
grades = {'Ana':'B', 'John':'A+', 'Denise':'A', 'Katy':'A'}
add an entry
grades['Sylvan'] = 'A'
test if key in dictionary
returns True
returns False
'John' in grades
'Daniel' in grades
delete entry
del(grades['Ana'])
133. DICTIONARY
OPERATIONS
'Ana' 'B'
'Denise' 'A'
'John' 'A+'
'Katy' 'A'
grades = {'Ana':'B', 'John':'A+', 'Denise':'A', 'Katy':'A'}
get an iterable that acts like a tuple of all keys
grades.keys() returns ['Denise','Katy','John','Ana']
get an iterable that acts like a tuple of all values
grades.values() returns ['A', 'A', 'A+', 'B']
13
3
134. DICTIONARY KEYS and VALUES
13
4
values
• any type (immutable and mutable)
• can be duplicates
• dictionary values can be lists, even other dictionaries!
keys
• must be unique
• immutable type (int, float, string, tuple,bool)
• actually need an object that is hashable, but think of as immutable as all
immutable types are hashable
• careful with float type as a key
no order to keys or values!
d = {4:{1:0}, (1,3):"twelve",
'const':[3.14,2.7,8.44]}
135. list vs dict
ordered sequence of
elements
look up elements by an
integer index
indices have an order
index is an integer
matches “keys” to
“values”
look up one item by
another item
no order is guaranteed
key can be any
immutable type
136. EXAMPLE: 3 FUNCTIONS TO ANALYZE
SONG LYRICS
1) create a frequency dictionary mapping str:int
2) find word that occurs the most and how many times
• use a list, in case there is more than one word
• return a tuple (list,int) for (words_list, highest_freq)
3) find the words that occur at least X times
• let user choose “at least X times”, so allow as parameter
• return a list of tuples, each tuple is a (list, int)
containing the list of words ordered by their frequency
• IDEA: From song dictionary, find most frequent word. Delete
most common word. Repeat. It works because you are
mutating the song dictionary.
138. USING THE DICTIONARY
def most_common_words(freqs):
values = freqs.values()
best = max(values)
words = []
for k in freqs:
if freqs[k] == best:
words.append(k)
return (words, best)
139. LEVERAGING DICTIONARY PROPERTIES
def words_often(freqs, minTimes):
result = []
done = False
while not done:
temp = most_common_words(freqs)
if temp[1] >= minTimes:
result.append(temp)
for w in temp[0]:
del(freqs[w])
else:
done = True
return result
print(words_often(beatles, 5))
140. FIBONACCI RECURSIVE CODE
def fib(n):
if n == 1:
return 1
elif n == 2:
return 2
else:
return fib(n-1) + fib(n-2)
two base cases
calls itself twice
this code is inefficient
141. INEFFICIENT FIBONACCI
recalculating the same values many times!
could keep track of already calculated values
fib(n) = fib(n-1) + fib(n-2)
fib(5)
fib(4) fib(3)
fib(3) fib(2) fib(1)
fib(2) fib(1)
fib(2)
142. FIBONACCI WITH A DICTIONARY
• def fib_efficient(n, d): if n
in d:
• return d[n] else:
• ans = fib_efficient(n-1, d) + fib_efficient(n-2, d) d[n] =
ans
• return ans
• d = {1:1, 2:2}
• print(fib_efficient(6, d))
do a lookup first in case already calculated the value
143. EFFICIENCY GAINS
Calling fib(34) results in 11,405,773 recursive calls to
the procedure
Calling fib_efficient(34) results in 65 recursive calls to
the procedure
Using dictionaries to capture intermediate results can
be very efficient
But note that this only works for procedures without
side effects (i.e., the procedure will always produce the
same result for a specific argument independent of any
other computations between calls)