SlideShare a Scribd company logo
PYTHON
GETTING STARTED WITH PYTHON
CLASS: XI
COMPUTER SCIENCE(083)
What is Python?
Python is an object-oriented programming language developed by Guido Van
Rossum in 1991.Python is a general purpose, dynamic, high-level language. It
supports Object Oriented programming approach to develop applications. It
is simple and easy to learn. Its an open source language.
Python programming is widely used in Artificial Intelligence, Natural
Language Generation and other advanced fields of Computer Science.
Python files have extension filename.py
So if you want to save the file of python then write:
myfile.py
What is High-level language?
A high-level language is a programming language which is designed to make
computer programming easy to understand. All these HLL source code
converted into machine understandable code with the help of there compilers
that convert it.
It is a programming language such as C, FORTRAN, or Pascal that enables a
programmer to write programs that are more or less independent of a
particular type of computer. Such languages are considered high-level because
they are closer to human languages and further from machine languages.
Java , C++ , C# , Visual Basic , JavaScript, Python
Object Oriented programming
OOP stands for Object-Oriented Programming. Object-oriented programming is
about creating objects that contain both data and functions.
It is based on objects, instead of just functions and procedures. An "object" is a
instance of a class. Each object has a structure similar to other objects in the class,
but can be assigned individual characteristics.
Class Object
A class is a template or a blu-print
representing a group of objects that
share common properties and
relationships.
An object is a instance of a class. An
object is nothing but a self-contained
component which consists of
methods/behaviors and
properties/states.
Let us understand
Class:
A class is a template or a blu-print representing a group of objects that
share common properties and relationships.
Class is divided into two part:
State/Attributes Behaviors
The state or attributes are the
built in characteristics or
properties of an object
The behavior or operations of an
object are its predefined functions
Let us understand with the help of example:
Television
Class
State/Attributes
size, colour, model,
sound,channels etc.
------------------------
Behaviors
PowerOn, PowerOff,
Increase(+)/Decrease(-)
volume etc.
Objects
Samsung
Sony
LG
Let us understand with the help of example:
Class: DOG
State/Attributes
Breed, size, colour,age
------------------------
Behaviors
Eat,Run,Sleep…..
State/Attributes
Breed=“Germanshepard”
Size= Large
Colour= Dark Brown
Age= 5 years
State/Attributes
Breed=“Pug”
Size= small
Colour= light brown
Age= 1 years
Object
Python is known for its general-purpose nature that makes it applicable in almost
every domain of software development. It provides libraries to handle
Python Applications
Web Applications
Desktop GUI Applications
Console-based Application
Software Development
Scientific and Numeric
Business Applications
Audio or Video-based ApplicationsImage Processing Application
Python Features
Easy to Learn and Use
Expressive Language
Interpreted Language
Cross-platform Language
Python is easy to learn as compared to other programming languages.
Python can perform complex tasks using a few lines of code.
it means the Python program is executed one line at a time.
Python can run equally on different platforms such as Windows, Linux, UNIX, and Macintosh,
etc. So, we can say that Python is a portable language.
Free and Open Source
Object-Oriented Language
Large Standard Library
GUI Programming Support
Embeddable
Python is freely available for everyone.
Python supports object-oriented language and concepts of classes and objects come
into existence.
It provides a vast range of libraries for the various fields such as machine
learning, web developer, and also for the scripting.
The code of the other programming language can use in the Python source code. We can use
Python source code in another programming language as well.
Graphical User Interface is used for the developing Desktop application. PyQT5, Tkinter, Kivy
are the libraries which are used for developing the web application.
How to Install Python
Visit the link https://www.python.org/downloads/ to download the
latest release of Python.
Python IDEs
IDE stands for Integrated Development Environment is defined as a coding tool that helps to
automate the process of editing, compiling, testing, etc.
Pyroid3 for Android Mobile.
Python Character Set:
Character set is an asset of valid characters that a language can
recognize. A character can represents any letter, digit, or any
other sign.
Following are some of the character set.
LETTERS A to Z and a to z
DIGITS 0 – 9
SPECIAL SYMBOLS + -*  [] {} = != < > . ‘ ‘ ; : & #
WHITE SPACE Blank space , horizontal tab
TOKENS:
In a passage of text, individual words and punctuation marks or
smallest lexical unit in a program is known as token.
keywords Identifier Literals
PunctuatorsOperators
keywords
Keywords are the reserved words in Python. keywords are case
sensitive. There are 33 keywords. Each keyword has a special
meaning and a specific operation, we cant modify or change the
meaning of these keywords.
True False None and as
asset def class continue break
else finally elif del except
global for if from import
raise try or return pass
nonlocal in not is lambda
Identifier
An identifier is a name given to entities like variables, functions,
classes etc. It helps to differentiate one entity from another.
Rules for writing identifiers
identifiers can be a combination of letters in lowercase (a to z) or
uppercase (A to Z) or digits (0 to 9) or an underscore (_)
An identifier cannot start with a digit.Example:
1var ab+1 ad 123 ch$ Ab#12
Invalid
So if we need to write a valid identifiers are:
ABC1 abc12 ad12cd ab_123 _abc
Invalid identifiers are:
12abc abc 12 ab@12 ab$$1 Ab*%1
It means if we use any special symbols with letters then its
an invalid identifiers or spaces between the characters
Ab+1
Literals
Literals referred as Constants also, python Literals can be defined as
data that is given in a variable. These are data items that never
change their value during a program run.
Kinds of Literals are:
Character Literals: String Literals: Integer Literals: Floating Literals:
Bool Literals:
One character enclosed in single quotes, as ‘A’ or in double quotes
“A”
Example:
ch=‘A’
Or
ch=“B”
Character Literals:
String literals can be formed by enclosing a text in the quotes.
We can use both single(‘) as well as double quotes(“) to create
a string.
Example:
name=“Rohan”
Or
Name=‘Rohan’
String Literals:
An integer is a numeric literal(associated with numbers)
without any fractional or exponential part. There are three
types of integer literals in python programming:
decimal (base 10)
octal (base 8)
hexadecimal (base 16)
Example:
A=10
B=-23
Number Literals:
Floating-point Literals
A floating-point literal is a numeric literal that has either a
fractional form or an exponent form. For example:
Example:
A=2.445
B=0.5567
C=-2.345
A Boolean literal can have any of the two values: True or False.
Example:
result=(10==20)
The result will store result in the form of True
or False
Bool Literals:
Punctuators
These are also known as separators.
Brackets: [ ] Parentheses ( ) Braces { }
Comma , Semi colon ; colon :
and many signs……
Operators
Operators are special symbols which represent computation.
They are applied on operands which can be values or variable.
Example: +, -, / , * ……..
How write Comments in python?
Comments are very important while writing a program. These
are ignored by the python interpreter and have no effect on
the actual output code. Comments make the code more
readable and understandable for human being. Comment
describe what is going on inside a program before looking at
the source code.
In Python, we use the hash (#) symbol to
start writing a comment.
#This is a comment
Single line Comments :
Put the # hash sign and then the statement
#This is a comment1
#This is a comment2
#This is a comment3
Multi line Comments :
Put the # hash sign and then the statement , then write
another statement with # hash sign
How to display statements using print() function.
So if we want to display any statement in python we have to
use print() function
Example: if we want to print statement
“Hello Python, Welcome to programming”
print(“Hello Python, Welcome to programming”)
So if we want to display output as shown below:
++++++
######
======
print(“++++++”)
print(“######”)
print(“======”)
So if we want to display output as shown below:
***********
* *
* *
***********
Line 1
Line 2
Line 3
Line 4
“***********”print( )
print( )“* *”
print( )“* *”
print( )“***********”
In Line 2 and Line 3 After first *
there is a space for that we need
to press spacebar
Using print display the following outputs:
***********
*
*
*****
*
*
*
* * * * * * *
*
*
* * * * *
*
*
*
*
print(“***************”)
print(“*”)
print(“*”)
print(“*”)
print(“**********”)
print(“*”)
print(“*”)
print(“*”)
Using print display the following outputs:
A
@
@ @
@@@@@
@ @
@ @
print(“ @”)
These blank box
are spaces press
spacebar
print(“ @ @”)
print(“ @@@@@”)
print(“ @ @”)
print(“@ @”)
Using print display the following outputs:
* * * * * *
* *
* * * * * *
*
* * * * *
* * * * *
* *
* * * *
Python Escape Characters
To insert characters that are illegal in a string, use an escape
character.
An escape character is a backslash  followed by the
character you want to insert.
n New Line It move the cursor to next line
t Tab It is use for horizontal tab
b Backspace
it move cursor one step back and overwrite the
character with next character over it.
We are the so-called "Vikings" from the north.
If we want to print the output as shown below:
print ("We are the so-called "Vikings" from the north.")
If we write the print line as shown below it will display
error:
To solve this error : Use the escape character "
print ("We are the so-called "Vikings" from the north.")
If we want to print the output as shown below using single
print:
We WELCOME You to Python program
We WELCOME
You to
Python program
print ("We WELCOMEn Yout ton Pythont program")
Next Line use n
Next Line use n
Use tab t
Use tab t
If we want to print the output using backslash b :
Example: remove double letters from the word given below:
WWELCCOMME
Output using b :
WELCOME
print ("WbWELCbCOMbME")
If we use b between W and W in an above statement, it will
overwrite W with next W, same with C and M
More use of print():
Syntax:
print(values or statements, sep=‘ ‘, end=‘n’)
sep:- string or symbol inserted between values, by default , a
space
end:- string appended after the last value, default, a new line
Example:
print(10,20,30)
----Output----
10 20 30
If we want to print the output 10 20 30 with comma(,) sign
use sep, it means separator
Example:
print(10,20,30,sep=“,”)
----Output----
10,20,30
If we want to print the output 10 20 30 with (* or &) sign use
sep, it means seperator
Example:
print(10,20,30,sep=“*”)
----Output----
10*20*30
Example:
print(10,20,30,sep=“&”)
----Output----
10&20&30
If we want to print the output 10 20 30 with space using t
Example:
print(10,20,30,sep=“t”)
----Output----
10 20 30
If we write print(10,20,30) in a separate line using n.How
you print.
print(10,20,30,sep=“n”) ----Output----10
20
30
If we want to print the output like this given below:
APPLE,GRAPES,MANGO !!!!!!!!
Hint : we have to use sep for comma(,) and (!) inside end
print(‘APPLE’,’GRAPES’,’MANGO’, sep=“,”,end=‘!!WOWn’)
----Output----
APPLE,GRAPES,MANGO !!WOW
Variable:
Variable is a name that is used to refer to memory location.
Python variable is also known as an identifier and used to hold
value.
A Python variable is a reserved memory location to store
values. In other words, a variable in a python program gives
data to the computer for processing.
How to Declare , Initialize and use a Variable
Example: If we want to store a value 20 in a variable A.
Means we need to declare a variable A and store value 20 as
integer / number(0-9)
A=20
Example: If we want to store a value ‘A’ character in a
variable ch. Means we need to declare a variable ch and store
character ‘A’ in it.
ch=‘A’ Character , words or paragraph use single quotes (‘)
or double quotes(“)
How to Declare , Initialize and use a Variable
Example: If we want to store a value ‘computer’ word or
string in a variable nm. Means we need to declare a variable
nm and store word ‘computer’ in it.
nm=‘computer’
Character , words or paragraph use single quotes (‘) or
double quotes(“)
nm=“computer”
OR

More Related Content

ODP
CProgrammingTutorial
PPT
Unit 4 Foc
PPT
Javascript by Yahoo
PPTX
Introduction of c programming unit-ii ppt
DOCX
C-PROGRAM
PDF
Learning c - An extensive guide to learn the C Language
PPTX
basics of c++
PPTX
CProgrammingTutorial
Unit 4 Foc
Javascript by Yahoo
Introduction of c programming unit-ii ppt
C-PROGRAM
Learning c - An extensive guide to learn the C Language
basics of c++

What's hot (20)

PPT
C material
PPTX
OOP Poster Presentation
PDF
POLITEKNIK MALAYSIA
PDF
Assignment4
PDF
C programming
PDF
POLITEKNIK MALAYSIA
PPTX
C++ Basics introduction to typecasting Webinar Slides 1
PPT
The smartpath information systems c pro
PPT
Introduction to C Programming - I
ODP
Basic C Programming language
PDF
C programming notes
PPT
Basics1
PPTX
PPT
C by balaguruswami - e.balagurusamy
PDF
Introduction to c++ ppt 1
DOC
C notes for exam preparation
PPT
Lecture 04 syntax analysis
PPTX
C programming Training in Ambala ! Batra Computer Centre
PPTX
System Programming Unit IV
C material
OOP Poster Presentation
POLITEKNIK MALAYSIA
Assignment4
C programming
POLITEKNIK MALAYSIA
C++ Basics introduction to typecasting Webinar Slides 1
The smartpath information systems c pro
Introduction to C Programming - I
Basic C Programming language
C programming notes
Basics1
C by balaguruswami - e.balagurusamy
Introduction to c++ ppt 1
C notes for exam preparation
Lecture 04 syntax analysis
C programming Training in Ambala ! Batra Computer Centre
System Programming Unit IV
Ad

Similar to Python Introduction (20)

PDF
Python-01| Fundamentals
PDF
Introduction of Python
PPTX
UNIT 1 PYTHON introduction and basic level
PPTX
11-unit1chapter02pythonfundamentals-180823043011.pptx
PPTX
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
PDF
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
PPTX
python ppt | Python Course In Ghaziabad | Scode Network Institute
PPTX
Introduction-to-Python.pptx grade 9 ICT.
PDF
How To Tame Python
PPTX
Python introduction towards data science
PDF
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
PPTX
Python - An Introduction
PDF
PPTX
Chapter 1-Introduction and syntax of python programming.pptx
PDF
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
PDF
Intro-to-Python-Part-1-first-part-edition.pdf
PPTX
Introduction on basic python and it's application
PPT
Python Programming Introduction demo.ppt
PDF
Fundamentals of python
Python-01| Fundamentals
Introduction of Python
UNIT 1 PYTHON introduction and basic level
11-unit1chapter02pythonfundamentals-180823043011.pptx
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
PART - 1 Python Introduction- Variables- Data types - Numeric- String- Boole...
python ppt | Python Course In Ghaziabad | Scode Network Institute
Introduction-to-Python.pptx grade 9 ICT.
How To Tame Python
Python introduction towards data science
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
Python - An Introduction
Chapter 1-Introduction and syntax of python programming.pptx
WEB PROGRAMMING UNIT VIII BY BHAVSINGH MALOTH
Intro-to-Python-Part-1-first-part-edition.pdf
Introduction on basic python and it's application
Python Programming Introduction demo.ppt
Fundamentals of python
Ad

More from vikram mahendra (20)

PPTX
Communication skill
PDF
Python Project On Cosmetic Shop system
PDF
Python Project on Computer Shop
PDF
PYTHON PROJECT ON CARSHOP SYSTEM
PDF
BOOK SHOP SYSTEM Project in Python
PPTX
FLOW OF CONTROL-NESTED IFS IN PYTHON
PPTX
FLOWOFCONTROL-IF..ELSE PYTHON
PPTX
FLOW OF CONTROL-INTRO PYTHON
PPTX
OPERATOR IN PYTHON-PART1
PPTX
OPERATOR IN PYTHON-PART2
PPTX
USE OF PRINT IN PYTHON PART 2
PPTX
DATA TYPE IN PYTHON
PPTX
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
PPTX
USER DEFINE FUNCTIONS IN PYTHON
PPTX
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
PPTX
INTRODUCTION TO FUNCTIONS IN PYTHON
PPTX
GREEN SKILL[PART-2]
PPTX
GREEN SKILLS[PART-1]
PPTX
Dictionary in python
PPTX
Entrepreneurial skills
Communication skill
Python Project On Cosmetic Shop system
Python Project on Computer Shop
PYTHON PROJECT ON CARSHOP SYSTEM
BOOK SHOP SYSTEM Project in Python
FLOW OF CONTROL-NESTED IFS IN PYTHON
FLOWOFCONTROL-IF..ELSE PYTHON
FLOW OF CONTROL-INTRO PYTHON
OPERATOR IN PYTHON-PART1
OPERATOR IN PYTHON-PART2
USE OF PRINT IN PYTHON PART 2
DATA TYPE IN PYTHON
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON
FUNCTIONS IN PYTHON[RANDOM FUNCTION]
INTRODUCTION TO FUNCTIONS IN PYTHON
GREEN SKILL[PART-2]
GREEN SKILLS[PART-1]
Dictionary in python
Entrepreneurial skills

Recently uploaded (20)

PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Computing-Curriculum for Schools in Ghana
PDF
RMMM.pdf make it easy to upload and study
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Lesson notes of climatology university.
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
GDM (1) (1).pptx small presentation for students
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 Đ...
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Pre independence Education in Inndia.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
VCE English Exam - Section C Student Revision Booklet
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Computing-Curriculum for Schools in Ghana
RMMM.pdf make it easy to upload and study
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Basic Mud Logging Guide for educational purpose
Pharma ospi slides which help in ospi learning
Lesson notes of climatology university.
Microbial disease of the cardiovascular and lymphatic systems
Sports Quiz easy sports quiz sports quiz
GDM (1) (1).pptx small presentation for students
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
O5-L3 Freight Transport Ops (International) V1.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
Pre independence Education in Inndia.pdf
Complications of Minimal Access Surgery at WLH
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
O7-L3 Supply Chain Operations - ICLT Program
VCE English Exam - Section C Student Revision Booklet

Python Introduction

  • 1. PYTHON GETTING STARTED WITH PYTHON CLASS: XI COMPUTER SCIENCE(083)
  • 2. What is Python? Python is an object-oriented programming language developed by Guido Van Rossum in 1991.Python is a general purpose, dynamic, high-level language. It supports Object Oriented programming approach to develop applications. It is simple and easy to learn. Its an open source language. Python programming is widely used in Artificial Intelligence, Natural Language Generation and other advanced fields of Computer Science. Python files have extension filename.py So if you want to save the file of python then write: myfile.py
  • 3. What is High-level language? A high-level language is a programming language which is designed to make computer programming easy to understand. All these HLL source code converted into machine understandable code with the help of there compilers that convert it. It is a programming language such as C, FORTRAN, or Pascal that enables a programmer to write programs that are more or less independent of a particular type of computer. Such languages are considered high-level because they are closer to human languages and further from machine languages. Java , C++ , C# , Visual Basic , JavaScript, Python
  • 4. Object Oriented programming OOP stands for Object-Oriented Programming. Object-oriented programming is about creating objects that contain both data and functions. It is based on objects, instead of just functions and procedures. An "object" is a instance of a class. Each object has a structure similar to other objects in the class, but can be assigned individual characteristics. Class Object A class is a template or a blu-print representing a group of objects that share common properties and relationships. An object is a instance of a class. An object is nothing but a self-contained component which consists of methods/behaviors and properties/states.
  • 5. Let us understand Class: A class is a template or a blu-print representing a group of objects that share common properties and relationships. Class is divided into two part: State/Attributes Behaviors The state or attributes are the built in characteristics or properties of an object The behavior or operations of an object are its predefined functions
  • 6. Let us understand with the help of example: Television Class State/Attributes size, colour, model, sound,channels etc. ------------------------ Behaviors PowerOn, PowerOff, Increase(+)/Decrease(-) volume etc. Objects Samsung Sony LG
  • 7. Let us understand with the help of example: Class: DOG State/Attributes Breed, size, colour,age ------------------------ Behaviors Eat,Run,Sleep….. State/Attributes Breed=“Germanshepard” Size= Large Colour= Dark Brown Age= 5 years State/Attributes Breed=“Pug” Size= small Colour= light brown Age= 1 years Object
  • 8. Python is known for its general-purpose nature that makes it applicable in almost every domain of software development. It provides libraries to handle Python Applications Web Applications Desktop GUI Applications Console-based Application Software Development Scientific and Numeric Business Applications Audio or Video-based ApplicationsImage Processing Application
  • 9. Python Features Easy to Learn and Use Expressive Language Interpreted Language Cross-platform Language Python is easy to learn as compared to other programming languages. Python can perform complex tasks using a few lines of code. it means the Python program is executed one line at a time. Python can run equally on different platforms such as Windows, Linux, UNIX, and Macintosh, etc. So, we can say that Python is a portable language.
  • 10. Free and Open Source Object-Oriented Language Large Standard Library GUI Programming Support Embeddable Python is freely available for everyone. Python supports object-oriented language and concepts of classes and objects come into existence. It provides a vast range of libraries for the various fields such as machine learning, web developer, and also for the scripting. The code of the other programming language can use in the Python source code. We can use Python source code in another programming language as well. Graphical User Interface is used for the developing Desktop application. PyQT5, Tkinter, Kivy are the libraries which are used for developing the web application.
  • 11. How to Install Python Visit the link https://www.python.org/downloads/ to download the latest release of Python.
  • 12. Python IDEs IDE stands for Integrated Development Environment is defined as a coding tool that helps to automate the process of editing, compiling, testing, etc. Pyroid3 for Android Mobile.
  • 13. Python Character Set: Character set is an asset of valid characters that a language can recognize. A character can represents any letter, digit, or any other sign. Following are some of the character set. LETTERS A to Z and a to z DIGITS 0 – 9 SPECIAL SYMBOLS + -* [] {} = != < > . ‘ ‘ ; : & # WHITE SPACE Blank space , horizontal tab
  • 14. TOKENS: In a passage of text, individual words and punctuation marks or smallest lexical unit in a program is known as token. keywords Identifier Literals PunctuatorsOperators
  • 15. keywords Keywords are the reserved words in Python. keywords are case sensitive. There are 33 keywords. Each keyword has a special meaning and a specific operation, we cant modify or change the meaning of these keywords. True False None and as asset def class continue break else finally elif del except global for if from import raise try or return pass nonlocal in not is lambda
  • 16. Identifier An identifier is a name given to entities like variables, functions, classes etc. It helps to differentiate one entity from another. Rules for writing identifiers identifiers can be a combination of letters in lowercase (a to z) or uppercase (A to Z) or digits (0 to 9) or an underscore (_) An identifier cannot start with a digit.Example: 1var ab+1 ad 123 ch$ Ab#12 Invalid
  • 17. So if we need to write a valid identifiers are: ABC1 abc12 ad12cd ab_123 _abc Invalid identifiers are: 12abc abc 12 ab@12 ab$$1 Ab*%1 It means if we use any special symbols with letters then its an invalid identifiers or spaces between the characters Ab+1
  • 18. Literals Literals referred as Constants also, python Literals can be defined as data that is given in a variable. These are data items that never change their value during a program run. Kinds of Literals are: Character Literals: String Literals: Integer Literals: Floating Literals: Bool Literals:
  • 19. One character enclosed in single quotes, as ‘A’ or in double quotes “A” Example: ch=‘A’ Or ch=“B” Character Literals:
  • 20. String literals can be formed by enclosing a text in the quotes. We can use both single(‘) as well as double quotes(“) to create a string. Example: name=“Rohan” Or Name=‘Rohan’ String Literals:
  • 21. An integer is a numeric literal(associated with numbers) without any fractional or exponential part. There are three types of integer literals in python programming: decimal (base 10) octal (base 8) hexadecimal (base 16) Example: A=10 B=-23 Number Literals:
  • 22. Floating-point Literals A floating-point literal is a numeric literal that has either a fractional form or an exponent form. For example: Example: A=2.445 B=0.5567 C=-2.345
  • 23. A Boolean literal can have any of the two values: True or False. Example: result=(10==20) The result will store result in the form of True or False Bool Literals:
  • 24. Punctuators These are also known as separators. Brackets: [ ] Parentheses ( ) Braces { } Comma , Semi colon ; colon : and many signs…… Operators Operators are special symbols which represent computation. They are applied on operands which can be values or variable. Example: +, -, / , * ……..
  • 25. How write Comments in python? Comments are very important while writing a program. These are ignored by the python interpreter and have no effect on the actual output code. Comments make the code more readable and understandable for human being. Comment describe what is going on inside a program before looking at the source code. In Python, we use the hash (#) symbol to start writing a comment.
  • 26. #This is a comment Single line Comments : Put the # hash sign and then the statement #This is a comment1 #This is a comment2 #This is a comment3 Multi line Comments : Put the # hash sign and then the statement , then write another statement with # hash sign
  • 27. How to display statements using print() function. So if we want to display any statement in python we have to use print() function Example: if we want to print statement “Hello Python, Welcome to programming” print(“Hello Python, Welcome to programming”)
  • 28. So if we want to display output as shown below: ++++++ ###### ====== print(“++++++”) print(“######”) print(“======”)
  • 29. So if we want to display output as shown below: *********** * * * * *********** Line 1 Line 2 Line 3 Line 4 “***********”print( ) print( )“* *” print( )“* *” print( )“***********” In Line 2 and Line 3 After first * there is a space for that we need to press spacebar
  • 30. Using print display the following outputs: *********** * * ***** * * * * * * * * * * * * * * * * * * * * * print(“***************”) print(“*”) print(“*”) print(“*”) print(“**********”) print(“*”) print(“*”) print(“*”)
  • 31. Using print display the following outputs: A @ @ @ @@@@@ @ @ @ @ print(“ @”) These blank box are spaces press spacebar print(“ @ @”) print(“ @@@@@”) print(“ @ @”) print(“@ @”)
  • 32. Using print display the following outputs: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  • 33. Python Escape Characters To insert characters that are illegal in a string, use an escape character. An escape character is a backslash followed by the character you want to insert. n New Line It move the cursor to next line t Tab It is use for horizontal tab b Backspace it move cursor one step back and overwrite the character with next character over it.
  • 34. We are the so-called "Vikings" from the north. If we want to print the output as shown below: print ("We are the so-called "Vikings" from the north.") If we write the print line as shown below it will display error: To solve this error : Use the escape character " print ("We are the so-called "Vikings" from the north.")
  • 35. If we want to print the output as shown below using single print: We WELCOME You to Python program We WELCOME You to Python program print ("We WELCOMEn Yout ton Pythont program") Next Line use n Next Line use n Use tab t Use tab t
  • 36. If we want to print the output using backslash b : Example: remove double letters from the word given below: WWELCCOMME Output using b : WELCOME print ("WbWELCbCOMbME") If we use b between W and W in an above statement, it will overwrite W with next W, same with C and M
  • 37. More use of print(): Syntax: print(values or statements, sep=‘ ‘, end=‘n’) sep:- string or symbol inserted between values, by default , a space end:- string appended after the last value, default, a new line Example: print(10,20,30) ----Output---- 10 20 30
  • 38. If we want to print the output 10 20 30 with comma(,) sign use sep, it means separator Example: print(10,20,30,sep=“,”) ----Output---- 10,20,30 If we want to print the output 10 20 30 with (* or &) sign use sep, it means seperator Example: print(10,20,30,sep=“*”) ----Output---- 10*20*30 Example: print(10,20,30,sep=“&”) ----Output---- 10&20&30
  • 39. If we want to print the output 10 20 30 with space using t Example: print(10,20,30,sep=“t”) ----Output---- 10 20 30 If we write print(10,20,30) in a separate line using n.How you print. print(10,20,30,sep=“n”) ----Output----10 20 30
  • 40. If we want to print the output like this given below: APPLE,GRAPES,MANGO !!!!!!!! Hint : we have to use sep for comma(,) and (!) inside end print(‘APPLE’,’GRAPES’,’MANGO’, sep=“,”,end=‘!!WOWn’) ----Output---- APPLE,GRAPES,MANGO !!WOW
  • 41. Variable: Variable is a name that is used to refer to memory location. Python variable is also known as an identifier and used to hold value. A Python variable is a reserved memory location to store values. In other words, a variable in a python program gives data to the computer for processing.
  • 42. How to Declare , Initialize and use a Variable Example: If we want to store a value 20 in a variable A. Means we need to declare a variable A and store value 20 as integer / number(0-9) A=20 Example: If we want to store a value ‘A’ character in a variable ch. Means we need to declare a variable ch and store character ‘A’ in it. ch=‘A’ Character , words or paragraph use single quotes (‘) or double quotes(“)
  • 43. How to Declare , Initialize and use a Variable Example: If we want to store a value ‘computer’ word or string in a variable nm. Means we need to declare a variable nm and store word ‘computer’ in it. nm=‘computer’ Character , words or paragraph use single quotes (‘) or double quotes(“) nm=“computer” OR