SlideShare a Scribd company logo
Section: BS in Information Technology - 2A
Day: FRI
Time: 1:00-4:00
Instructor: Percival A. Fernandez, MSIT
Python Programming Part 1.pdf
WHAT IS PYTHON
• Python is a popular programming language. It was created by Guido van Rossum, and released
in 1991.
• It is used for:
• web development (server-side),
• software development,
• mathematics,
• system scripting.
WHAT IS PYTHON
• Python is a high-level, general-purpose and a very popular programming language. Python
programming language (latest Python 3) is being used in web development, Machine Learning
applications, along with all cutting edge technology in Software Industry.
• Python Programming Language is very well suited for Beginners, also for experienced
programmers with other programming languages like C++ and Java.
• Python is a very popular general-purpose interpreted, interactive, object-oriented, and high-level
programming language. Python is dynamically-typed and garbage-collected programming
language. It was created by Guido van Rossum during 1985- 1990.
• Like Perl, Python source code is also available under the GNU General Public License (GPL).
• Python is a popular programming language.
• Python can be used on a server to create web applications.
CAREERS WITH PYTHON
• If you know Python nicely, then you have a great career ahead. Here are just a few of the
career options where Python is a key skill:
 Game developer
 Web designer
 Python developer
 Full-stack developer
 Machine learning engineer
 Data scientist
 Data analyst
 Data engineer
 DevOps engineer
 Software engineer
 Many more other roles
FACTS ABOUT PYTHON PROGRAMMING LANGUAGE
• Python is currently the most widely used multi-purpose, high-level programming language.
• Python allows programming in Object-Oriented and Procedural paradigms.
• Python programs generally are smaller than other programming languages like Java.
Programmers have to type relatively less and indentation requirement of the language, makes
them readable all the time.
• Python language is being used by almost all tech-giant companies like – Google, Amazon,
Facebook, Instagram, Dropbox, Uber… etc.
FACTS ABOUT PYTHON PROGRAMMING LANGUAGE
• The biggest strength of Python is huge collection of standard library which can be used for the
following:
• Machine Learning
• GUI Applications (like Kivy, Tkinter, PyQt etc. )
• Web frameworks like Django (used by YouTube, Instagram, Dropbox)
• Image processing (like OpenCV, Pillow)
• Web scraping (like Scrapy, BeautifulSoup, Selenium)
• Test frameworks
• Multimedia
• Scientific computing
• Text processing and many more..
WHY TO LEARN PYTHON?
• Python is consistently rated as one of the world's most popular programming languages.
• Python is fairly easy to learn, so if you are starting to learn any programming language then
Python could be your great choice.
• Today various Schools, Colleges and Universities are teaching Python as their primary
programming language.
• There are many other good reasons which makes Python as the top choice of any programmer:
 Python is Open Source which means its available free of cost.
 Python is simple and so easy to learn
 Python is versatile and can be used to create many different things.
 Python has powerful development libraries include AI, ML etc.
 Python is much in demand and ensures high salary
WHY TO LEARN PYTHON?
• Python is a MUST for students and working professionals to become a great Software Engineer
specially when they are working in Web Development Domain. I will list down some of the key
advantages of learning Python:
 Python is Interpreted − Python is processed at runtime by the interpreter. You do not need
to compile your program before executing it. This is similar to PERL and PHP.
 Python is Interactive − You can actually sit at a Python prompt and interact with the
interpreter directly to write your programs.
 Python is Object-Oriented − Python supports Object-Oriented style or technique of
programming that encapsulates code within objects.
 Python is a Beginner's Language − Python is a great language for the beginner-level
programmers and supports the development of a wide range of applications from simple
text processing to WWW browsers to games.
CHARACTERISTICS OF PYTHON
• Following are important characteristics of Python Programming −
 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.
