SlideShare a Scribd company logo
Python
Python
 Developed by Guido van Rossum
 Derived from many other languages, including ABC, Modula-3, C, C++, Algol-68,
Smalltalk, and Unix shell and other scripting languages.
 Python is copyrighted. Like Perl, Python source code is now available under the
GNU General Public License (GPL).
Ref: www.tutorialspoint.com Created By : Abishek
Python-Features
 Easy-to-learn
 Easy-to-read
 Easy-to-maintain
 A broad standard library
 Interactive Mode
 Portable
 Extendable
 Provide interface to all major Databases
 Supports GUI applications
 Scalable
Ref: www.tutorialspoint.com Created By : Abishek
Advanced Features
 It supports functional and structured programming methods as well as OOP.
 It can be used as a scripting language or can be compiled to byte-code for
building large applications.
 It provides very high-level dynamic data types and supports dynamic type
checking.
 IT supports automatic garbage collection.
 It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.
Ref: www.tutorialspoint.com Created By : Abishek
Python Environment Variables
 PYTHONPATH
 PYTHONSTARTUP
 PYTHONCASEOK
 PYTHONHOME
Ref: www.tutorialspoint.com Created By : Abishek
Python Identifiers
 A Python identifier is a name used to identify a variable, function, class, module or
other object.
 Python does not allow punctuation characters such as @, $, and % within
identifiers.
 Class names start with an uppercase letter. All other identifiers start with a
lowercase letter.
 Starting an identifier with a single leading underscore indicates that the identifier is
private.
 Starting an identifier with two leading underscores indicates a strongly private
identifier.
 If the identifier also ends with two trailing underscores, the identifier is a language-
defined special name.
Ref: www.tutorialspoint.com Created By : Abishek
Reserved Words(Key words)
and exec not
assert finally or
break for pass
class from print
continue global raise
def if return
del import try
elif in while
else is with
except lambda yield
Ref: www.tutorialspoint.com Created By : Abishek
Lines and Indentation
 Python provides no braces to indicate blocks of code for class and function
definitions or flow control.
 Blocks of code are denoted by line indentation, which is rigidly enforced.
 The number of spaces in the indentation is variable, but all statements within the
block must be indented the same amount.
Ref: www.tutorialspoint.com Created By : Abishek
Multi-Line Statements
 Statements in Python typically end with a new line
 Python allow the use of the line continuation character () to denote that the line
should continue. For Example :-
 total = item_one + 
