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.
Provides an introductory level understanding of the Python Programming Language and language features. Serves as a guide for beginners and a reference to Python basics and language use cases.
This 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
Provides an introductory level understanding of the Python Programming Language and language features. Serves as a guide for beginners and a reference to Python basics and language use cases.
This 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
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 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
Youtube Link: https://youtu.be/woVJ4N5nl_s
** Python Certification Training: https://www.edureka.co/data-science-python-certification-course **
This Edureka PPT on 'Python Basics' will help you understand what exactly makes Python special and covers all the basics of Python programming along with examples.
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
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 Tutorial | Python Tutorial for Beginners | Python Training | EdurekaEdureka!
This Edureka Python tutorial will help you in understanding the various fundamentals of Python programming with examples in detail. This Python tutorial helps you to learn following topics:
1. Introduction to Python
2. Who uses Python
3. Features of Python
4. Operators in Python
5. Datatypes in Python
6. Flow Control
7. Functions in Python
8. File Handling in Python
All data values in Python are encapsulated in relevant object classes. Everything in Python is an object and every object has an identity, a type, and a value. Like another object-oriented language such as Java or C++, there are several data types which are built into Python. Extension modules which are written in C, Java, or other languages can define additional types.
To determine a variable's type in Python you can use the type() function. The value of some objects can be changed. Objects whose value can be changed are called mutable and objects whose value is unchangeable (once they are created) are called immutable.
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 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 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
Youtube Link: https://youtu.be/woVJ4N5nl_s
** Python Certification Training: https://www.edureka.co/data-science-python-certification-course **
This Edureka PPT on 'Python Basics' will help you understand what exactly makes Python special and covers all the basics of Python programming along with examples.
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
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 Tutorial | Python Tutorial for Beginners | Python Training | EdurekaEdureka!
This Edureka Python tutorial will help you in understanding the various fundamentals of Python programming with examples in detail. This Python tutorial helps you to learn following topics:
1. Introduction to Python
2. Who uses Python
3. Features of Python
4. Operators in Python
5. Datatypes in Python
6. Flow Control
7. Functions in Python
8. File Handling in Python
All data values in Python are encapsulated in relevant object classes. Everything in Python is an object and every object has an identity, a type, and a value. Like another object-oriented language such as Java or C++, there are several data types which are built into Python. Extension modules which are written in C, Java, or other languages can define additional types.
To determine a variable's type in Python you can use the type() function. The value of some objects can be changed. Objects whose value can be changed are called mutable and objects whose value is unchangeable (once they are created) are called immutable.
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
ZENUS INFOTECH is best Python Training institute in Roorkee and an ISO 9001:2008 Certified Engineer’s Training Company in Roorkee & provides training to the B.E./B.TECH/DIPLOMA/MCA/BCA and related field students in 35+ cutting-edge technologies like AutoCAD, Solid-Works, CATIA, REVIT, Pro-E, UG-NX .NET, JAVA, PHP, GST Tally and Wireless & Telecommunication and many more.
First in the series of slides for python programming, covering topics like programming language, python programming constructs, loops and control statements.
python programming language Python is a high-level, interpreted, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. INTRODUCTION
HISTORY
USES OF PYTHON
FEATURES OF PYTHON
PYTHON PROJECT FOR BEGINNERS
PYTHON PROGRAM
KEY CHANGES IN PYTHON
BASIC SYNTAX
VARIABLE
NUMBERS
STANDARD TYPE HIERARCHY
STRING
CONDITIONALS
FOR LOOP
FUNCTION
KEYWORDS
WHY PYTHON ?
DIFFERENTIATE
EXAMPLES
Kosmik is the best institute for Python training in Hyderabad Kukatpally/KPHB. kosmik provides lab facilities with complete real-time training with live sessions
call now: +91-8712186898, +91-8179496603, +91-6309565721
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
This has been presented in association with Robosepians for Java concepts. Basic concepts of Java including features, conditional statements, loop statements, arrays, string, primitive datatypes, essentials of Java including oops concepts, classes, objects, polymorphism, advance topics including packages, exception handling, multihtreading and network programming have been discussed.
Introduction to Active Server Pages (ASP)
ASP.NET
Java Server Pages (JSP), JSP Processing
JSP Life Cycle, JSP Application Design
Tomcat Server, JSP Components: Scriptlets, Directives
JSP Actions
JSP Implicit Objects, Sharing Data between JSP Pages
Session Tracking
JSP Error Handling and Debugging
COM/DCOM
Introduction to HTML, HTML Basic Tags
HTML Images, Links, Style
HTML Tables, HTML Lists
HTML Frames, HTML Forms
XML, XML Documents
CSS
DTD
XML Schema
XML Parsers
Introduction to WWW, History of Web
Protocols governing web
Cyber Crime
Cyber Laws
IT Act 2000
Web Development Strategies, Planning and Development
Web Applications
Web Development Process
Web Team
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
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.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
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.
2. Who all can learn?
Beginners who have never programmed
Programmers coming from another language
3. Python-An Introduction
General-purpose interpreted, interactive, object-oriented, high-level
programming language.
Started in 1989 and published in 1991 by Guido Van Rossum.
First version was released as Python 1.0 in 1994
ABC programming language is said to be the predecessor of Python
Influenced by ABC language and Modula-3
6. Python-Application Areas
Web Applications Django, Pyramid, Flask frameworks
Desktop GUI applications wxWidgets, Kivy etc. toolkits.
Software Development
Scientific and Numeric SciPy, Panda etc.
Business Applications Tryton ERP (application)
Console Based applications
Audio or Video Based applications Timplayer, cPlay etc. (applications)
3D CAD applications Fandango
Enterprise applications OpenErp, Picalo etc.
Application for Images Vpython, Gogh etc.
Google,
Youtube,
Dropbox,
Quora, Spotify,
Instagram etc.
7. Python-Resources
https://www.python.org/
Documentation, tutorials, beginners guide …
Other Resources:
Learning Python by Mark Lutz
Python Essential Reference by David Beazley
Python Cookbook, ed. by Martelli, Ravenscroft and Ascher
http://wiki.python.org/moin/PythonBooks
8. Python v/s Jython v/s IronPython
Python or CPython is written in C/C++. It is most commonly used
python by developers.
Jython is written in Java and runs on JVM. So, a developer can write a
plugin for Java application using it.
IronPython or IPython is written in .NET and runs on CLR (Common
Language Runtime). So, a developer can use .NET libraries.
10. Python-Installation
There are 2 different versions of Python:
Python 2.7.14
Python 3.6.4
Click here: Download Python
Double click on the downloaded .exe file and install.
12. Python-Setting Path
You can set the path for python in your system using below steps:
1. Right Click on My Computer icon and navigate to following path:
Properties Advanced System Settings Environment Variables
2. Under System Variables, search for variable Path and append C:Python27 to
existing value.
14. Python-Variables
A name which is used to refer memory location.
Also known as identifier and used to hold value.
No need to specify type for variable.
Variable name can be a group of letters and digits, but it must start either
with a letter or an underscore.
Recommended to use lower case letters.
15. Python-Variables
Multiple Assignments:
Python allows developers to assign a value to multiple variables in a single
statement.
Assigning Single Value to multiple variables:
x=y=z=100
Assigning Multiple Values to multiple variables:
a, b, c=20, 30, 40
16. Python-Variables
Multiple Assignments:
Python allows developers to assign a value to multiple variables in a single
statement.
Assigning Single Value to multiple variables:
x=y=z=100
Assigning Multiple Values to multiple variables:
a, b, c=20, 30, 40
18. Python-Identifiers
Names given to the fundamental building blocks in a program.
Can be variable, class, list, object, dictionary, function etc.
Rules:
Sequence of letters and numbers.
No special character can be used as an identifier except underscore (_)
Keyword must not be used as identifier.
Python is case sensitive, So using case is significant.
Identifier must start with a letter or underscore (_).
19. Python-Literals
Data given in a variable or constant.
String literals: Can be formed by enclosing a text in either single or double
quotes.
“Ram”, ‘232324’
Single Line String: >>> text1= “Hello”
Multi Line String: >>> text1= ‘Hello
User’
Using triple quotation marks: >>> str= ‘’’ Welcome
to
India’’’
20. Python-Literals
Numeric Literals:
int (signed integers): 100
long (long integers): 3456570L
float (floating point): -25.7
Complex (complex numbers): 3.14j
Boolean Literals:
True or False
Special Literals:
Python contains one special literal: None
Used to specify that field which has not been created.
Also used for end of lists.
24. Python-Operators
Comparison Operators
Operators Description
< Performs less than comparison
> Performs greater than comparison
<= Performs less than equal to comparison
>= Performs greater than equal to comparison
== Performs equal to comparison
!= Performs not equal to comparison
< > Performs not equal to comparison
25. Python-Operators
Assignment Operators
Operators Description
= Simple assignment (right side expression to left side variable)
/= Performs division and then assignment
+= Performs addition and then assignment
-= Performs subtraction and then assignment
*= Performs multiplication and then assignment
%= Performs modulus and then assignment
**= Performs power and then assignment
//= Performs floor division and then assignment
26. Python-Operators
Logical Operators
Operators Description
and Performs Logical AND (both conditions must be true)
or Performs Logical OR (one of the conditions must be true)
not Performs Logical NOT (compliment the condition i.e. reverse)
27. Python-Operators
Identity Operators
Operators Description
is Returns true if identity of two variables are same else false.
is not Returns true if identity of two variables are not same else false.
28. Python-Operators
Bitwise Operators
Operators Description
& Performs bitwise and operation
| Performs bitwise or operation
^ Performs bitwise xor operation
~ Performs bitwise complement operation
<< Performs bitwise left shift operation
>> Performs bitwise right shift operation
29. Python-Comments
Single Line Comments
To put single line comments in code, use # symbol
Multi Line Comments
To put multi line comments in code enclose the comment statements
with triple quotes. ‘’’ Your comment Statements ‘’’
30. Python-Control Statements
Control statements are used to control the structure/flow of your
application program.
An if statement decides whether to execute another statement or not.
A loop statement decides how many times to execute another statement.
31. Python-Control Statements
IF- Statement:
Syntax:
if (condition):
// lines of code
IF-ELSE Statement:
Syntax:
if (condition):
// lines of code
else:
// lines of code
34. Python-Control Statements
FOR Loop Statement:
Syntax:
for <variable> in <sequence>:
// statements
Syntax:
for <variable> in <sequence>:
// statements
else:
//statements
35. Python-Control Statements
WHILE Loop Statement:
Syntax:
while <expression>:
// statements
Syntax:
while <expression>:
// statements
else:
//statements
36. Python-Control Statements
BREAK Statement:
A jump statement use to transfer execution control.
Breaks the current execution
In case of inner loop, terminates inner loop immediately.
Example:
for letter in 'Python2':
if letter == 'o':
break
print (letter)
37. Python-Control Statements
CONTINUE Statement:
A jump statement use to skip execution of current iteration.
After skipping, loop continues with next iteration.
Example:
a=0
while a<=5:
a=a+1
if a%2==0:
continue
print a
print "End of Loop"
38. Python-Control Statements
PASS Statement:
Keyword use to execute nothing.
When developer don’t want to execute code, this can be used to execute
empty.
Example:
for i in [1,2,3,4,5]:
if i==3:
pass
print "Pass when value is",i
print i
41. Python-Numbers
Type Conversion:
Function Description
int(x) Converts x to plain integer
long(x) Converts x to a long integer
float(x) Converts x to a floating-point number
complex(x)
Converts x to a complex number with real part x and imaginary
part zero.
complex(x, y)
Converts x to a complex number with real part x and imaginary
part y.
42. Python-Numbers
Mathematical Functions:
Function Description
abs(x) The absolute value of x (positive)
ceil(x)* The ceiling of x: smallest integer not less than x.
cmp(x, y) -1 if x<y; 0 if x==y; 1 if x>y
floor(x) * The floor of x: largest integer not greater than x.
*import math
max(x1, x2, x3,…) The largest of its arguments.
43. Python-Numbers
Mathematical Functions:
Function Description
min(x1, x2, x3,…) The smallest of its arguments.
pow(x, y) * The value of x**y.
round(x [, n]) Returns x rounded to n digits from the decimal point.
*import math
sqrt(x) * Returns square root of x for x>0
45. Python-Strings
Tricky Operations:
Use ‘+’ to concatenate strings and ‘*’ to replicate a string.
‘Ram’+’ Kumar’ ‘Ram Kumar’
‘Ram’*5‘RamRamRamRamRam’
Use ‘in’ to check whether specified string is substring or not.
str1=‘This is an in example’
str2=‘in’
str2 in str1 True
46. Python-Strings
Tricky Operations:
Use ‘:’ to slice a string.
str1=‘This is an example’
str1[2:3]‘i’ {startIndex (inclusive): endIndex (exclusive)}
str[::-1] {reverse a string}
Use ‘r’ to not interpret characters as special characters prefaced by ‘’.
print ‘D:newPrognewInstruction’
print r‘D:newPrognewInstruction’
47. Python-Strings
Tricky Operations:
Two strings enclosed with quotes will automatically be concatenated.
str1=‘This’ ‘ is’
print str1 This is
Enclose string with ( ) to break long strings.
str1=(‘This is’
‘ an example of’
‘ concatenating strings’)
print str1 This is an example of concatenating strings
48. Python-Strings
Functions:
Function Description
captialize() Capitalize the first character of the string
--count(sub string [, begin] [, end]) Counts no. of times sub string occurs within given start and
end index.
find(sub-string [, begin] [, end]) Returns index value of the string where sub-string found
between begin and end index.
index(sub-string [, begin] [, end]) Works same as find() but throws an exception if sub-string
not found.
isalnum() Returns True if string is alphanumeric and have at least 1
character.
isalpha() Returns True when all the characters are alphabets and
string have at least 1 character.
49. Python-Strings
Functions:
Function Description
isdigit() Returns True when all the characters are digits and string
have at least 1 character.
isupper() Returns True if all the characters of a string are in upper
case.
islower() Returns True if all the characters of a string are in lower
case.
isspace() Returns True if all the characters of a string are white space.
len(string) Returns length of the string.
lower() Converts all the characters of a string to lower case.
upper() Converts all the characters of a string to upper case.
swapcase() Inverts case of all characters in a string.
51. Python-Print Formatting
Print Statements-Strings:
print ‘This string will be printed’
When using variables:
str=‘Print this string’
print ‘I have assigned the string in variable: %s’ %(str)
Print Statement-Floating Point Numbers:
print ‘Floating point Number: %f’ %(12.345)
print ‘Floating point Number: %1.2f’ %(12.345)
print ‘Floating point Number: %20.2f’ %(12.345)
54. Python-Lists
A mutable data structure which is used to store various types of data.
Works as container which holds other objects in a given order.
Can be composed by storing a sequence of different type of values separated by
commas.
Enclosed between square ([ ]) brackets and elements are stored on the index basis
with starting index 0.
Example:
list1=[1,2,3,4]
list2=[‘1’,’2’,’3’,’4’]
list3=[‘1’,2.0,3,4]
55. Python-Lists
Operations on Lists:
Accessing Elements
Elements can be accessed via indexing. e.g. list1[0]
List can be sliced as well to access elements. e.g. list1[2:4]
58. Python-Lists
List Methods:
Method Name Description
append(object) Add an element at the end of the existing list.
pop([index]) If specified, remove the element at the given position in the list
otherwise remove the last element and returns it.
reverse() Reverse the elements of the list, in place.
sort() Sort the elements of the list, in place.
min(list) Returns the minimum value from the list given.
59. Python-Lists
List Methods:
Method Name Description
max(list) Returns the maximum value from the list given.
len(list) Returns the number of elements in the list.
index(object) Returns the index value of the object.
insert(index, object) Insert an object at given position
remove(object) Remove the first object from the list, if not found throws an error.
60. Python-Lists Comprehension
List Comprehension allows to build out list using a different notation.
It can be thought as one line for loop built inside of brackets.
Examples:
List1=[x for x in range(1,10)]
List2=[x**2 for x in range(1,10)]
List3=[x for x in range(11) if x%2==0]
List4=[x**2 for x in [x for x in range(20) if x%2==1]]
List5=[x for x in ‘Hello World’]
62. Python-Dictionaries
An unordered set of key and value pair.
A container that contains data, enclosed within {}.
Key-value pair is known as item.
Key must be unique.
Key and value is separated by ‘:’ and items in dictionary are separated by
‘,’.
Examples:
my_dict={‘001’:’Alex’, ‘002’:’Akira’, ‘003’:’Ayesha’}
63. Python-Dictionaries
It is mutable i.e. values can be updated.
Values can be accessed via key only.
Example:
my_dict[‘001’]
Nested Dictionaries can also be defined:
my_dict={‘key’:{‘subkey’:{‘subsubkey’:’value’}}}
64. Python-Dictionaries
Dictionaries Methods:
Method Name Description
len(dict ) Returns the number of elements in the dictionary.
keys() Returns all the keys of a dictionary.
values() Returns all the values associated with keys in a dictionary.
items() Returns all the items (key-value pair) in a dictionary.
update(dict) Used to add items of dict to the dictionary.
65. Python-Dictionaries
Dictionaries Methods:
Method Name Description
clear() Used to remove all items of a dictionary.
copy() Shallow copies data of a dictionary
has_key(key) Returns True if key is found in a dictionary otherwise False.
get(key) Returns the value associated with key. If key is not present, returns None.
66. Python-Tuples
A sequence of immutable objects.
Can be used to collect different types of object.
Similar to list, except tuples has immutable objects whereas list has
mutable objects and list uses [] to enclose objects whereas tuple uses () to
enclose objects.
Example:
tuple1=(1,2,3)
67. Python-Tuples
Operations on Tuples:
Accessing Elements
Elements can be accessed via indexing. e.g. tuple1[0]
Tuple can be sliced as well to access elements. e.g. tuple1[2:4]
71. Python-Files
Python uses file object to interact with external files on system.
It can be any type of file e.g. audio, video, text, etc.
To interact with these types of files, need to install some libraries or
modules which are easily available.
For instance, to read video files, need to install opencv-python package or
some other available packages for video files.
72. Python-Files
Installation of modules/ libraries/ packages:
To install any package for python, open command prompt and type:
python pip –m install packagename
e.g. python pip –m install opencv-python
To install a specific version of package:
python pip –m install “packagename>=version”
e.g. python pip –m install “opencv-python>=3.4.0.12”
To upgrade existing package:
python pip –m install --upgrade packagename
e.g. python pip –m install –upgrade opencv-python
73. Python-Files
Operations on File:
Opening a File:
f=open(‘filename’, ’mode’)
filename name of a file to be opened.
mode specifies the mode in which a file can be opened. E.g. ‘r’ to
read a file.
e.g. f=open(‘C:myFile.txt’, ’r’)
74. Python-Files
Different modes to open a File (Text):
Mode Description
r Opens a file in reading mode. Pointer is at the beginning of the file.
r+ Opens a file for reading and writing. Pointer is at the beginning of the file.
w Opens a file in writing mode. If already exists, then overwrite the file else
creates a new file.
w+ Opens a file for reading and writing. If already exists, then overwrite the file
else creates a new file.
a Opens a file in appending mode. If already exists, then append the data at the
end of the file else creates a new file.
a+ Opens a file in reading and appending mode. If already exists, then append the
data at the end of the file else creates a new file.
75. Python-Files
Different modes to open a File (Binary):
Mode Description
rb Opens a file in reading mode for binary format. Pointer is at the beginning of
the file.
rb+ Opens a file for reading and writing for binary format. Pointer is at the
beginning of the file.
wb Opens a file in writing mode for binary format. If already exists, then overwrite
the file else creates a new file.
wb+ Opens a file for reading and writing for binary format. If already exists, then
overwrite the file else creates a new file.
ab Opens a file in appending mode for binary format. If already exists, then
append the data at the end of the file else creates a new file.
ab+ Opens a file for reading and appending mode for binary format. If already
exists, then append the data at the end of the file else creates a new file.
76. Python-Files
Use of with Keyword:
Sample code:
with open('workfile', 'r') as f:
read_data = f.read()
It’s a good practice to use this approach.
File is properly closed after its suite finishes, even if an exception is
raised on the way.
77. Python-Files
Methods for File object:
Method Description
read([size]) To read a file’s content. If size is omitted or negative then entire content of
the file will be returned else read the specified quantity of data.
readline() Reads a single line from the file.
readlines() Reads all the lines from the file and returned as list of lines.
write(text) Writes content to the file.
tell() Returns an integer giving the file object’s current position in the file.
close() Closes an opened file.
78. Python-Files
Functions for File object by os module:
,
Function Description
rename(old_file_name new_file_name) Use to rename an existing file.
)remove(file_name Use to remove an existing file.
mkdir(directory_name) Use to create a directory with the name specified.
chdir(directory_name) Use to change the current working directory.
getcwd() Use to get the current working directory.
rmdir(directory_name) Use to delete a directory with the name specified.
79. Python-Sets
A set in python holds a sequence of values.
It is sequenced but not indexed.
A set contains only unique values.
A set is mutable, but may not contain mutable items like a list, set or
dictionary.
Function set() can be used to create a set from an iterable like list.
80. Python-Sets
Examples:
d=set() # Creates an empty set
d={1,2,3}
Since sets do not support indexing, slicing operation can’t be performed on
sets.
Since sets do not contain duplicate items, replication operation also can’t be
performed. (via *)
81. Python-Sets
Methods:
Method Description
add(object) Adds a hashable object to the set.
update(object) Adds iterable objects to the set.
discard(object) Deletes an object from the set. If object isn’t in the set, does nothing.
remove(object) Deletes an object from the set. If object isn’t in the set, throws an error.
pop() Removes first object from the set.
82. Python-Sets
Methods:
Method Description
clear() Removes all the objects from the set i.e. empties the set.
union(object) Performs union operations on the set with specified iterable objects in
the arguments.
intersection(object) Performs intersection operation on the set with specified iterable
objects in the arguments.
difference(object) Performs difference operation on the set with specified iterable objects
in the arguments
83. Python-Sets
Methods:
Method Description
issubset(object) Checks whether the set is a sub set of given object in the argument.
issuperset(object) Checks whether the set is a super set of given object in the argument.
isdisjoint(object) Checks whether the set is disjoint with the given object in argument.
84. Python-Booleans
A Boolean value may either be True or be False.
A Boolean can be declared like other objects e.g. x=True.
Function bool() can be used to convert other types in to Boolean.
Any empty construct has a Boolean value of False and a non-empty one
has True.
86. Python-Methods & Functions
Methods are essentially functions built into objects.
Methods perform specific actions on the objects and can also take
arguments.
Example:
object.method(arg1, arg2,…,etc)
Any information about the methods can be retrieved through
help(method_name) in python.
87. Python-Methods & Functions
Functions are the program section that are written once and let the
programmer to not repeat the same lines of code, hence make code
reusable.
Functions work on data and produces some output.
There are two types of functions:
Built-in functions: Predefined and organized into a library.
User-defined functions: Created by developer to meet the desired
requirements.
Follow the link for built-in functions in python: Built-in Functions
88. Python-Methods & Functions
A developer can define his/her own functions using below format:
Keyword def is used to declare a function.
def is followed by function name with parenthesis ending with a colon.
If required arguments can be provided within the parenthesis.
Example:
def function_name(parameter1, parameter2):
// line of codes
//sample code
def name_of_function():
pass
89. Python-Methods & Functions
Example:
def iseven(num):
if num%2==0:
print “Number is even”
else:
print “Number is not even”
The above function is defined to check whether the provided number is
even or not.
The above defined function can be called as follows:
iseven(10)
90. Python-Methods & Functions
Example using return statement:
def iseven(num):
return num%2==0
iseven(15)
Add documentation for function:
def iseven(num):
‘’’
This function will check whether the input number is even or not
‘’’
return num%2==0
92. Python-Methods & Functions
Local and Global Variables:
Variables defined inside a function is local variables and variables defined
outside the function is called global variables.
Example:
LOCAL VARIABLES
def printValue():
x=10
print x
printValue()
print x
GLOBAL VARIABLES
y=5
def printValue():
x=10
print x
print y
printValue()
94. Python-Lambda Expressions
Allows a programmer to create anonymous functions.
Allows to quickly make ad-hoc functions without needing to properly
define a function using def.
It’s an expression, not a block of statements.
The result of this is an expression without explicitly defining a return
statement.
Designed for coding simple functions to limit program nesting.
95. Python-Lambda Expressions
Converting a normal function to lambda expression:
Example:
def square(x):
return x*x
def square(x): return x*x
Syntax for lambda:
lambda input: result
lambda x: x*x
square=lambda x:x*x
sqaure(10)
100. Project: Tic-Tac-Toe
Problem Statement:
Create an application in Python for 2-player Tic-Tac-Toe game.
Step-by-step solution for problem statement:
Variables for the application
Board: Tic-Tac-Toe board a list with size 10
Player Markers: ‘x’ and ‘o’ string types
101. Project: Tic-Tac-Toe
Step-by-step solution for problem statement:
1. Create and Display Tic-Tac-Toe board
2. Choose the player’s marker and player to start the game
3. Ask the player to place his marker
4. Check if board is empty or not
5. If empty, place his marker
6. Ask another player to place his marker
7. Repeat 2-6 until the board is full or someone doesn’t declare as winner
8. If no winner found, then it’s a tie and ask to restart the game.
103. Project: Tic-Tac-Toe
Step-by-step solution for problem statement:
2. Select player’s marker and choose the player to start the game
def player_input():
player_marker=' '
while not (player_marker=='X' or player_marker=='O'):
player_marker=raw_input("Please select either X or O").upper()
if player_marker=='X':
return ('X', 'O')
else:
return ('O', 'X')
def choose_first_player():
if random.randint(0,1)==0:
return 'Player 1'
else:
return 'Player 2'
104. Project: Tic-Tac-Toe
Step-by-step solution for problem statement:
3. Ask to place the marker, check the empty place and place the marker
def player_choice(board):
choice=' '
numberList='1 2 3 4 5 6 7 8 9'
while choice not in numberList.split() or not check_place(board, int(choice)):
choice=raw_input("Please enter a number between 1-9")
return int(choice)
def check_place(board, position):
return board[position]==' '
def place_marker(board, marker, position):
board[position]=marker
105. Project: Tic-Tac-Toe
Step-by-step solution for problem statement:
4. Check whether the board is full or not
def full_board_space_check(board):
for i in range(1,10):
if check_place(board, i):
return False
return True
106. Project: Tic-Tac-Toe
Step-by-step solution for problem statement:
5. Start the game, check for winner or tie
def play_game():
print('Welcome to Tic-Tac-Toe')
while True:
game_board=[' ']*10
player1_mark,player2_mark=player_input()
turn=choose_first_player()
print(turn+' will start this game')
game_on=True
while game_on:
if turn=='Player 1':
display_board(game_board)
position=player_choice(game_board)
place_marker(game_board, player1_mark, position)
if check_winner(game_board, player1_mark):
display_board(game_board)
print('Congratulation...!!!! Player1 has won')
game_on=False
else:
if full_board_space_check(game_board):
display_board(game_board)
print('Try next time.. Its a Tie.. ')
break
else:
turn='Player 2'
107. Project: Tic-Tac-Toe
Step-by-step solution for problem statement:
5. Start the game, check for winner or tie
else:
display_board(game_board)
position=player_choice(game_board)
place_marker(game_board, player2_mark, position)
if check_winner(game_board, player2_mark):
display_board(game_board)
print('Congratulation...!!!! Player2 has won')
game_on=False
else:
if full_board_space_check(game_board):
display_board(game_board)
print('Try next time.. Its a Tie.. ')
break
else:
turn='Player 1'
if not restart_play():
print('We will Miss you..')
break
def check_winner(board, marker):
return board[1]==board[2]==board[3]==marker or
board[4]==board[5]==board[6]==marker or
board[7]==board[8]==board[9]==marker or
board[1]==board[4]==board[7]==marker or
board[2]==board[5]==board[8]==marker or
board[3]==board[6]==board[9]==marker or
board[1]==board[5]==board[9]==marker or
board[3]==board[5]==board[7]==marker
108. Project: Tic-Tac-Toe
Step-by-step solution for problem statement:
6. Ask to restart the game
Let’s play the game: play_game()
def restart_play():
return raw_input("Do you want to play again (Yes/No)").lower().startswith('y')