SlideShare a Scribd company logo
1 of 12
20BCT23 – PYTHON PROGRAMMING
Literal Constants and Numbers
• Literal Constants:
– The value of a literal constant can be used directly in programs.
– Eg : 7,3,9,’A’ and “Hello” are literal constants.
– It is a constant because its value cannot be changed.
• Numbers:
– Four types of nunmbers in Python.
– Integers – 5 or other whole numbers.
– Long Integers- 535633629843L or other bigger whole numbers.
– Complex Numbers – Number of the form a+bi
• Issues in floating point numbers:
– The arithmetic overflow problem.
– The arithmetic underflow problem.
– Loss of precision problem.
Format() function
• format (float(16/(float(3))),’.2f’)
– ‘5.33’
• format(float(16/3),’.2f’)
– ‘5.33’
• format(3**50,’.5e’)
– ‘7.17898e+23’
• format(123456, ’ , ’)
– ‘123,456’
Simple operations on Numbers
• 10+7 #17
• 50+40-35 #55
• 12*10 #120
• 96/12 #8.0
• 96//12 #8
• (-30*4)+500 #380
• -15/0 #Zero Division Error
• 5*3.0 #15.0
• 78%5 #3
• 152.78//3.0 #50.0
• 152.78/3.0 #2.780000000000001
• 36**0.5 #6.0
• 78//5 #15
Strings
• String are group of characters
• Strings can e represented
– Using single quotes Eg: ‘Hello’
– Using double quotes Eg: “Hello” same as ‘Hello’
– Using triple quotes – Eg: ‘’’Hello’’’ To specify multi-line.
• print(‘Hello’) #Hello
• print(“Hello”) #Hello
• print(‘ “Hello” ’) #”Hello”
• print(“ ‘Hello’ ”) #’Hello’
• print(‘ ’ ’ “Hello” ‘ ‘ ‘) #”Hello”
• print(‘’’ ‘Hello’ ’’’) #’Hello’
Strings
• String Literal Concatenation:
– print(‘Hello’ ‘ ‘ ‘ World!’) # Hello World!
• Unicode Strings:
– Standard way of writing international text.
– To write text in native language need to enable unicode text editor.
– U” Sample Unicode String” # ‘Sample Unicode String’
• Escape Sequence:
– Some characters like “, cannot be directly included in a string.
– Such characters must be escaped by placing a backslash before them.
– Eg: print(‘What’s your Name’) # Invalid Syntax
print(‘What’s your Name’) # What’s your Name
• Raw String:
– In order to specify a string that should not handle any escape sequences and
to display exactly as specified raw string.
– print(R’What’s Your Name’) # What’s Your Name
Variable and Identifiers
• Variables means its value can vary.
• It is just parts of computer’s memory where information is stored.
• Variables are reserved memory locations that stores values.
• Identifiers are names given to identify something like variables,
function, class, module or other object.
• Basic rules for naming identifiers,
• First character must be an ‘_’ or a letter.
• Rest of the identifier can be ‘_’ or letters or numbers.
• Identifier names are case sensitive.
• Punctuation characters such as @,$ and % are not allowed within
identifiers.
• Valid: sum, _var,num1,r
• Invalid: 1num,my-var,%check
Data Types
• Variable can held values of different types are
called data types.
• Based on the data types of a variable, the
interpreter reserves memory for it and also
determines the type of data that can be stored in
the reserved memory.
– Basic Types: Numbers and Strings
– Own Data Type : Classes
– Standard Data Type: numbers, string, list, tuple and
dictionary.
Assigning Values to the Variables
• Need not explicitly declare variables.
• Declaration is done when the value is assigned.
• Eg : x=‘a’
• In python, varaibles may be reassigned as many times as
possible to change the value stored in them.
Val=“hello”
print(val)
• Multiple Assignment:
– Python allows programmers to assign a single value to more
than on variables simultaneously.
• Eg : sum,a,b,msg=0,3,5,”Result”
– Trying to reference a variable that has not been assigned any
value causes an error.
Data Types
• Boolean:
– Boolean variables have one of the two values. True or False
– Eg : Flag=True 20!=20
• Input Operation:
– The input function takes user’s input as a string.
– Python uses input() functionto take input from user.
– Eg: age=input(“Enter Your Age”)
• Comments:
– Comments are non executable statements in a program.
– Makes the program easily readable and understandable by the
programmer as well as others who are seeing the code.
– # a hash sign represents comment line.
– print(“Hello”) #prints the string Hello
• Reserved Words:
– These words have a pre-defined meaning .
– Cannot be used for naming identifiers.
– Eg : and assert break class exec finally for from not
• Indentation:
– White space at the beginning of the line is called indentation.
– Single tab for each indentation level.
– It is used to associate and group statements.
– The level of indentation groups statements to form a block of
statements.
– The statements in a block should have same indentation level.
– Error is thrown if indentation is not correct.
– Eg : age=21
print(age) # Indentation Error
– All the statement inside the block should be at the same
indentation level.
Operators and Expressions
• Operators are the constructs that are used to manipulate the value of
operands.
• Eg: sum=a+b
• Arithmetic Operator:
• +,-,*,/,//,%,**,|,&
• Comparison Operator:
– These are also called as relational operator.
– Used to compare the values on its either sides and determine the relationship between
them.
– Eg: a==b a!=b a>b
– ==,!=,>,<,>=,<=
• Shortcut operators :
– +=,-=,*=,/=,%=
• Unary operator:
– Acts on single operands.
– When an operand is preceded by a minus sign, the unary operator negates its value.
– Eg : b=-10 a=-b #a=10