APPLICATIONS OF PYTHON
• The latest release of Python is 3.x. As mentioned before, Python is one of the most widely used
language over the web. I'm going to list few of them here:
• Easy-to-learn − Python has few keywords, simple structure, and a clearly defined syntax.
This allows the student to pick up the language quickly.
• Easy-to-read − Python code is more clearly defined and visible to the eyes.
• Easy-to-maintain − Python's source code is fairly easy-to-maintain.
• A broad standard library − Python's bulk of the library is very portable and cross-platform
compatible on UNIX, Windows, and Macintosh.
• Interactive Mode − Python has support for an interactive mode which allows interactive
testing and debugging of snippets of code.
• Portable − Python can run on a wide variety of hardware platforms and has the same
interface on all platforms.
APPLICATIONS OF PYTHON
• Extendable − You can add low-level modules to the Python interpreter. These modules
enable programmers to add to or customize their tools to be more efficient.
• Databases − Python provides interfaces to all major commercial databases.
• GUI Programming − Python supports GUI applications that can be created and ported to
many system calls, libraries and windows systems, such as Windows MFC, Macintosh, and the
X Window system of Unix.
• Scalable − Python provides a better structure and support for large programs than shell
scripting.
PYTHON SYNTAX COMPARED TO OTHER PROGRAMMING
LANGUAGES
• Python was designed for readability, and has some similarities to the English language with
influence from mathematics.
• Python uses new lines to complete a command, as opposed to other programming languages
which often use semicolons or parentheses.
• Python relies on indentation, using whitespace, to define scope; such as the scope of loops,
functions and classes. Other programming languages often use curly-brackets for this purpose.
PYTHON - ENVIRONMENT SETUP
• For python installation – please refer to the following links
• https://www.python.org/about/gettingstarted/
• https://wiki.python.org/moin/BeginnersGuide/Download
• https://www.tutorialspoint.com/python/python_environment.htm
• https://www.w3schools.com/python/python_getstarted.asp
• https://realpython.com/installing-python/
PYTHON - BASIC SYNTAX
• The Python syntax defines a set of rules that are used to create Python statements while writing a
Python Program.
• The Python Programming Language Syntax has many similarities to Perl, C, and Java
Programming Languages. However, there are some definite differences between the languages.
• Python syntax can be executed by writing directly in the Command Line:
• Or by creating a python file on the server, using the .py file extension, and running it in the
Command Line:
PYTHON INDENTATION
• Indentation refers to the spaces at the beginning of a code line.
• Where in other programming languages the indentation in code is for readability only, the
indentation in Python is very important.
• Python uses indentation to indicate a block of code.
• The number of spaces is up to you as a programmer, the most common use is four, but it has to be
at least one.
FIRST PYTHON PROGRAM
Python - Interactive Mode Programming
• We can invoke a Python interpreter from command line by typing python at the command
prompt as following −
• Here >>> denotes a Python Command Prompt where you can type your commands. Let's
type the following text at the Python prompt and press the Enter −
• Python - Script Mode Programming
 We can invoke the Python interpreter with a script parameter which begins the execution of
the script and continues until the script is finished. When the script is finished, the interpreter
is no longer active.
 Let us write a simple Python program in a script which is simple text file. Python files have
