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
Python programming ppt.pptx
PPTX
Python 3 Programming Language
PPTX
Phython Programming Language
PDF
Python - the basics
PPTX
Introduction to python
PPTX
Basics of python
PDF
Python Workshop
Python tutorial
Python programming ppt.pptx
Python 3 Programming Language
Phython Programming Language
Python - the basics
Introduction to python
Basics of python
Python Workshop

What's hot (20)

PPTX
Python Libraries and Modules
PDF
Python libraries
PDF
Installing Anaconda Distribution of Python
PPTX
Full Python in 20 slides
PPTX
Introduction to-python
PPTX
Python programming
PDF
Introduction to Python IDLE | IDLE Tutorial | Edureka
PDF
Python: the Project, the Language and the Style
PPTX
Python presentation
PDF
Python Visual Studio | Edureka
PPTX
Python Integrated Development Environment
PPTX
Beginning Python Programming
PPTX
Intro to Python Programming Language
PPTX
Python
PDF
Introduction to python
PDF
Python Basics.pdf
PPTX
Python Tutorial Part 1
PPTX
Introduction to Python Programming Basics
PPTX
Python final presentation kirti ppt1
PPTX
Understanding open max il
Python Libraries and Modules
Python libraries
Installing Anaconda Distribution of Python
Full Python in 20 slides
Introduction to-python
Python programming
Introduction to Python IDLE | IDLE Tutorial | Edureka
Python: the Project, the Language and the Style
Python presentation
Python Visual Studio | Edureka
Python Integrated Development Environment
Beginning Python Programming
Intro to Python Programming Language
Python
Introduction to python
Python Basics.pdf
Python Tutorial Part 1
Introduction to Python Programming Basics
Python final presentation kirti ppt1
Understanding open max il
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
Python - An Introduction
PPTX
Session-1_Introduction to Python.pptx
PPTX
PYTHON UNIT 1
PPTX
Chapter - 1.pptx
PPTX
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.pptx
PDF
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
PPTX
Lecture - 1 (Python) E-Notes.pptx important
PPTX
Python learning notes for freshers and also beginners.
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
Python - An Introduction
Session-1_Introduction to Python.pptx
PYTHON UNIT 1
Chapter - 1.pptx
a9855c3532e13484ee6a39ba30218896d7c0d863-1676987272842.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
Lecture - 1 (Python) E-Notes.pptx important
Python learning notes for freshers and also beginners.
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)

PDF
Business Ethics Teaching Materials for college
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Introduction and Scope of Bichemistry.pptx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Onica Farming 24rsclub profitable farm business
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
PPTX
Cardiovascular Pharmacology for pharmacy students.pptx
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Basic Mud Logging Guide for educational purpose
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Pre independence Education in Inndia.pdf
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Open folder Downloads.pdf yes yes ges yes
Business Ethics Teaching Materials for college
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
human mycosis Human fungal infections are called human mycosis..pptx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Introduction and Scope of Bichemistry.pptx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
TR - Agricultural Crops Production NC III.pdf
Onica Farming 24rsclub profitable farm business
2.FourierTransform-ShortQuestionswithAnswers.pdf
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
Open Quiz Monsoon Mind Game Final Set.pptx
Cardiovascular Pharmacology for pharmacy students.pptx
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Basic Mud Logging Guide for educational purpose
O7-L3 Supply Chain Operations - ICLT Program
Pre independence Education in Inndia.pdf
NOI Hackathon - Summer Edition - GreenThumber.pptx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Open folder Downloads.pdf yes yes ges yes

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