More Related Content

Similar to 20BCT23 – PYTHON PROGRAMMING.pptx

Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++K Durga Prasad
 
Programming Basics.pptx
Programming Basics.pptxProgramming Basics.pptx
Programming Basics.pptxmahendranaik18
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming LanguageAhmad Idrees
 
Escape Sequences and Variables
Escape Sequences and VariablesEscape Sequences and Variables
Escape Sequences and Variablesyarkhosh
 
Programming construction tools
Programming construction toolsProgramming construction tools
Programming construction toolssunilchute1
 
Programming in c
Programming in cProgramming in c
Programming in cvineet4523
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introductionnikshaikh786
 
M.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C LanguageM.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C LanguageDr.Florence Dayana
 
C – A Programming Language- I
C – A Programming Language- IC – A Programming Language- I
C – A Programming Language- IGagan Deep
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data typesPratik Devmurari
 
2nd PUC Computer science chapter 5 review of c++
2nd PUC Computer science chapter 5   review of c++2nd PUC Computer science chapter 5   review of c++
2nd PUC Computer science chapter 5 review of c++Aahwini Esware gowda
 
C programming language
C programming languageC programming language
C programming languageAbin Rimal
 
programming week 2.ppt
programming week 2.pptprogramming week 2.ppt
programming week 2.pptFatimaZafar68
 
Programming for Problem Solving Unit 2
Programming for Problem Solving Unit 2Programming for Problem Solving Unit 2
Programming for Problem Solving Unit 2Dhiviya Rose
 
Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variablesTony Apreku
 

Similar to 20BCT23 – PYTHON PROGRAMMING.pptx (20)

Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
Programming Basics.pptx
Programming Basics.pptxProgramming Basics.pptx
Programming Basics.pptx
 
Introduction
IntroductionIntroduction
Introduction
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
Escape Sequences and Variables
Escape Sequences and VariablesEscape Sequences and Variables
Escape Sequences and Variables
 
Java chapter 2
Java chapter 2Java chapter 2
Java chapter 2
 
Programming construction tools
Programming construction toolsProgramming construction tools
Programming construction tools
 
Programming in c
Programming in cProgramming in c
Programming in c
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introduction
 
M.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C LanguageM.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C Language
 
C – A Programming Language- I
C – A Programming Language- IC – A Programming Language- I
C – A Programming Language- I
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
 
lec 2.pptx
lec 2.pptxlec 2.pptx
lec 2.pptx
 
2nd PUC Computer science chapter 5 review of c++
2nd PUC Computer science chapter 5   review of c++2nd PUC Computer science chapter 5   review of c++
2nd PUC Computer science chapter 5 review of c++
 
C programming language
C programming languageC programming language
C programming language
 
programming week 2.ppt
programming week 2.pptprogramming week 2.ppt
programming week 2.ppt
 
Raptor tool
Raptor toolRaptor tool
Raptor tool
 
Programming for Problem Solving Unit 2
Programming for Problem Solving Unit 2Programming for Problem Solving Unit 2
Programming for Problem Solving Unit 2
 
C PROGRAMING.pptx
C PROGRAMING.pptxC PROGRAMING.pptx
C PROGRAMING.pptx
 
Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variables
 

Recently uploaded

How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 

Recently uploaded (20)

Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 