item_two + 
item_three
Ref: www.tutorialspoint.com Created By : Abishek
Quotation in Python
 Python accepts single ('), double (") and triple (''' or """) quotes to denote string
literals
 The triple quotes are used to span the string across multiple lines. For example, all
the following are legal −
 word = 'word'
sentence = "This is a sentence."
paragraph = """This is a paragraph. It is made up of multiple lines and
sentences."""
Ref: www.tutorialspoint.com Created By : Abishek
Other Syntax in python
 A hash sign (#) that is not inside a string literal begins a comment.
 A line containing only whitespace, possibly with a comment, is known as a blank
line and Python totally ignores it.
 "nn" is used to create two new lines before displaying the actual line.
 The semicolon ( ; ) allows multiple statements on the single line given that neither
statement starts a new code block.
 A group of individual statements, which make a single code block are
called suites in Python
Ref: www.tutorialspoint.com Created By : Abishek
Assigning Values to Variables
 Python variables do not need explicit declaration to reserve memory space.
 The declaration happens automatically when you assign a value to a variable. The
equal sign (=) is used to assign values to variables.
 Python allows you to assign a single value to several variables simultaneously.
Ref: www.tutorialspoint.com Created By : Abishek
Data Types in Python
 Python has five standard data types
 Numbers:
 var2 = 10
 String
 str = 'Hello World!'
 List
 list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]
 Tuple
 tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )
 Dictionary
 dict = {'name': 'john','code':6734, 'dept': 'sales'}
Ref: www.tutorialspoint.com Created By : Abishek
Data Type Conversion
Function Description
int(x [,base]) Converts x to an integer. base specifies the
base if x is a string.
long(x [,base] ) Converts x to a long integer. base specifies the
base if x is a string.
float(x) Converts x to a floating-point number.
complex(real [,imag]) Creates a complex number.
str(x) Converts object x to a string representation.
repr(x) Converts object x to an expression string.
eval(str) Evaluates a string and returns an object.
Ref: www.tutorialspoint.com Created By : Abishek
Cont.
tuple(s) Converts s to a tuple.
list(s) Converts s to a list.
set(s) Converts s to a set.
dict(d) Creates a dictionary. d must be a sequence of
(key,value) tuples.
frozenset(s) Converts s to a frozen set.
chr(x) Converts an integer to a character.
unichr(x) Converts an integer to a Unicode character.
ord(x) Converts a single character to its integer value.
hex(x) Converts an integer to a hexadecimal string.
oct(x) Converts an integer to an octal string.
Function Description
Ref: www.tutorialspoint.com Created By : Abishek
Types of Operator
 Arithmetic Operators
 Comparison (Relational) Operators
 Assignment Operators
 Logical Operators
 Bitwise Operators
 Membership Operators
 Identity Operators
Ref: www.tutorialspoint.com Created By : Abishek
Decision Making
 If statement
 If-Else statement
 Nested If statements
Ref: www.tutorialspoint.com Created By : Abishek
Python Loops
 While loop
 For loop
 Nested loops
Ref: www.tutorialspoint.com Created By : Abishek
Loop control Statements
 break statement
 continue statement
 pass statement
Ref: www.tutorialspoint.com Created By : Abishek
Python Date & Time
 Time intervals are floating-point numbers in units of seconds. Particular instants in
time are expressed in seconds since 12:00am, January 1, 1970(epoch).
 The function time.time() returns the current system time in ticks since 12:00am,
January 1, 1970(epoch).
 Many of Python's time functions handle time as a tuple of 9 numbers
 Get Current time : time.localtime(time.time())
 Getting formatted time : time.asctime(time.localtime(time.time()))
 Getting calendar for a month : calendar.month(year,month)
Ref: www.tutorialspoint.com Created By : Abishek
Python Functions
 We can define the function to provide required functionality. We have to stick with some
rules and regulations to do this.
 Function blocks begin with the keyword def followed by the function name and parentheses ( ( )
).
 Any input parameters or arguments should be placed within these parentheses. You can also
define parameters inside these parentheses.
 The first statement of a function can be an optional statement - the documentation string of the
function or docstring.
 The code block within every function starts with a colon (:) and is indented.
 The statement return [expression] exits a function, optionally passing back an expression to the
caller. A return statement with no arguments is the same as return None.
Ref: www.tutorialspoint.com Created By : Abishek
Syntax and Example for a function
 Syntax
def functionname( parameters ):
"function_docstring"
function_suite
return [expression]
 Example:
def printme( str ):
"This prints a passed string into this function"
print str
return
Ref: www.tutorialspoint.com Created By : Abishek
Function Arguments
 You can call a function by using the following types of formal arguments:
 Required arguments : Required arguments are the arguments passed to a function in
correct positional order. Here, the number of arguments in the function call should
match exactly with the function definition.
 Keyword arguments : Keyword arguments are related to the function calls. When you
use keyword arguments in a function call, the caller identifies the arguments by the
parameter name.
 Default arguments : A default argument is an argument that assumes a default value if
a value is not provided in the function call for that argument.
 Variable-length arguments : You may need to process a function for more arguments
than you specified while defining the function. These arguments are called variable-
length arguments and are not named in the function definition, unlike required and
default arguments.
Ref: www.tutorialspoint.com Created By : Abishek
Anonymous Functions
 These functions are called anonymous because they are not declared in the standard
manner by using the def keyword. You can use the lambda keyword to create small
anonymous functions.
 Syntax: lambda [arg1 [,arg2,.....argn]]:expression
 Lambda forms can take any number of arguments but return just one value in the form of an
expression.
 They cannot contain commands or multiple expressions.
 An anonymous function cannot be a direct call to print because lambda requires an expression
 Lambda functions have their own local namespace and cannot access variables other than
those in their parameter list and those in the global namespace.
 Although it appears that lambda's are a one-line version of a function, they are not equivalent
to inline statements in C or C++, whose purpose is by passing function stack allocation during
invocation for performance reasons.
Ref: www.tutorialspoint.com Created By : Abishek
Variables
 Scope of a variable
 Global variables
 Variables that are defined outside a function body have a global scope.
 Global variables can be accessed throughout the program body by all functions.
 Local variables
 Variables that are defined inside a function body have a local scope.
 Local variables can be accessed only inside the function in which they are declared
Ref: www.tutorialspoint.com Created By : Abishek
Python Modules
 A module is a Python object with arbitrarily named attributes that you can bind
and reference.
 A module allows you to logically organize your Python code.
 Grouping related code into a module makes the code easier to understand and
use.
 A module can define functions, classes and variables. A module can also include
runnable code.
 You can use any Python source file as a module by executing an import statement
in some other Python source file. The import has the following syntax:
 import module1[, module2[,... moduleN]
Ref: www.tutorialspoint.com Created By : Abishek
Cont.
 Python's from statement lets you import specific attributes from a module into the
current namespace. The from...import has the following syntax −
 from modname import name1[, name2[, ... nameN]]
 Using ‘import *’ will import all names from a module into the current namespace.
 When you import a module, the Python interpreter searches for the module in the
following sequences −
 The current directory.
 If the module isn't found, Python then searches each directory in the shell variable
PYTHONPATH.
 If all else fails, Python checks the default path. On UNIX, this default path is normally
/usr/local/lib/python/.
Ref: www.tutorialspoint.com Created By : Abishek
Python I/O
 Print statement is the simplest way to produce the output.
 We can pass zero or more expressions separated by commas to print statement.
 Eg: print "Python is really a great language,", "isn't it?“
 Reading Keyboard Input
 Python provides two built-in functions to read a line of text
 raw_input : The raw_input([prompt]) function reads one line from standard input and returns it as
a string
 raw_input([prompt])
 Input : The input([prompt]) function is equivalent to raw_input, except that it assumes the input is
a valid Python expression and returns the evaluated result to you.
 input([prompt])
Ref: www.tutorialspoint.com Created By : Abishek
Opening and Closing Files
 The open Function
 Open() is used to open a file
 This function creates a file object, which would be utilized to call other support methods
associated with it.
 Syntax: file object = open(file_name [, access_mode][, buffering])
 file_name: The file_name argument is a string value that contains the name of the file that you
want to access.
 access_mode: The access_mode determines the mode in which the file has to be opened, i.e.,
read, write, append, etc.
 buffering: If the buffering value is set to 0, no buffering takes place. If the buffering value is 1,
line buffering is performed while accessing a file. If you specify the buffering value as an integer
greater than 1, then buffering action is performed with the indicated buffer size. If negative, the
buffer size is the system default(default behavior).
Ref: www.tutorialspoint.com Created By : Abishek
Cont.
 The close() Method
 The close() method of a file object flushes any unwritten information and closes the file
object, after which no more writing can be done.
 Python automatically closes a file when the reference object of a file is reassigned to
another file.
 It is a good practice to use the close() method to close a file.
 Syntax : fileObject.close();
 The write() Method
 The write() method writes any string to an open file.
 The write() method does not add a newline character ('n') to the end of the string −
 Syntax : fileObject.write(string);
 The read() Method
 The read() method reads a string from an open file.
 Syntax : fileObject.read([count]);
Ref: www.tutorialspoint.com Created By : Abishek
Python Exceptions
 An exception is a Python object that represents an error.
 Exception is an event, which occurs during the execution of a program that disrupts
the normal flow of the program's instructions.
 When a Python script encounters a situation that it cannot cope with, it raises an
exception.
Ref: www.tutorialspoint.com Created By : Abishek
Handling an exception
 Exception handling implemented in Python using try-except method.
 You can defend your program by placing the suspicious code in a try: block.
 After the try: block, include an except: statement, followed by a block of code which handles the problem as
elegantly as possible.
 Syntax:
try:
You do your operations here;
......................
except ExceptionI:
If there is ExceptionI, then execute this block.
except ExceptionII:
If there is ExceptionII, then execute this block.
......................
else:
If there is no exception then execute this block.
Ref: www.tutorialspoint.com Created By : Abishek
Cont.
 Here are few important points about the above-mentioned syntax −
 A single try statement can have multiple except statements. This is useful when the try block
contains statements that may throw different types of exceptions.
 You can also provide a generic except clause, which handles any exception.
 After the except clause(s), you can include an else-clause. The code in the else-block executes if
the code in the try: block does not raise an exception.
 The else-block is a good place for code that does not need the try: block's protection.
 The except Clause with No Exceptions
 You can also use the except statement with no exceptions defined as follows −
try:
You do your operations here;
......................
except:
If there is any exception, then execute this block.
......................
else:
If there is no exception then execute this block.
Ref: www.tutorialspoint.com Created By : Abishek
Cont.
 The except Clause with Multiple Exceptions
 You can also use the same except statement to handle multiple exceptions as follows −
try:
You do your operations here;
......................
except(Exception1[, Exception2[,...ExceptionN]]]):
If there is any exception from the given exception list,
then execute this block.
......................
else:
If there is no exception then execute this block.
Ref: www.tutorialspoint.com Created By : Abishek
Cont.
 The try-finally Clause
 You can use a finally: block along with a try: block.
 The finally block is a place to put any code that must execute, whether the try-block
raised an exception or not.
 Syntax:
try:
You do your operations here;
......................
Due to any exception, this may be skipped.
finally:
This would always be executed.
......................
Ref: www.tutorialspoint.com Created By : Abishek
Ad

More Related Content

What's hot (19)

Bcsl 031 solve assignment
Bcsl 031 solve assignmentBcsl 031 solve assignment
Bcsl 031 solve assignment
Indira Gnadhi National Open University (IGNOU)
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
kiran acharya
 
Python revision tour i
Python revision tour iPython revision tour i
Python revision tour i
Mr. Vikram Singh Slathia
 
Consuming and Creating Libraries in C++
Consuming and Creating Libraries in C++Consuming and Creating Libraries in C++
Consuming and Creating Libraries in C++
Richard Thomson
 
Top C Language Interview Questions and Answer
Top C Language Interview Questions and AnswerTop C Language Interview Questions and Answer
Top C Language Interview Questions and Answer
Vineet Kumar Saini
 
C programming notes
C programming notesC programming notes
C programming notes
Prof. Dr. K. Adisesha
 
C++ Interview Questions
C++ Interview QuestionsC++ Interview Questions
C++ Interview Questions
Kaushik Raghupathi
 
Lesson 03 python statement, indentation and comments
Lesson 03   python statement, indentation and commentsLesson 03   python statement, indentation and comments
Lesson 03 python statement, indentation and comments
Nilimesh Halder
 
Functional programming in C++
Functional programming in C++Functional programming in C++
Functional programming in C++
Alexandru Bolboaca
 
Lexical analysis-using-lex
Lexical analysis-using-lexLexical analysis-using-lex
Lexical analysis-using-lex
Dattatray Gandhmal
 
DEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellDEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World Haskell
Bryan O'Sullivan
 
Introduction to Python Part-1
Introduction to Python Part-1Introduction to Python Part-1
Introduction to Python Part-1
Devashish Kumar
 
Functional Programming in C# and F#
Functional Programming in C# and F#Functional Programming in C# and F#
Functional Programming in C# and F#
Alfonso Garcia-Caro
 
Introduction to Python Basics
Introduction to Python BasicsIntroduction to Python Basics
Introduction to Python Basics
Raghunath A
 
Python Session - 4
Python Session - 4Python Session - 4
Python Session - 4
AnirudhaGaikwad4
 
OOP in C++
OOP in C++OOP in C++
OOP in C++
ppd1961
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++
Bharat Kalia
 
C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1
ReKruiTIn.com
 
Python regular expressions
Python regular expressionsPython regular expressions
Python regular expressions
Krishna Nanda
 

Similar to Python Programming Basics for begginners (20)

c & c++ logic building concepts practice.pptx
c & c++ logic building concepts practice.pptxc & c++ logic building concepts practice.pptx
c & c++ logic building concepts practice.pptx
rawatsatish0327
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
home
 
python and perl
python and perlpython and perl
python and perl
Mara Angelica Refraccion
 
Python Programming Course Presentations
Python Programming Course  PresentationsPython Programming Course  Presentations
Python Programming Course Presentations
DreamerInfotech
 
presentation_intro_to_python
presentation_intro_to_pythonpresentation_intro_to_python
presentation_intro_to_python
gunanandJha2
 
presentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.pptpresentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.ppt
MohitChaudhary637683
 
11-unit1chapter02pythonfundamentals-180823043011.pptx
11-unit1chapter02pythonfundamentals-180823043011.pptx11-unit1chapter02pythonfundamentals-180823043011.pptx
11-unit1chapter02pythonfundamentals-180823043011.pptx
MamtaKaundal1
 
3-Python Python oho pytho hdiwefjhdsjhds
3-Python Python oho pytho hdiwefjhdsjhds3-Python Python oho pytho hdiwefjhdsjhds
3-Python Python oho pytho hdiwefjhdsjhds
hardikbhagwaria83
 
PythonStudyMaterialSTudyMaterial.pdf
PythonStudyMaterialSTudyMaterial.pdfPythonStudyMaterialSTudyMaterial.pdf
PythonStudyMaterialSTudyMaterial.pdf
data2businessinsight
 
12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp
sharvivek
 
Python1
Python1Python1
Python1
AllsoftSolutions
 
Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning
ParrotAI
 
7986-lect 7.pdf
7986-lect 7.pdf7986-lect 7.pdf
7986-lect 7.pdf
RiazAhmad521284
 
An Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAn Overview Of Python With Functional Programming
An Overview Of Python With Functional Programming
Adam Getchell
 
7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc
7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc
7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc
abdulhaq467432
 
Gude for C++11 in Apache Traffic Server
Gude for C++11 in Apache Traffic ServerGude for C++11 in Apache Traffic Server
Gude for C++11 in Apache Traffic Server
Apache Traffic Server
 
Introduction to R for beginners
Introduction to R for beginnersIntroduction to R for beginners
Introduction to R for beginners
Abishek Purushothaman
 
Python
PythonPython
Python
Aashish Jain
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
home
 
Php intro by sami kz
Php intro by sami kzPhp intro by sami kz
Php intro by sami kz
sami2244
 
c & c++ logic building concepts practice.pptx
c & c++ logic building concepts practice.pptxc & c++ logic building concepts practice.pptx
c & c++ logic building concepts practice.pptx
rawatsatish0327
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
home
 
Python Programming Course Presentations
Python Programming Course  PresentationsPython Programming Course  Presentations
Python Programming Course Presentations
DreamerInfotech
 
presentation_intro_to_python
presentation_intro_to_pythonpresentation_intro_to_python
presentation_intro_to_python
gunanandJha2
 
presentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.pptpresentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.ppt
MohitChaudhary637683
 
11-unit1chapter02pythonfundamentals-180823043011.pptx
11-unit1chapter02pythonfundamentals-180823043011.pptx11-unit1chapter02pythonfundamentals-180823043011.pptx
11-unit1chapter02pythonfundamentals-180823043011.pptx
MamtaKaundal1
 
3-Python Python oho pytho hdiwefjhdsjhds
3-Python Python oho pytho hdiwefjhdsjhds3-Python Python oho pytho hdiwefjhdsjhds
3-Python Python oho pytho hdiwefjhdsjhds
hardikbhagwaria83
 
PythonStudyMaterialSTudyMaterial.pdf
PythonStudyMaterialSTudyMaterial.pdfPythonStudyMaterialSTudyMaterial.pdf
PythonStudyMaterialSTudyMaterial.pdf
data2businessinsight
 
12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp12 computer science_notes_ch01_overview_of_cpp
12 computer science_notes_ch01_overview_of_cpp
sharvivek
 
Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning Introduction to Python for Data Science and Machine Learning
Introduction to Python for Data Science and Machine Learning
ParrotAI
 
An Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAn Overview Of Python With Functional Programming
An Overview Of Python With Functional Programming
Adam Getchell
 
7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc
7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc
7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc
abdulhaq467432
 
Gude for C++11 in Apache Traffic Server
Gude for C++11 in Apache Traffic ServerGude for C++11 in Apache Traffic Server
Gude for C++11 in Apache Traffic Server
Apache Traffic Server
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
home
 
Php intro by sami kz
Php intro by sami kzPhp intro by sami kz
Php intro by sami kz
sami2244
 
Ad

More from Abishek Purushothaman (7)

Aws solution architect
Aws solution architectAws solution architect
Aws solution architect
Abishek Purushothaman
 
Machine learning
Machine learningMachine learning
Machine learning
Abishek Purushothaman
 
Multiple choice questions for Java io,files and inheritance
Multiple choice questions for Java io,files and inheritanceMultiple choice questions for Java io,files and inheritance
Multiple choice questions for Java io,files and inheritance
Abishek Purushothaman
 
Multiple Choice Questions for Java interfaces and exception handling
Multiple Choice Questions for Java interfaces and exception handlingMultiple Choice Questions for Java interfaces and exception handling
Multiple Choice Questions for Java interfaces and exception handling
Abishek Purushothaman
 
Mini Project presentation for MCA
Mini Project presentation for MCAMini Project presentation for MCA
Mini Project presentation for MCA
Abishek Purushothaman
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
Abishek Purushothaman
 
Exception handling
Exception handlingException handling
Exception handling
Abishek Purushothaman
 
Ad

Recently uploaded (20)

FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Sales Deck SentinelOne Singularity Platform.pptx
Sales Deck SentinelOne Singularity Platform.pptxSales Deck SentinelOne Singularity Platform.pptx
Sales Deck SentinelOne Singularity Platform.pptx
EliandoLawnote
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
steaveroggers
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
Adobe Photoshop Lightroom CC 2025 Crack Latest Version
Adobe Photoshop Lightroom CC 2025 Crack Latest VersionAdobe Photoshop Lightroom CC 2025 Crack Latest Version
Adobe Photoshop Lightroom CC 2025 Crack Latest Version
usmanhidray
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 
FL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full VersionFL Studio Producer Edition Crack 2025 Full Version
FL Studio Producer Edition Crack 2025 Full Version
tahirabibi60507
 
EASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License CodeEASEUS Partition Master Crack + License Code
EASEUS Partition Master Crack + License Code
aneelaramzan63
 
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Mastering Fluent Bit: Ultimate Guide to Integrating Telemetry Pipelines with ...
Eric D. Schabell
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and CollaborateMeet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Meet the Agents: How AI Is Learning to Think, Plan, and Collaborate
Maxim Salnikov
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
What Do Contribution Guidelines Say About Software Testing? (MSR 2025)
Andre Hora
 
Sales Deck SentinelOne Singularity Platform.pptx
Sales Deck SentinelOne Singularity Platform.pptxSales Deck SentinelOne Singularity Platform.pptx
Sales Deck SentinelOne Singularity Platform.pptx
EliandoLawnote
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Solidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license codeSolidworks Crack 2025 latest new + license code
Solidworks Crack 2025 latest new + license code
aneelaramzan63
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
How to Batch Export Lotus Notes NSF Emails to Outlook PST Easily?
steaveroggers
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
Adobe Photoshop Lightroom CC 2025 Crack Latest Version
Adobe Photoshop Lightroom CC 2025 Crack Latest VersionAdobe Photoshop Lightroom CC 2025 Crack Latest Version
Adobe Photoshop Lightroom CC 2025 Crack Latest Version
usmanhidray
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025PDF Reader Pro Crack Latest Version FREE Download 2025
PDF Reader Pro Crack Latest Version FREE Download 2025
mu394968
 

Python Programming Basics for begginners

  • 2. Python  Developed by Guido van Rossum  Derived from many other languages, including ABC, Modula-3, C, C++, Algol-68, Smalltalk, and Unix shell and other scripting languages.  Python is copyrighted. Like Perl, Python source code is now available under the GNU General Public License (GPL). Ref: www.tutorialspoint.com Created By : Abishek
  • 3. Python-Features  Easy-to-learn  Easy-to-read  Easy-to-maintain  A broad standard library  Interactive Mode  Portable  Extendable  Provide interface to all major Databases  Supports GUI applications  Scalable Ref: www.tutorialspoint.com Created By : Abishek
  • 4. Advanced Features  It supports functional and structured programming methods as well as OOP.  It can be used as a scripting language or can be compiled to byte-code for building large applications.  It provides very high-level dynamic data types and supports dynamic type checking.  IT supports automatic garbage collection.  It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java. Ref: www.tutorialspoint.com Created By : Abishek
  • 5. Python Environment Variables  PYTHONPATH  PYTHONSTARTUP  PYTHONCASEOK  PYTHONHOME Ref: www.tutorialspoint.com Created By : Abishek
  • 6. Python Identifiers  A Python identifier is a name used to identify a variable, function, class, module or other object.  Python does not allow punctuation characters such as @, $, and % within identifiers.  Class names start with an uppercase letter. All other identifiers start with a lowercase letter.  Starting an identifier with a single leading underscore indicates that the identifier is private.  Starting an identifier with two leading underscores indicates a strongly private identifier.  If the identifier also ends with two trailing underscores, the identifier is a language- defined special name. Ref: www.tutorialspoint.com Created By : Abishek
  • 7. Reserved Words(Key words) and exec not assert finally or break for pass class from print continue global raise def if return del import try elif in while else is with except lambda yield Ref: www.tutorialspoint.com Created By : Abishek
  • 8. Lines and Indentation  Python provides no braces to indicate blocks of code for class and function definitions or flow control.  Blocks of code are denoted by line indentation, which is rigidly enforced.  The number of spaces in the indentation is variable, but all statements within the block must be indented the same amount. Ref: www.tutorialspoint.com Created By : Abishek
  • 9. Multi-Line Statements  Statements in Python typically end with a new line  Python allow the use of the line continuation character () to denote that the line should continue. For Example :-  total = item_one + item_two + item_three Ref: www.tutorialspoint.com Created By : Abishek
  • 10. Quotation in Python  Python accepts single ('), double (") and triple (''' or """) quotes to denote string literals  The triple quotes are used to span the string across multiple lines. For example, all the following are legal −  word = 'word' sentence = "This is a sentence." paragraph = """This is a paragraph. It is made up of multiple lines and sentences.""" Ref: www.tutorialspoint.com Created By : Abishek
  • 11. Other Syntax in python  A hash sign (#) that is not inside a string literal begins a comment.  A line containing only whitespace, possibly with a comment, is known as a blank line and Python totally ignores it.  "nn" is used to create two new lines before displaying the actual line.  The semicolon ( ; ) allows multiple statements on the single line given that neither statement starts a new code block.  A group of individual statements, which make a single code block are called suites in Python Ref: www.tutorialspoint.com Created By : Abishek
  • 12. Assigning Values to Variables  Python variables do not need explicit declaration to reserve memory space.  The declaration happens automatically when you assign a value to a variable. The equal sign (=) is used to assign values to variables.  Python allows you to assign a single value to several variables simultaneously. Ref: www.tutorialspoint.com Created By : Abishek
  • 13. Data Types in Python  Python has five standard data types  Numbers:  var2 = 10  String  str = 'Hello World!'  List  list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]  Tuple  tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )  Dictionary  dict = {'name': 'john','code':6734, 'dept': 'sales'} Ref: www.tutorialspoint.com Created By : Abishek
  • 14. Data Type Conversion Function Description int(x [,base]) Converts x to an integer. base specifies the base if x is a string. long(x [,base] ) Converts x to a long integer. base specifies the base if x is a string. float(x) Converts x to a floating-point number. complex(real [,imag]) Creates a complex number. str(x) Converts object x to a string representation. repr(x) Converts object x to an expression string. eval(str) Evaluates a string and returns an object. Ref: www.tutorialspoint.com Created By : Abishek
  • 15. Cont. tuple(s) Converts s to a tuple. list(s) Converts s to a list. set(s) Converts s to a set. dict(d) Creates a dictionary. d must be a sequence of (key,value) tuples. frozenset(s) Converts s to a frozen set. chr(x) Converts an integer to a character. unichr(x) Converts an integer to a Unicode character. ord(x) Converts a single character to its integer value. hex(x) Converts an integer to a hexadecimal string. oct(x) Converts an integer to an octal string. Function Description Ref: www.tutorialspoint.com Created By : Abishek
  • 16. Types of Operator  Arithmetic Operators  Comparison (Relational) Operators  Assignment Operators  Logical Operators  Bitwise Operators  Membership Operators  Identity Operators Ref: www.tutorialspoint.com Created By : Abishek
  • 17. Decision Making  If statement  If-Else statement  Nested If statements Ref: www.tutorialspoint.com Created By : Abishek
  • 18. Python Loops  While loop  For loop  Nested loops Ref: www.tutorialspoint.com Created By : Abishek
  • 19. Loop control Statements  break statement  continue statement  pass statement Ref: www.tutorialspoint.com Created By : Abishek
  • 20. Python Date & Time  Time intervals are floating-point numbers in units of seconds. Particular instants in time are expressed in seconds since 12:00am, January 1, 1970(epoch).  The function time.time() returns the current system time in ticks since 12:00am, January 1, 1970(epoch).  Many of Python's time functions handle time as a tuple of 9 numbers  Get Current time : time.localtime(time.time())  Getting formatted time : time.asctime(time.localtime(time.time()))  Getting calendar for a month : calendar.month(year,month) Ref: www.tutorialspoint.com Created By : Abishek
  • 21. Python Functions  We can define the function to provide required functionality. We have to stick with some rules and regulations to do this.  Function blocks begin with the keyword def followed by the function name and parentheses ( ( ) ).  Any input parameters or arguments should be placed within these parentheses. You can also define parameters inside these parentheses.  The first statement of a function can be an optional statement - the documentation string of the function or docstring.  The code block within every function starts with a colon (:) and is indented.  The statement return [expression] exits a function, optionally passing back an expression to the caller. A return statement with no arguments is the same as return None. Ref: www.tutorialspoint.com Created By : Abishek
  • 22. Syntax and Example for a function  Syntax def functionname( parameters ): "function_docstring" function_suite return [expression]  Example: def printme( str ): "This prints a passed string into this function" print str return Ref: www.tutorialspoint.com Created By : Abishek
  • 23. Function Arguments  You can call a function by using the following types of formal arguments:  Required arguments : Required arguments are the arguments passed to a function in correct positional order. Here, the number of arguments in the function call should match exactly with the function definition.  Keyword arguments : Keyword arguments are related to the function calls. When you use keyword arguments in a function call, the caller identifies the arguments by the parameter name.  Default arguments : A default argument is an argument that assumes a default value if a value is not provided in the function call for that argument.  Variable-length arguments : You may need to process a function for more arguments than you specified while defining the function. These arguments are called variable- length arguments and are not named in the function definition, unlike required and default arguments. Ref: www.tutorialspoint.com Created By : Abishek
  • 24. Anonymous Functions  These functions are called anonymous because they are not declared in the standard manner by using the def keyword. You can use the lambda keyword to create small anonymous functions.  Syntax: lambda [arg1 [,arg2,.....argn]]:expression  Lambda forms can take any number of arguments but return just one value in the form of an expression.  They cannot contain commands or multiple expressions.  An anonymous function cannot be a direct call to print because lambda requires an expression  Lambda functions have their own local namespace and cannot access variables other than those in their parameter list and those in the global namespace.  Although it appears that lambda's are a one-line version of a function, they are not equivalent to inline statements in C or C++, whose purpose is by passing function stack allocation during invocation for performance reasons. Ref: www.tutorialspoint.com Created By : Abishek
  • 25. Variables  Scope of a variable  Global variables  Variables that are defined outside a function body have a global scope.  Global variables can be accessed throughout the program body by all functions.  Local variables  Variables that are defined inside a function body have a local scope.  Local variables can be accessed only inside the function in which they are declared Ref: www.tutorialspoint.com Created By : Abishek
  • 26. Python Modules  A module is a Python object with arbitrarily named attributes that you can bind and reference.  A module allows you to logically organize your Python code.  Grouping related code into a module makes the code easier to understand and use.  A module can define functions, classes and variables. A module can also include runnable code.  You can use any Python source file as a module by executing an import statement in some other Python source file. The import has the following syntax:  import module1[, module2[,... moduleN] Ref: www.tutorialspoint.com Created By : Abishek
  • 27. Cont.  Python's from statement lets you import specific attributes from a module into the current namespace. The from...import has the following syntax −  from modname import name1[, name2[, ... nameN]]  Using ‘import *’ will import all names from a module into the current namespace.  When you import a module, the Python interpreter searches for the module in the following sequences −  The current directory.  If the module isn't found, Python then searches each directory in the shell variable PYTHONPATH.  If all else fails, Python checks the default path. On UNIX, this default path is normally /usr/local/lib/python/. Ref: www.tutorialspoint.com Created By : Abishek
  • 28. Python I/O  Print statement is the simplest way to produce the output.  We can pass zero or more expressions separated by commas to print statement.  Eg: print "Python is really a great language,", "isn't it?“  Reading Keyboard Input  Python provides two built-in functions to read a line of text  raw_input : The raw_input([prompt]) function reads one line from standard input and returns it as a string  raw_input([prompt])  Input : The input([prompt]) function is equivalent to raw_input, except that it assumes the input is a valid Python expression and returns the evaluated result to you.  input([prompt]) Ref: www.tutorialspoint.com Created By : Abishek
  • 29. Opening and Closing Files  The open Function  Open() is used to open a file  This function creates a file object, which would be utilized to call other support methods associated with it.  Syntax: file object = open(file_name [, access_mode][, buffering])  file_name: The file_name argument is a string value that contains the name of the file that you want to access.  access_mode: The access_mode determines the mode in which the file has to be opened, i.e., read, write, append, etc.  buffering: If the buffering value is set to 0, no buffering takes place. If the buffering value is 1, line buffering is performed while accessing a file. If you specify the buffering value as an integer greater than 1, then buffering action is performed with the indicated buffer size. If negative, the buffer size is the system default(default behavior). Ref: www.tutorialspoint.com Created By : Abishek
  • 30. Cont.  The close() Method  The close() method of a file object flushes any unwritten information and closes the file object, after which no more writing can be done.  Python automatically closes a file when the reference object of a file is reassigned to another file.  It is a good practice to use the close() method to close a file.  Syntax : fileObject.close();  The write() Method  The write() method writes any string to an open file.  The write() method does not add a newline character ('n') to the end of the string −  Syntax : fileObject.write(string);  The read() Method  The read() method reads a string from an open file.  Syntax : fileObject.read([count]); Ref: www.tutorialspoint.com Created By : Abishek
  • 31. Python Exceptions  An exception is a Python object that represents an error.  Exception is an event, which occurs during the execution of a program that disrupts the normal flow of the program's instructions.  When a Python script encounters a situation that it cannot cope with, it raises an exception. Ref: www.tutorialspoint.com Created By : Abishek
  • 32. Handling an exception  Exception handling implemented in Python using try-except method.  You can defend your program by placing the suspicious code in a try: block.  After the try: block, include an except: statement, followed by a block of code which handles the problem as elegantly as possible.  Syntax: try: You do your operations here; ...................... except ExceptionI: If there is ExceptionI, then execute this block. except ExceptionII: If there is ExceptionII, then execute this block. ...................... else: If there is no exception then execute this block. Ref: www.tutorialspoint.com Created By : Abishek
  • 33. Cont.  Here are few important points about the above-mentioned syntax −  A single try statement can have multiple except statements. This is useful when the try block contains statements that may throw different types of exceptions.  You can also provide a generic except clause, which handles any exception.  After the except clause(s), you can include an else-clause. The code in the else-block executes if the code in the try: block does not raise an exception.  The else-block is a good place for code that does not need the try: block's protection.  The except Clause with No Exceptions  You can also use the except statement with no exceptions defined as follows − try: You do your operations here; ...................... except: If there is any exception, then execute this block. ...................... else: If there is no exception then execute this block. Ref: www.tutorialspoint.com Created By : Abishek
  • 34. Cont.  The except Clause with Multiple Exceptions  You can also use the same except statement to handle multiple exceptions as follows − try: You do your operations here; ...................... except(Exception1[, Exception2[,...ExceptionN]]]): If there is any exception from the given exception list, then execute this block. ...................... else: If there is no exception then execute this block. Ref: www.tutorialspoint.com Created By : Abishek
  • 35. Cont.  The try-finally Clause  You can use a finally: block along with a try: block.  The finally block is a place to put any code that must execute, whether the try-block raised an exception or not.  Syntax: try: You do your operations here; ...................... Due to any exception, this may be skipped. finally: This would always be executed. ...................... Ref: www.tutorialspoint.com Created By : Abishek