extension .py. Type the following source code in a test.py file −
• We assume that you have Python interpreter path set in PATH variable. Now, let's try to run
this program as follows −
FIRST PYTHON PROGRAM
PYTHON COMMENTS
• Comments can be used to explain Python code.
• Comments can be used to make the code more readable.
• Comments can be used to prevent execution when testing code.
• Creating a Comment
• Comments starts with a #, and Python will ignore them:
• Comments can be placed at the end of a line, and Python will ignore the rest of the line:
PYTHON IDENTIFIERS
• A Python identifier is a name used to identify a variable, function, class, module or other object.
An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more
letters, underscores and digits (0 to 9).
• Python does not allow punctuation characters such as @, $, and % within identifiers.
• Variables are containers for storing data values.
• Creating Variables
• Python has no command for declaring a variable.
• A variable is created the moment you first assign a value to it.
PYTHON IDENTIFIERS
• Casting
• If you want to specify the data type of a variable, this can be done with casting.
PYTHON IDENTIFIERS
• Single or Double Quotes?
• String variables can be declared either by using single or double quotes:
• Case-Sensitive
• Variable names are case-sensitive.
#A will not overwrite a
PYTHON LINES AND INDENTATION
• Python programming 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. For example −
• However, the following block generates an error −
Thus, in Python all the continuous lines indented with same number
of spaces would form a block.
PYTHON DATA TYPES
• Python Data Types are used to define the type of a variable. It defines what type of data we
are going to store in a variable. The data stored in memory can be of many types.
• For example, a person's age is stored as a numeric value and his or her address is stored as
alphanumeric characters.
PYTHON NUMERIC DATA TYPE
• Python numeric data types store numeric values. Number objects are created when you assign a
value to them. For example −
• Python supports four different numerical types −
• int (signed integers)
• long (long integers, they can also be
represented in octal and hexadecimal)
• float (floating point real values)
• complex (complex numbers)
PYTHON STRING DATA TYPE
• Python Strings are identified as a contiguous set of characters represented in the quotation
marks. Python allows for either pairs of single or double quotes.
• Subsets of strings can be taken using the slice operator ([ ] and [:] ) with indexes starting at 0 in
the beginning of the string and working their way from -1 at the end.
• The plus (+) sign is the string concatenation operator and the asterisk (*) is the repetition
operator in Python. For example −
PYTHON OPERATORS
• Operators are used to perform operations on variables and values.
• Python divides the operators in the following groups:
• Arithmetic operators
• Assignment operators
• Comparison operators
• Logical operators
• Identity operators
• Membership operators
• Bitwise operators
PYTHON ARITHMETIC OPERATORS
• Python arithmetic operators are used to perform
mathematical operations on numerical values. These
operations are Addition, Subtraction, Multiplication,
Division, Modulus, Expoents and Floor Division.
This produce the following result −
PYTHON COMPARISON OPERATORS
• Python comparison operators compare the values on
either sides of them and decide the relation among
them. They are also called relational operators. These
operators are equal, not equal, greater than, less than,
greater than or equal to and less than or equal to.
This produce the following result −
PYTHON ASSIGNMENT OPERATORS
• Python assignment operators are used to assign values
to variables. These operators include simple assignment
operator, addition assign, subtraction assign,
multiplication assign, division and assign operators etc.
This produce the following result −
REFERENCES:
• https://www.python.org/about/gettingstarted/
• https://www.tutorialspoint.com/python/index.htm
• https://www.geeksforgeeks.org/python-programming-language/
• https://www.w3schools.com/python/default.asp

More Related Content

PDF
Python tutorial
PPTX
Welcome to python workshop
PPTX
Beginning Python Programming
PDF
Intro to Python for Non-Programmers
PPTX
Basics of python
PDF
Python, the Language of Science and Engineering for Engineers
PPTX
Python basics
PPTX
Python presentation by Monu Sharma
Python tutorial
Welcome to python workshop
Beginning Python Programming
Intro to Python for Non-Programmers
Basics of python
Python, the Language of Science and Engineering for Engineers
Python basics
Python presentation by Monu Sharma

What's hot (20)

PPTX
Python - An Introduction
PPT
Python ppt
PDF
API Testing: The heart of functional testing" with Bj Rollison
PPTX
Basic Python Programming: Part 01 and Part 02
PPT
Introduction to cython
PPSX
API Test Automation
PDF
Introduction to Robot Framework – Exove
PDF
API Testing
PPTX
POWER OF PYTHON PROGRAMMING LANGUAGE
PPTX
Understand more about C
PDF
05 python.pdf
PDF
Introduction to python
PPTX
Python-00 | Introduction and installing
PDF
chapter-8-function-overloading.pdf
PDF
Introduction To Mobile-Automation
PDF
Postman & API Testing by Amber Race
PPTX
Automation With Appium
PPTX
Open Source Software
PDF
Api presentation
PPT
Robustness testing
Python - An Introduction
Python ppt
API Testing: The heart of functional testing" with Bj Rollison
Basic Python Programming: Part 01 and Part 02
Introduction to cython
API Test Automation
Introduction to Robot Framework – Exove
API Testing
POWER OF PYTHON PROGRAMMING LANGUAGE
Understand more about C
05 python.pdf
Introduction to python
Python-00 | Introduction and installing
chapter-8-function-overloading.pdf
Introduction To Mobile-Automation
Postman & API Testing by Amber Race
Automation With Appium
Open Source Software
Api presentation
Robustness testing
Ad

Similar to Python Programming Part 1.pdf (20)