20BCT23 – PYTHON PROGRAMMING.pptx

  • 1. 20BCT23 – PYTHON PROGRAMMING
  • 2. Literal Constants and Numbers • Literal Constants: – The value of a literal constant can be used directly in programs. – Eg : 7,3,9,’A’ and “Hello” are literal constants. – It is a constant because its value cannot be changed. • Numbers: – Four types of nunmbers in Python. – Integers – 5 or other whole numbers. – Long Integers- 535633629843L or other bigger whole numbers. – Complex Numbers – Number of the form a+bi • Issues in floating point numbers: – The arithmetic overflow problem. – The arithmetic underflow problem. – Loss of precision problem.
  • 3. Format() function • format (float(16/(float(3))),’.2f’) – ‘5.33’ • format(float(16/3),’.2f’) – ‘5.33’ • format(3**50,’.5e’) – ‘7.17898e+23’ • format(123456, ’ , ’) – ‘123,456’
  • 4. Simple operations on Numbers • 10+7 #17 • 50+40-35 #55 • 12*10 #120 • 96/12 #8.0 • 96//12 #8 • (-30*4)+500 #380 • -15/0 #Zero Division Error • 5*3.0 #15.0 • 78%5 #3 • 152.78//3.0 #50.0 • 152.78/3.0 #2.780000000000001 • 36**0.5 #6.0 • 78//5 #15
  • 5. Strings • String are group of characters • Strings can e represented – Using single quotes Eg: ‘Hello’ – Using double quotes Eg: “Hello” same as ‘Hello’ – Using triple quotes – Eg: ‘’’Hello’’’ To specify multi-line. • print(‘Hello’) #Hello • print(“Hello”) #Hello • print(‘ “Hello” ’) #”Hello” • print(“ ‘Hello’ ”) #’Hello’ • print(‘ ’ ’ “Hello” ‘ ‘ ‘) #”Hello” • print(‘’’ ‘Hello’ ’’’) #’Hello’
  • 6. Strings • String Literal Concatenation: – print(‘Hello’ ‘ ‘ ‘ World!’) # Hello World! • Unicode Strings: – Standard way of writing international text. – To write text in native language need to enable unicode text editor. – U” Sample Unicode String” # ‘Sample Unicode String’ • Escape Sequence: – Some characters like “, cannot be directly included in a string. – Such characters must be escaped by placing a backslash before them. – Eg: print(‘What’s your Name’) # Invalid Syntax print(‘What’s your Name’) # What’s your Name • Raw String: – In order to specify a string that should not handle any escape sequences and to display exactly as specified raw string. – print(R’What’s Your Name’) # What’s Your Name
  • 7. Variable and Identifiers • Variables means its value can vary. • It is just parts of computer’s memory where information is stored. • Variables are reserved memory locations that stores values. • Identifiers are names given to identify something like variables, function, class, module or other object. • Basic rules for naming identifiers, • First character must be an ‘_’ or a letter. • Rest of the identifier can be ‘_’ or letters or numbers. • Identifier names are case sensitive. • Punctuation characters such as @,$ and % are not allowed within identifiers. • Valid: sum, _var,num1,r • Invalid: 1num,my-var,%check
  • 8. Data Types • Variable can held values of different types are called data types. • Based on the data types of a variable, the interpreter reserves memory for it and also determines the type of data that can be stored in the reserved memory. – Basic Types: Numbers and Strings – Own Data Type : Classes – Standard Data Type: numbers, string, list, tuple and dictionary.
  • 9. Assigning Values to the Variables • Need not explicitly declare variables. • Declaration is done when the value is assigned. • Eg : x=‘a’ • In python, varaibles may be reassigned as many times as possible to change the value stored in them. Val=“hello” print(val) • Multiple Assignment: – Python allows programmers to assign a single value to more than on variables simultaneously. • Eg : sum,a,b,msg=0,3,5,”Result” – Trying to reference a variable that has not been assigned any value causes an error.
  • 10. Data Types • Boolean: – Boolean variables have one of the two values. True or False – Eg : Flag=True 20!=20 • Input Operation: – The input function takes user’s input as a string. – Python uses input() functionto take input from user. – Eg: age=input(“Enter Your Age”) • Comments: – Comments are non executable statements in a program. – Makes the program easily readable and understandable by the programmer as well as others who are seeing the code. – # a hash sign represents comment line. – print(“Hello”) #prints the string Hello
  • 11. • Reserved Words: – These words have a pre-defined meaning . – Cannot be used for naming identifiers. – Eg : and assert break class exec finally for from not • Indentation: – White space at the beginning of the line is called indentation. – Single tab for each indentation level. – It is used to associate and group statements. – The level of indentation groups statements to form a block of statements. – The statements in a block should have same indentation level. – Error is thrown if indentation is not correct. – Eg : age=21 print(age) # Indentation Error – All the statement inside the block should be at the same indentation level.
  • 12. Operators and Expressions • Operators are the constructs that are used to manipulate the value of operands. • Eg: sum=a+b • Arithmetic Operator: • +,-,*,/,//,%,**,|,& • Comparison Operator: – These are also called as relational operator. – Used to compare the values on its either sides and determine the relationship between them. – Eg: a==b a!=b a>b – ==,!=,>,<,>=,<= • Shortcut operators : – +=,-=,*=,/=,%= • Unary operator: – Acts on single operands. – When an operand is preceded by a minus sign, the unary operator negates its value. – Eg : b=-10 a=-b #a=10