This document provides an introduction and overview of the Python programming language. It discusses Python's features such as being simple, easy to learn, free and open source, portable, and having batteries included. It also covers installing Python, writing a simple "Hello World" program, using variables and data types, operators, control flow statements, functions, and various Python data structures like lists, tuples, and dictionaries. The document is intended to teach beginners the basics of Python.
Introduction to python -easiest way to understand python for beginners
What is Python…?
Differences between programming and scripting language
Programming Paradigms
History of Python
Scope of Python
Why do people use Python?
Installing Python
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.
Introduction to python -easiest way to understand python for beginners
What is Python…?
Differences between programming and scripting language
Programming Paradigms
History of Python
Scope of Python
Why do people use Python?
Installing Python
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.
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
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.
Learn Python Programming | Python Programming - Step by Step | Python for Beg...Edureka!
( Python Training : https://www.edureka.co/python )
This Edureka “Python Programming" introduces you to Python by giving you enough reasons to learn it. It will then take you to its various fundamentals along with a practical demonstrating the various libraries such as Numpy, Pandas, Matplotlib and Seaborn. This video helps you to learn the below topics:
1. Why should you go for Python?
2. Introduction to Python Programming Language
3. How to work with Jupyter?
4. Python Programming Fundamentals: Operators & Data Types
5. Libraries: Numpy, Pandas, Matplotlib, Seaborn
Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed.
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++".
Python is a popular programming language used in a variety of applications, including data analysis, web development, and artificial intelligence. Here's an introduction to the Basics of Python - A Beginners Guide! Whether you're new to programming or looking to brush up on your skills, this video covers the basics of Python programming language. From data types and operators to loops, functions and libraries, you'll get a solid foundation to start coding in Python.
Visit us: https://www.elewayte.com/
this presentation will walk you through basic introduction to python, major features of python, how python runs on our system and some important commands used in python.
This Presentation Helps for the beginners to understand easily Python Programming Language, because i had given an snapshot of each concepts. Those who are knowing C,C++ and Java they can easily understand my presentation.
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
1. Python Presented By: Rajesh Kumar Guided By: Mr. Jaishankar Bhatt
2. Content Python Introduction Python Code Execution Python Comments & Indentation Variables Data Types Strings Collections (Arrays)
3. Python Introduction What is Python? Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum Released in 1991
4. Python Code Execution Source code extension is .py Byte code extension is .pyc (compiled python code) Python’s runtime execution model:
5. Comments •Creating a Comment: Ex: Comments starts with a # Output:
6. Comments •Multi Line Comments: Ex: or:
7. Python Indentation •Indentation refers to the spaces at the beginning of a code line. Ex1: Ex2:
8. Variables •Variables are containers for storing data values. Ex:
9. Data Types •Built-in Data Types
10. Getting the Data Type •You can get the data type of any object by using the type() method. Ex: Print the data type of the variable x: Output:
11. Setting the Data Type •In Python, the data type is set when you assign a value to a variable:
12. Strings •String literals in python are surrounded by either single quotation marks, or double quotation marks. •'hello' is the same as "hello". Ex:
13. Multiline Strings •You can assign a multiline string to a variable by using three quotes Ex: Output:
14. Slicing •You can return a range of characters by using the slice syntax. Ex:Get the characters from position 2 to position 5. Output:
15. String Methods Method Description len() Returns the length of a string. lower() Returns the string in lower case. upper() Returns the string in upper case. count() Returns the number of times a specified value appears in the string.
16. Collections (Arrays) •There are four collection data types in the Python programming language. Types: 1. List 2. Tuple 3. Set 4. Dictionary
17. Python Lists •A list is a collection which is ordered and changeable. In Python lists are written with square brackets. Ex: Create a List: Output:
18. Python Tuples •A tuple is a collection which is ordered and unchangeable. In Python tuples are written with round brackets. Ex: Create a Tuple: Output:
19. Python Sets •A set is a collection which is unordered and unindexed. In Python sets are written with curly brackets. Ex: Create a Set:
20. Python Dictionaries •A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets. Ex: Create a Dictionary:
21. Conclusion Python is a great option, whether you are a beginning programmer looking to learn the basics, an experienced programmer designing a large application, or anywhere in between. The basics of Python are easily grasped, and yet its capabilities are vast.
22. Reference https://www.udemy.com/course/learn- programming-with-python https://www.w3schools.com/python/default.asp
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
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.
Learn Python Programming | Python Programming - Step by Step | Python for Beg...Edureka!
( Python Training : https://www.edureka.co/python )
This Edureka “Python Programming" introduces you to Python by giving you enough reasons to learn it. It will then take you to its various fundamentals along with a practical demonstrating the various libraries such as Numpy, Pandas, Matplotlib and Seaborn. This video helps you to learn the below topics:
1. Why should you go for Python?
2. Introduction to Python Programming Language
3. How to work with Jupyter?
4. Python Programming Fundamentals: Operators & Data Types
5. Libraries: Numpy, Pandas, Matplotlib, Seaborn
Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed.
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++".
Python is a popular programming language used in a variety of applications, including data analysis, web development, and artificial intelligence. Here's an introduction to the Basics of Python - A Beginners Guide! Whether you're new to programming or looking to brush up on your skills, this video covers the basics of Python programming language. From data types and operators to loops, functions and libraries, you'll get a solid foundation to start coding in Python.
Visit us: https://www.elewayte.com/
this presentation will walk you through basic introduction to python, major features of python, how python runs on our system and some important commands used in python.
This Presentation Helps for the beginners to understand easily Python Programming Language, because i had given an snapshot of each concepts. Those who are knowing C,C++ and Java they can easily understand my presentation.
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
1. Python Presented By: Rajesh Kumar Guided By: Mr. Jaishankar Bhatt
2. Content Python Introduction Python Code Execution Python Comments & Indentation Variables Data Types Strings Collections (Arrays)
3. Python Introduction What is Python? Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum Released in 1991
4. Python Code Execution Source code extension is .py Byte code extension is .pyc (compiled python code) Python’s runtime execution model:
5. Comments •Creating a Comment: Ex: Comments starts with a # Output:
6. Comments •Multi Line Comments: Ex: or:
7. Python Indentation •Indentation refers to the spaces at the beginning of a code line. Ex1: Ex2:
8. Variables •Variables are containers for storing data values. Ex:
9. Data Types •Built-in Data Types
10. Getting the Data Type •You can get the data type of any object by using the type() method. Ex: Print the data type of the variable x: Output:
11. Setting the Data Type •In Python, the data type is set when you assign a value to a variable:
12. Strings •String literals in python are surrounded by either single quotation marks, or double quotation marks. •'hello' is the same as "hello". Ex:
13. Multiline Strings •You can assign a multiline string to a variable by using three quotes Ex: Output:
14. Slicing •You can return a range of characters by using the slice syntax. Ex:Get the characters from position 2 to position 5. Output:
15. String Methods Method Description len() Returns the length of a string. lower() Returns the string in lower case. upper() Returns the string in upper case. count() Returns the number of times a specified value appears in the string.
16. Collections (Arrays) •There are four collection data types in the Python programming language. Types: 1. List 2. Tuple 3. Set 4. Dictionary
17. Python Lists •A list is a collection which is ordered and changeable. In Python lists are written with square brackets. Ex: Create a List: Output:
18. Python Tuples •A tuple is a collection which is ordered and unchangeable. In Python tuples are written with round brackets. Ex: Create a Tuple: Output:
19. Python Sets •A set is a collection which is unordered and unindexed. In Python sets are written with curly brackets. Ex: Create a Set:
20. Python Dictionaries •A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets. Ex: Create a Dictionary:
21. Conclusion Python is a great option, whether you are a beginning programmer looking to learn the basics, an experienced programmer designing a large application, or anywhere in between. The basics of Python are easily grasped, and yet its capabilities are vast.
22. Reference https://www.udemy.com/course/learn- programming-with-python https://www.w3schools.com/python/default.asp
GraphQL is an application layer query language from Facebook. With GraphQL, you can define your backend as a well-defined graph-based schema. Then client applications can query your dataset as they are needed. GraphQL’s power comes from a simple idea — instead of defining the structure of responses on the server, the flexibility is given to the client. Will GraphQL do to REST what REST did to SOAP?
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.
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.
Python Session - 2
Install Python
Run Python
Python Keyword
Python Identifiers
Python Variables
Python Literals
Python Comments
By default Python installed on following path in Windows
C:\Users\user\AppData\Local\Programs\Python\Python37
Removing the MAX_PATH Limitation :
Windows historically has limited path lengths to 260 characters. This meant that paths longer than this would not resolve and errors would result.
In the latest versions of Windows, this limitation can be expanded to approximately 32,000 characters. Your administrator will need to activate the “Enable Win32 long paths” group policy, or set the registry value HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem@LongPathsEnabled to 1.
Top Most Python Interview Questions.pdfDatacademy.ai
Python is higher level language ,now most of the technologies used this language . Interview purpose written for the top most python interview questions to the article or document .this article read & gain more knowledge to the python and crack the interview - Congratulation's
From
Datacademy Team
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
Introduction to python, interpreter vs compiler. Concepts like object oriented programming, functions, lists, control flow etc. Also concept of dictionary and nested lists.
A for loop is probably the most common type of loop in Python. A for loop will select items from any iterable. In Python an iterable is any container (list, tuple, set, dictionary), as well as many other important objects such as generator function, generator expressions, the results of builtin functions such as filter, map, range and many other items.
Similar to Let’s Learn Python An introduction to Python (20)
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
The field of Information retrieval (IR) is currently undergoing a transformative shift, at least partly due to the emerging applications of generative AI to information access. In this talk, we will deliberate on the sociotechnical implications of generative AI for information access. We will argue that there is both a critical necessity and an exciting opportunity for the IR community to re-center our research agendas on societal needs while dismantling the artificial separation between the work on fairness, accountability, transparency, and ethics in IR and the rest of IR research. Instead of adopting a reactionary strategy of trying to mitigate potential social harms from emerging technologies, the community should aim to proactively set the research agenda for the kinds of systems we should build inspired by diverse explicitly stated sociotechnical imaginaries. The sociotechnical imaginaries that underpin the design and development of information access technologies needs to be explicitly articulated, and we need to develop theories of change in context of these diverse perspectives. Our guiding future imaginaries must be informed by other academic fields, such as democratic theory and critical theory, and should be co-developed with social science scholars, legal scholars, civil rights and social justice activists, and artists, among others.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Let’s Learn Python An introduction to Python
1. Let’s Learn Python
An introduction to Python
Jaganadh G
Project Lead NLP R&D
365Media Pvt. Ltd.
jaganadhg@gmail.com
KiTE, Coimbatore
19 July 2011
Jaganadh G Let’s Learn Python
2. Just a word about me !!
Working in Natural Language Processing (NLP), Machine
Learning, Data Mining
Passionate about Free and Open source :-)
When gets free time teaches Python and blogs at
http://jaganadhg.freeflux.net/blog reviews books for
Packt Publishers.
Works for 365Media Pvt. Ltd. Coimbatore India.
Member of Indian Python Software Society
Jaganadh G Let’s Learn Python
3. Python
Python is an easy to learn, powerful programming
language.
It has efficient high-level data structures and a simple but
effective approach to object-oriented programming.
Elegant syntax
Dynamic typing
Interpreted
Ideal for scripting and rapid application development
Developed by Guido Van Rossum
Free and Open Source
Jaganadh G Let’s Learn Python
4. Features of Python
Simple
1 Python is a simple and minimalist language
2 Reading a good Python program feels almost like
reading English
Easy to Learn
1 Python is extremely easy to get started with
2 Python has an extraordinarily simple syntax
Free and Open Source
High-level Language
Portable, You can use Python on
1 Linux
2 Microsoft Windows
3 Macintosh
4 ...........
Jaganadh G Let’s Learn Python
5. Features of Python
Interpreted
Object Oriented
Extensible
Embeddable
Batteries included
Jaganadh G Let’s Learn Python
6. Installing Python
If you are using a Linux distribution such as Fedora or
Ubuntu then you probably already have Python installed
on your system.
To test it open a shell program like gnome-terminal or
konsole and enter the command python -V
If you are using windows - go to
http://www.python.org/download/releases/2.7/ and
download
http://www.python.org/ftp/python/2.7/python-2.7.msi.
Then double click and install it.
You may need to set PATH variable in Environment
Settings
Jaganadh G Let’s Learn Python
7. Hello world !!!
Lets write a ”Hello world!!” program
Fire-up the terminal and invoke Python interpreter
Type print ”Hello World !!! ”
Jaganadh G Let’s Learn Python
8. Hello world !!!
#!/usr/bin/env python
#Just a Hello World !! program
print "Hello World!!"
You can write the code in you favorite editor, save and
run it.
Extension for the filename should be .py
Save it as hello.py and make it as executable !
#chmod +x hello.py
Run the program #python hello.py
Jaganadh G Let’s Learn Python
9. Using the Python Interpreter
The Python iterpreter can be used as a calculator !!
Jaganadh G Let’s Learn Python
10. Keywords
The following are keywords or reserved words in Python
These words can’t be used as variable names or function
names or class names
and del for is raise assert elif from lambda return break else
global not try class except if or while continue exec import
pass yield def finally in print
Jaganadh G Let’s Learn Python
11. Variables
age = 32
year = 1997
avg = 12.5
Note:
There is no need to specify the type as like in C or Java
Jaganadh G Let’s Learn Python
12. String
name = ”jagan”
anname = ’jagan’
annname = ”””jagan”””
Note:
There is no need to specify the type as like in C or Java
Jaganadh G Let’s Learn Python
13. Identifier Naming
Identifiers
Identifiers are names given to identify something.
Rules to follow for naming identifiers
1 The first character of the identifier must be a letter of
the alphabet (upper or lowercase) or an underscore (’ ’).
2 The rest of the identifier name can consist of letters
(upper or lowercase), underscores (’ ’) or digits (0-9).
3 Identifier names are case-sensitive. For example,
myname andmyName are not the same. Note the
lowercase n in the former and the uppercaseN in te
latter.
4 Examples of valid identifier names arei, my name,
name 23 and a1b c3 .
5 Examples of invalid identifier names are 2things, this is
spaced out and my-name.
Jaganadh G Let’s Learn Python
14. Operators
+ Plus
- Minus
/ divide
* Multiply
** Power
// Floor Division
% Modulo
< Less than
> Greater than
<= Less than or equal to
>= Greater than equal to
== Equal to
Jaganadh G Let’s Learn Python
15. Basic Math
!= Not equal to
not Boolian NOT
and Boolian AND
or Boolian OR
& Bitwise AND
Note:
Operator precedence is as same as of other programming
languages
Jaganadh G Let’s Learn Python
16. Data Structure: List
A list is a data structure that holds an ordered collection
of items
fruits = [’apple’,’banana’,’orange’]
marks = [12,15,17]
avgs = [1.5, 4.5,7.8]
avgm = [1.5, 4.5,7.8,avgs]
lists are mutable
elemnts can be accessed by index numbers
either positive index or negative index can be used to
access elements
Jaganadh G Let’s Learn Python
17. Data Structure: List
elemnts can be accessed by index numbers
fruits[0]
elements can be accessed with positive or negative index
avgs[-1]
new elements can be appended to a list
fruits.append(’cherry’)
list can be sorted or reversed
fruits.sort()
fruits.reverse()
length of a list can be identified by the ’len’ function
len(fruits)
Jaganadh G Let’s Learn Python
18. Data Structure: List
elements can be deleted del fruits[0]
list can be sliced new list = fruits[1:3]
lists can be extended
flowers = [’rose’,’lilly’,’tulip’]
fruits.extend(flowers)
the index method can be used to find index of an item in
a list
fruits.index(’apple’)
Jaganadh G Let’s Learn Python
19. Data Structure: List
The pop method removes an element from a list
fruits.pop()
The remove method is used to remove the first
occurrence of a value:
flowers = [’rose’,’lilly’,’tulip’,’rose’]
flowers.remove(’rose’)
The reverse method reverses the elements in the list.
flowers.reverse()
The sort method is used to sort lists in place
flowers.sort()
Jaganadh G Let’s Learn Python
20. Data Structure: List
>>> numbers = [5, 2, 9, 7]
>>> numbers.sort(cmp)
>>> numbers
[2, 5, 7, 9]
>>> x = [’aardvark’, ’abalone’, ’acme’,
’add’, ’aerate’]
>>> x.sort(key=len)
>>> x
[’add’, ’acme’, ’aerate’, ’abalone’, ’aardvark’]
>>> x = [4, 6, 2, 1, 7, 9]
>>> x.sort(reverse=True)
Jaganadh G Let’s Learn Python
21. Data Structure: Tuple
Tuples are sequences like lists .
The only difference is that tuples are immutable
Values in a tuple are enclosed in parentheses (())
mytuple = (2,3,4,5,6,7,8)
Elements in a tuple can be accessed by index value
It is not possible to sort or reverse tuple
Jaganadh G Let’s Learn Python
22. Data Structure: Tuple
There is a way to sort and reverse tuple
atuple = (9,6,4,8,3,7,2)
sortuple = tuple(sorted(atuple))
revtuple = tuple((reversed(atuple))
Note:
A tuple can be converted to list and vice versa
tup = (1,2,3)
li = list(tup)
atup = tuple(li)
Jaganadh G Let’s Learn Python
23. Data Structure: Dictionary
Another useful data type built into Python is the
dictionary
Dictionaries are sometimes found in other languages as
associative memories or associative arrays.
Dictionaries consist of pairs (called items) of keys and
their corresponding values
phonebook = {’Alice’: ’2341’, ’Beth’: ’9102’,
’Cecil’: ’3258’}
phonebook[’Alice’] #’2341’
Jaganadh G Let’s Learn Python
24. Basic Dictionary Operations
len(d) returns the number of items (key-value pairs) in d
d = {’Alice’: ’2341’, ’Beth’: ’9102’, ’Cecil’: ’325
len(d)
3
d[’Alice’] returns the value associated with the key k ie
”2341”
d[’Alice’] = ’456’ associates the value ’456’ with the key
’Alice’
del d[’Alice’] deletes the item with key ’Alice’
’Alice’ in d checks whether there is an item in d that has
the key ’Alice’
Jaganadh G Let’s Learn Python
25. Data Structure: Dictionary
Key types: Dictionary keys dont have to be integers
(though they may be). They may be any immutable type,
such as floating-point (real) numbers, strings, or tuples.
Automatic addition: You can assign a value to a key, even
if that key isnt in the dictionary to begin with; in that
case, a new item will be created. You cannot assign a
value to an index outside the lists range (without using
append or something like that).
phonebook[’Ravi’] = ’567’
Membership: The expression k in d (where d is a
dictionary) looks for a key, not a value.
’Alice’ in phonebook
Jaganadh G Let’s Learn Python
26. Data Structure: Dictionary
All the keys in a dictionary can be accessed as a list
phonebook.keys()
[’Beth’, ’Alice’, ’Cecil’]
All the values in a dictionary can be accessed as a list
phonebook.values()
[’9102’, ’2341’, ’3258’]
The keys and values in a dictionary can be accessed as a
list of tuples
phonebook.items()
[(’Beth’, ’9102’), (’Alice’, ’2341’),
(’Cecil’, ’3258’)]
Jaganadh G Let’s Learn Python
27. Control Flow:The if statement
The if statement is used to check a condition and if the
condition is true, we run a block of statements (called the
if-block), else we process another block of statements (called
the else-block). The else clause is optional.
if <test1>: #if test
<statement1> #associated block
elif <test2>: # Optional else if (elif)
<statement2>
else: #optional else
<statement3>
Jaganadh G Let’s Learn Python
28. Control Flow:The if statement
name = raw_input(""Enter your name: "")
if name == "trisha":
print "Hi trisha have you seen my chitti"
elif name == "aishwarya":
print "Hai Aishu have u seen my chitti"
else:
print "Oh!! my chitti !!!!"
Jaganadh G Let’s Learn Python
29. Control Flow:The while statement
The while statement allows you to repeatedly execute a block
of statements as long as a condition is true. A while statement
is an example of what is called a looping statement. A while
statement can have an optional else clause.The structure of
while loop is
while <test>:
<statement>
else:
<statement>
Jaganadh G Let’s Learn Python
30. Control Flow:The while statement
#!/usr/bin/python
a = 0
b = 10
while a < b:
print a
a += 1
#0123456789
Jaganadh G Let’s Learn Python
31. Control Flow:The for loop
The for..in statement is another looping statement which
iterates over a sequence of objects i.e. go through each item
in a sequence.
for <target> in <object>:
<statement>
else:
statement
Jaganadh G Let’s Learn Python
32. Control Flow:The for loop
#!/usr/bin/python
names = [’Jaganadh’,’Biju’,’Sreejith’,
’Kenneth’,’Sundaram’]
for name in names:
print "Hello %s" %name
Jaganadh G Let’s Learn Python
33. Control Flow:The for loop
#!/usr/bin/python
for i in range(1, 5):
print i
else:
print ’The for loop is over’
Jaganadh G Let’s Learn Python
34. Control Flow: The break,continue and pass
statement
The break statement is used to break out of a loop statement
i.e. stop the execution of a looping state-ment, even if the
loop condition has not become False or the sequence of items
has been completely iterated over.
while <test1>:
<statement>
if <test1>:break
else <test2>:continue
else:
<statement>
Jaganadh G Let’s Learn Python
35. Control Flow: continue
#Example for continue
x = 10
while x:
x = x -1
if x % 2 != 0: continue
print x
Jaganadh G Let’s Learn Python
36. Control Flow:break
#Example for break
while True:
s = raw_input(’Enter something : ’)
if s == ’quit’:
break
print ’Length of the string is’, len(s)
print ’Done’
Jaganadh G Let’s Learn Python
37. Control Flow:pass
#Example for pass
while 1:
pass
Jaganadh G Let’s Learn Python
38. Functions
Functions are reusable pieces of programs. They allow you to
give a name to a block of statements and you can run that
block using that name anywhere in your program and any
number of times. This is known as calling the function.
Defining Functions
def <name>(arg1,arg2,...argN):
<statement>
#!/usr/bin/python
# Filename: function1.py
def sayHello():
print ’Hello World!’
# End of function
sayHello() # call the function
Jaganadh G Let’s Learn Python
39. Functions with parameters
A function can take parameters which are just values you
supply to the function so that the function can do something
utilising those values.
#!/usr/bin/python
# Filename: func_param.py
def printMax(a, b):
if a > b:
print a, ’is maximum’
else:
print b, ’is maximum’
printMax(3, 4) # directly give literal values
x = 5
y = 7
printMax(x, y)
Jaganadh G Let’s Learn Python
40. Functions: Using Keyword Arguments
#!/usr/bin/python
# Filename: func_key.py
def func(a, b=5, c=10):
print ’a is’, a, ’and b is’, b, ’and c is’, c
func(3, 7)
func(25, c=24)
func(c=50, a=100)
Jaganadh G Let’s Learn Python
41. Functions: Return Statement
#!/usr/bin/python
# Filename: func_return.py
def maximum(x, y):
if x > y:
return x
else:
return y
print maximum(2, 3)
Jaganadh G Let’s Learn Python
42. Functions: Arbitrary Arguments
def minimum(*args):
res = args[0]
for arg in args[1:]:
if arg < res:
res = arg
return res
print minimum(3,4,1,2,5)
Jaganadh G Let’s Learn Python
44. Object Oriented Programming
#!/usr/bin/python
# Filename: simplestclass.py
class Person:
pass # An empty block
p = Person()
print p
Jaganadh G Let’s Learn Python
45. Object Oriented Programming:Using Object
Methods
Class/objects can have methods just like functions except that
we have an extra self variable.
class Person:
def sayHi(self):
print ’Hello, how are you?’
p = Person()
p.sayHi()
Jaganadh G Let’s Learn Python
46. Object Oriented Programming:The init
method
The init method is run as soon as an object of a class is
instantiated. The method is useful to do any initialization you
want to do with your object. Notice the double underscore
both in the beginning and at the end in the name.
#!/usr/bin/python
# Filename: class_init.py
class Person:
def __init__(self, name):
self.name = name
def sayHi(self):
print ’Hello, my name is’, self.name
p = Person(’Jaganadh G’)
p.sayHi()
Jaganadh G Let’s Learn Python
47. Object Oriented Programming:Class and
Object Variables
There are two types of fields - class variables and object
variables which are classified depending on whether the class
or the object owns the variables respectively.
Class variables are shared in the sense that they are accessed
by all objects (instances) of that class.There is only copy of
the class variable and when any one object makes a change to
a class variable, the change is reflected in all the other
instances as well.
Object variables are owned by each individual object/instance
of the class. In this case, each object has its own copy of the
field i.e. they are not shared and are not related in any way to
the field by the samen name in a different instance of the
same class.
Jaganadh G Let’s Learn Python
48. Object Oriented Programming:Class and
Object Variables
#!/usr/bin/python
# Filename: objvar.py
class Person:
’’’Represents a person.’’’
population = 0
def __init__(self, name):
’’’Initializes the person’s data.’’’
self.name = name
print ’(Initializing %s)’ % self.name
Person.population += 1
Jaganadh G Let’s Learn Python
49. Object Oriented Programming:Class and
Object Variables
def __del__(self):
’’’I am dying.’’’
print ’%s says bye.’ % self.name
Person.population -= 1
if Person.population == 0:
print ’I am the last one.’
else:
print ’There are still %d people left.’
% Person.population
def sayHi(self):
’’’Greeting by the person.
Really, that’s all it does.’’’
print ’Hi, my name is %s.’ % self.name
Jaganadh G Let’s Learn Python
50. Object Oriented Programming:Class and
Object Variables
def howMany(self):
’’’Prints the current population.’’’
if Person.population == 1:
print ’I am the only person here.’
else:
print ’We have %d persons here.’
% Person.population
swaroop = Person(’Swaroop’)
swaroop.sayHi()
swaroop.howMany()
kalam = Person(’Abdul Kalam’)
kalam.sayHi()
kalam.howMany()
Jaganadh G Let’s Learn Python
51. Object Oriented Programming: Inheritance
#!/usr/bin/python
# Filename: inherit.py
class SchoolMember:
’’’Represents any school member.’’’
def __init__(self, name, age):
self.name = name
self.age = age
print ’(Initialized SchoolMember: %s)’
% self.name
def tell(self):
’’’Tell my details.’’’
print ’Name:"%s" Age:"%s"’ % (self.name,
self.age),
Jaganadh G Let’s Learn Python
53. Object Oriented Programming: Inheritance
class Student(SchoolMember):
’’’Represents a student.’’’
def __init__(self, name, age, marks):
SchoolMember.__init__(self, name, age)
self.marks = marks
print ’(Initialized Student: %s)’ % self.name
def tell(self):
SchoolMember.tell(self)
print ’Marks: "%d"’ % self.marks
t = Teacher(’Mrs. Shrividya’, 40, 30000)
s = Student(’Swaroop’, 22, 75)
members = [t, s]
for member in members:
member.tell()
Jaganadh G Let’s Learn Python
54. Modules
A module is basically a file containing all your functions and
variables that you have defined. To reuse the module in other
programs, the filename of the module must have a .py
extension.
By using the import statement you can use built-in modules in
Python
import sys , os
sys.argv[1]
os.name
os.curdir
import math
math.sqrt(9)
Jaganadh G Let’s Learn Python
56. I/O Operations
with open(help.txt, r) as f:
read_data = f.read()
#file writing
out = open(’out.txt’,’w’)
out.write("Hello out file")
out.close()
Jaganadh G Let’s Learn Python
57. Handling Exceptions
while True:
try:
x = int(raw_input("Please enter a number: "))
break
except ValueError:
print "Oops! That was no valid number.Try again"
Jaganadh G Let’s Learn Python
58. Handling Exceptions
import sys
try:
f = open(myfile.txt)
s = f.readline()
i = int(s.strip())
except IOError as (errno, strerror):
print "I/O error({0}): {1}".format(errno, strerror)
except ValueError:
print "Could not convert data to an integer."
except:
print "Unexpected error:", sys.exc_info()[0]
raise
Jaganadh G Let’s Learn Python