PDF
Python Programming.pdf
PPTX
Chapter 2: Basics of programming pyton programming
PPT
1-ppt-python.ppt
PDF
Unit 1-Part-1-Introduction to Python.pdf
PDF
Module 1 Review of Python Basics An Introduction
PPT
Python for students step by step guidance
PPTX
Session-1_Introduction to Python.pptx
PPTX
PYTHON UNIT 1
PPTX
Chapter - 1.pptx
PPTX
Introduction to Python Programming Basics
PPTX
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
PPTX
Python final presentation kirti ppt1
PDF
PPTX
Python programming ppt.pptx
PDF
summer t.pdf
PDF
Computer Related material named Phython ok
PDF
Introduction To Python For Beginners
PPTX
introduction to python in computer graphics.pptx
PDF
Python Programing Bio computing,basic concepts lab,,
PPTX
university notes Lecture - 1 (Python) E-Notes.pptx
Python Programming.pdf
Chapter 2: Basics of programming pyton programming
1-ppt-python.ppt
Unit 1-Part-1-Introduction to Python.pdf
Module 1 Review of Python Basics An Introduction
Python for students step by step guidance
Session-1_Introduction to Python.pptx
PYTHON UNIT 1
Chapter - 1.pptx
Introduction to Python Programming Basics
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
Python final presentation kirti ppt1
Python programming ppt.pptx
summer t.pdf
Computer Related material named Phython ok
Introduction To Python For Beginners
introduction to python in computer graphics.pptx
Python Programing Bio computing,basic concepts lab,,
university notes Lecture - 1 (Python) E-Notes.pptx
Ad

More from percivalfernandez2 (9)

PDF
Module 2-Review of Python Decision making and Loops.pdf
PPTX
Wk_10_Scanner and BufferedReader Class in Java.pptx
PPTX
Module 3 - Software Classification.pptx
PPTX
Data Analytics.pptx
PPTX
Python Programming Part 8 - MYSQL.pptx
PPTX
Wk8_Expansion and External Input and Output Devices.pptx
PDF
Advance C# Programming Part 1.pdf
PDF
Python Programming Part 3.pdf
PDF
Python Programming Part 1.pdf
Module 2-Review of Python Decision making and Loops.pdf
Wk_10_Scanner and BufferedReader Class in Java.pptx
Module 3 - Software Classification.pptx
Data Analytics.pptx
Python Programming Part 8 - MYSQL.pptx
Wk8_Expansion and External Input and Output Devices.pptx
Advance C# Programming Part 1.pdf
Python Programming Part 3.pdf
Python Programming Part 1.pdf

Recently uploaded (20)

PPTX
master seminar digital applications in india
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Pharma ospi slides which help in ospi learning
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
Basic Mud Logging Guide for educational purpose
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Pre independence Education in Inndia.pdf
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
01-Introduction-to-Information-Management.pdf
master seminar digital applications in india
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Microbial diseases, their pathogenesis and prophylaxis
Insiders guide to clinical Medicine.pdf
Pharma ospi slides which help in ospi learning
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
FourierSeries-QuestionsWithAnswers(Part-A).pdf
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Basic Mud Logging Guide for educational purpose
Abdominal Access Techniques with Prof. Dr. R K Mishra
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Pre independence Education in Inndia.pdf
TR - Agricultural Crops Production NC III.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPH.pptx obstetrics and gynecology in nursing
01-Introduction-to-Information-Management.pdf

Python Programming Part 1.pdf

  • 1. Section: BS in Information Technology - 2A Day: FRI Time: 1:00-4:00 Instructor: Percival A. Fernandez, MSIT
  • 3. WHAT IS PYTHON • Python is a popular programming language. It was created by Guido van Rossum, and released in 1991. • It is used for: • web development (server-side), • software development, • mathematics, • system scripting.
  • 4. WHAT IS PYTHON • Python is a high-level, general-purpose and a very popular programming language. Python programming language (latest Python 3) is being used in web development, Machine Learning applications, along with all cutting edge technology in Software Industry. • Python Programming Language is very well suited for Beginners, also for experienced programmers with other programming languages like C++ and Java. • Python is a very popular general-purpose interpreted, interactive, object-oriented, and high-level programming language. Python is dynamically-typed and garbage-collected programming language. It was created by Guido van Rossum during 1985- 1990. • Like Perl, Python source code is also available under the GNU General Public License (GPL). • Python is a popular programming language. • Python can be used on a server to create web applications.
  • 5. CAREERS WITH PYTHON • If you know Python nicely, then you have a great career ahead. Here are just a few of the career options where Python is a key skill:  Game developer  Web designer  Python developer  Full-stack developer  Machine learning engineer  Data scientist  Data analyst  Data engineer  DevOps engineer  Software engineer  Many more other roles
  • 6. FACTS ABOUT PYTHON PROGRAMMING LANGUAGE • Python is currently the most widely used multi-purpose, high-level programming language. • Python allows programming in Object-Oriented and Procedural paradigms. • Python programs generally are smaller than other programming languages like Java. Programmers have to type relatively less and indentation requirement of the language, makes them readable all the time. • Python language is being used by almost all tech-giant companies like – Google, Amazon, Facebook, Instagram, Dropbox, Uber… etc.
  • 7. FACTS ABOUT PYTHON PROGRAMMING LANGUAGE • The biggest strength of Python is huge collection of standard library which can be used for the following: • Machine Learning • GUI Applications (like Kivy, Tkinter, PyQt etc. ) • Web frameworks like Django (used by YouTube, Instagram, Dropbox) • Image processing (like OpenCV, Pillow) • Web scraping (like Scrapy, BeautifulSoup, Selenium) • Test frameworks • Multimedia • Scientific computing • Text processing and many more..
  • 8. WHY TO LEARN PYTHON? • Python is consistently rated as one of the world's most popular programming languages. • Python is fairly easy to learn, so if you are starting to learn any programming language then Python could be your great choice. • Today various Schools, Colleges and Universities are teaching Python as their primary programming language. • There are many other good reasons which makes Python as the top choice of any programmer:  Python is Open Source which means its available free of cost.  Python is simple and so easy to learn  Python is versatile and can be used to create many different things.  Python has powerful development libraries include AI, ML etc.  Python is much in demand and ensures high salary
  • 9. WHY TO LEARN PYTHON? • Python is a MUST for students and working professionals to become a great Software Engineer specially when they are working in Web Development Domain. I will list down some of the key advantages of learning Python:  Python is Interpreted − Python is processed at runtime by the interpreter. You do not need to compile your program before executing it. This is similar to PERL and PHP.  Python is Interactive − You can actually sit at a Python prompt and interact with the interpreter directly to write your programs.  Python is Object-Oriented − Python supports Object-Oriented style or technique of programming that encapsulates code within objects.  Python is a Beginner's Language − Python is a great language for the beginner-level programmers and supports the development of a wide range of applications from simple text processing to WWW browsers to games.
  • 10. CHARACTERISTICS OF PYTHON • Following are important characteristics of Python Programming −  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.
  • 11. APPLICATIONS OF PYTHON • The latest release of Python is 3.x. As mentioned before, Python is one of the most widely used language over the web. I'm going to list few of them here: • Easy-to-learn − Python has few keywords, simple structure, and a clearly defined syntax. This allows the student to pick up the language quickly. • Easy-to-read − Python code is more clearly defined and visible to the eyes. • Easy-to-maintain − Python's source code is fairly easy-to-maintain. • A broad standard library − Python's bulk of the library is very portable and cross-platform compatible on UNIX, Windows, and Macintosh. • Interactive Mode − Python has support for an interactive mode which allows interactive testing and debugging of snippets of code. • Portable − Python can run on a wide variety of hardware platforms and has the same interface on all platforms.
  • 12. APPLICATIONS OF PYTHON • Extendable − You can add low-level modules to the Python interpreter. These modules enable programmers to add to or customize their tools to be more efficient. • Databases − Python provides interfaces to all major commercial databases. • GUI Programming − Python supports GUI applications that can be created and ported to many system calls, libraries and windows systems, such as Windows MFC, Macintosh, and the X Window system of Unix. • Scalable − Python provides a better structure and support for large programs than shell scripting.
  • 13. PYTHON SYNTAX COMPARED TO OTHER PROGRAMMING LANGUAGES • Python was designed for readability, and has some similarities to the English language with influence from mathematics. • Python uses new lines to complete a command, as opposed to other programming languages which often use semicolons or parentheses. • Python relies on indentation, using whitespace, to define scope; such as the scope of loops, functions and classes. Other programming languages often use curly-brackets for this purpose.
  • 14. PYTHON - ENVIRONMENT SETUP • For python installation – please refer to the following links • https://www.python.org/about/gettingstarted/ • https://wiki.python.org/moin/BeginnersGuide/Download • https://www.tutorialspoint.com/python/python_environment.htm • https://www.w3schools.com/python/python_getstarted.asp • https://realpython.com/installing-python/
  • 15. PYTHON - BASIC SYNTAX • The Python syntax defines a set of rules that are used to create Python statements while writing a Python Program. • The Python Programming Language Syntax has many similarities to Perl, C, and Java Programming Languages. However, there are some definite differences between the languages. • Python syntax can be executed by writing directly in the Command Line: • Or by creating a python file on the server, using the .py file extension, and running it in the Command Line:
  • 16. PYTHON INDENTATION • Indentation refers to the spaces at the beginning of a code line. • Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important. • Python uses indentation to indicate a block of code. • The number of spaces is up to you as a programmer, the most common use is four, but it has to be at least one.
  • 17. FIRST PYTHON PROGRAM Python - Interactive Mode Programming • We can invoke a Python interpreter from command line by typing python at the command prompt as following − • Here >>> denotes a Python Command Prompt where you can type your commands. Let's type the following text at the Python prompt and press the Enter −
  • 18. • Python - Script Mode Programming  We can invoke the Python interpreter with a script parameter which begins the execution of the script and continues until the script is finished. When the script is finished, the interpreter is no longer active.  Let us write a simple Python program in a script which is simple text file. Python files have extension .py. Type the following source code in a test.py file − • We assume that you have Python interpreter path set in PATH variable. Now, let's try to run this program as follows − FIRST PYTHON PROGRAM
  • 19. PYTHON COMMENTS • Comments can be used to explain Python code. • Comments can be used to make the code more readable. • Comments can be used to prevent execution when testing code. • Creating a Comment • Comments starts with a #, and Python will ignore them: • Comments can be placed at the end of a line, and Python will ignore the rest of the line:
  • 20. PYTHON IDENTIFIERS • A Python identifier is a name used to identify a variable, function, class, module or other object. An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores and digits (0 to 9). • Python does not allow punctuation characters such as @, $, and % within identifiers. • Variables are containers for storing data values. • Creating Variables • Python has no command for declaring a variable. • A variable is created the moment you first assign a value to it.
  • 21. PYTHON IDENTIFIERS • Casting • If you want to specify the data type of a variable, this can be done with casting.
  • 22. PYTHON IDENTIFIERS • Single or Double Quotes? • String variables can be declared either by using single or double quotes: • Case-Sensitive • Variable names are case-sensitive. #A will not overwrite a
  • 23. PYTHON LINES AND INDENTATION • Python programming 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. For example − • However, the following block generates an error − Thus, in Python all the continuous lines indented with same number of spaces would form a block.
  • 24. PYTHON DATA TYPES • Python Data Types are used to define the type of a variable. It defines what type of data we are going to store in a variable. The data stored in memory can be of many types. • For example, a person's age is stored as a numeric value and his or her address is stored as alphanumeric characters.
  • 25. PYTHON NUMERIC DATA TYPE • Python numeric data types store numeric values. Number objects are created when you assign a value to them. For example − • Python supports four different numerical types − • int (signed integers) • long (long integers, they can also be represented in octal and hexadecimal) • float (floating point real values) • complex (complex numbers)
  • 26. PYTHON STRING DATA TYPE • Python Strings are identified as a contiguous set of characters represented in the quotation marks. Python allows for either pairs of single or double quotes. • Subsets of strings can be taken using the slice operator ([ ] and [:] ) with indexes starting at 0 in the beginning of the string and working their way from -1 at the end. • The plus (+) sign is the string concatenation operator and the asterisk (*) is the repetition operator in Python. For example −
  • 27. PYTHON OPERATORS • Operators are used to perform operations on variables and values. • Python divides the operators in the following groups: • Arithmetic operators • Assignment operators • Comparison operators • Logical operators • Identity operators • Membership operators • Bitwise operators
  • 28. PYTHON ARITHMETIC OPERATORS • Python arithmetic operators are used to perform mathematical operations on numerical values. These operations are Addition, Subtraction, Multiplication, Division, Modulus, Expoents and Floor Division. This produce the following result −
  • 29. PYTHON COMPARISON OPERATORS • Python comparison operators compare the values on either sides of them and decide the relation among them. They are also called relational operators. These operators are equal, not equal, greater than, less than, greater than or equal to and less than or equal to. This produce the following result −
  • 30. PYTHON ASSIGNMENT OPERATORS • Python assignment operators are used to assign values to variables. These operators include simple assignment operator, addition assign, subtraction assign, multiplication assign, division and assign operators etc. This produce the following result −
  • 31. REFERENCES: • https://www.python.org/about/gettingstarted/ • https://www.tutorialspoint.com/python/index.htm • https://www.geeksforgeeks.org/python-programming-language/ • https://www.w3schools.com/python/default.asp