SlideShare a Scribd company logo
1 of 64
PART 1
VARIABLES AND DATA
TYPES IN PYTHON
• PART 0 – Installing python and syllabus
• Playlist link in description
• WANT TO LEARN PYTHON PROGRAMMING? (SUBTITLES)
• SUBSCRIBE
• TELEGRAM – FreeCodeSchool
• Twitter – shivammitra4
• LinkedIn – shivammitra
• Link in description
CONTENT
• What are variables ?
• String data type
• Numerical data type
• Examples
VARIABLES IN MATHS
• A symbol used to represent a numerical value
which can change
• 2x = y + 1 ( Algebra )
• x = 1, y = 1
• x = 2, y = 3
• Ten years from now, Rohit will be three times older
than he is today. What is his current age?
WHAT ARE VARIABLES
• Variables are used to store data
• These data are stored in main memory when you
run the program
• Programming = data + logic
• Different data types in python
• Numbers
• Strings
• Lists
• Tuple
• Dictionary
A SIMPLE EXAMPLE
• What is print() here ?
• What does it do ?
WHAT ARE FUNCTIONS IN MATHS
?
• Takes inputs and gives an output depending on the
input
• f(x) = x^2
• f(1) = 1
• f(2) = 4
• Programming functions also do the same.
• Takes input and returns output ( not always )
• Many built-in functions are present in python
• print() is one example – prints the input on screen
• More about functions in a separate video
WHY SHOULD I USE VARIABLES ?
• Using variables makes programs simpler
• Reduces repeated work
Naming Variables
• Can you give any name to the variables ?
• What are errors ?
WHAT ARE ERRORS IN PYTHON ?
• My name is Shivam vs Is name Shivam my ?
• My nam is Shivam vs My name is Shivam ?
• My name are Shivam vs My name is Shivam ?
• Every language has a syntax or a set of rules to
follow while writing it
• Python also has a syntax
• If you do not follow it, you will get errors.
• More about ”errors in python” in a separate video
RULES FOR NAMING
VARIABLES
RULE 1 - Variable names can contain only letters,
numbers, and underscores. They can start with a
letter or an underscore, but not with a number.
SUPPOSE YOU WANT TO WRITE TWO DIFFERENT MESSAGES ?
RULE 2 - Spaces are not allowed in variable names,
but underscores can be used to separate words in
variable names.
RULE 3 - Avoid using Python keywords and function
names as variable names; that is, do not use words
that Python has reserved for a particular
programmatic purpose, such as the word print.
WHAT ARE KEYWORDS IN PYTHON?
• These are reserved words in python which are used
to define the syntax of python language.
• In English, “is”, “the”, “you” etc. are reserved words
which defines the grammar.
• Keywords have different meaning for Python
language.
• Do not use them in your variables or function
names.
LIST OF KEYWORDS IN PYTHON
BUILT-IN FUNCTIONS IN PYTHON
SOME OTHER IMPORTANT POINTS TO
NOTE
• Variable names should be short but descriptive.
• name is better than writing n
• message is better than writing m or my_name_message
• Be careful when using the lowercase letter l and the
uppercase letter O because they could be confused
with the numbers 1 and 0.
It can take some practice to learn how to create good
variable names, especially as your programs become
more interesting and complicated. As you write more
programs and start to read through other people’s
code, you’ll get better at coming up with meaningful
names.
AVOIDING NAME ERRORS WHEN
USING VARIABLES
FINDING THE DATA TYPE OF A
VARIABLE
• Use type() built-in function
STRINGS DATA TYPE
WHAT ARE STRINGS ?
• A string is a series of characters
• Characters – alphabets, digits, special characters,
white spaces
• Anything inside quotes is considered a string in
Python
• You can use single or double quotes around your
strings
SINGLE QUOTE VS DOUBLE
QUOTE ?
• You can use any of these
• Be consistent
• Exceptions – print these text on screen:
• The language 'Python' is named after Monty Python, not
the snake.
• I told my friend, "Python is my favorite language!"
ASSIGNMENT: Try to find out if it is possible to print first message by using single quotes and second by using double quotes
and how ?
BUILT-IN FUNCTIONS
ASSOCIATED WITH
STRINGS
UPPER/LOWER FUNCTION
• print() vs message.lower()
• These built-in functions are specific to strings.
• print() is specific to multiple data types
• The dot(.) operator acts on the variable and
converts it into upper/lower cases
• The original data doesn’t change
TITLE FUNCTION
• Converts the first character of each word into
upper case
LEN FUNCTION
• Outputs the length of the string
• A single character is of length 1
• Characters can be alphabets or digits or
punctuation or white spaces
STRIP FUNCTIONS – strip(),
lstrip(), rstrip()
• Remove the extra whitespaces from a string
rstrip() – remove whitespace at
right end
lstrip() – remove whitespace from
left end
strip() – remove spaces from both
ends
USING VARIABLES
INSIDE A STRING
COMBINE THESE TWO TO
PRODUCE FULL NAME
Use f-strings
• Feature is available from python 3.6
• Start string with f – f stands for format
• Put braces around variable name
CONCAT MULTIPLE STRINGS
Adding Whitespace to Strings with
Tabs or Newlines
• In programming, whitespace refers to any
nonprinting character, such as spaces, tabs, and
end-of-line symbols.
• You can use whitespace to organize your output so
it’s easier for users to read.
Add a tab to your text
Add newline to your text
NUMBERS DATA TYPE
What are numbers ?
• Integers = 1, 2, 3
• Floats = 1.2, 2.55
• These data are used very frequently in a program.
INTEGERS
• You can add, subtract, multiply and divide python
integers
• Python uses two multiplication symbols to
represent exponents.
MULTIPLE OPERATORS IN ONE
EXPRESSION
• The spacing in these examples has no effect on how
Python evaluates the expressions
• Clarity
• More about precedence of operators in a future
video
FLOATS
• Python calls any number with a decimal point
a float.
• This term is used in most programming languages,
and it refers to the fact that a decimal point can
appear at any position in a number.
• Example: 1.2, 12.35
This happens in all languages and is of little concern. Python tries to find
a way to represent the result as precisely as possible, which is
sometimes difficult given how computers have to represent numbers
internally.
USE ROUND FUNCTION
INTEGERS AND FLOATS
DATA TYPE CONVERSION
MULTIPLE ASSIGNMENTS
• You can assign values to more than one variable
using just a single line.
• This can help shorten your programs and make
them easier to read.
• You’ll use this technique most often when
initializing a set of numbers.
CONSTANTS IN PYTHON
• A constant is like a variable whose value stays the
same throughout the life of a program.
• Python doesn’t have built-in constant types, but
Python programmers use all capital letters to
indicate a variable should be treated as a constant
and never be changed.
LISTS IN PYTHON

More Related Content

What's hot

Phython Programming Language
Phython Programming LanguagePhython Programming Language
Phython Programming LanguageR.h. Himel
 
Python programming
Python  programmingPython  programming
Python programmingAshwinKumarR7
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An IntroductionSwarit Wadhe
 
Interactive Python PPT with animations
Interactive Python PPT with animationsInteractive Python PPT with animations
Interactive Python PPT with animationsShauryaChawla4
 
Unit 2 python
Unit 2 pythonUnit 2 python
Unit 2 pythonpraveena p
 
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Learn Python Programming | Python Programming - Step by Step | Python for Beg...Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Learn Python Programming | Python Programming - Step by Step | Python for Beg...Edureka!
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonAgung Wahyudi
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python ProgrammingKamal Acharya
 
11 Unit1 Chapter 1 Getting Started With Python
11   Unit1 Chapter 1 Getting Started With Python11   Unit1 Chapter 1 Getting Started With Python
11 Unit1 Chapter 1 Getting Started With PythonPraveen M Jigajinni
 
Python Basics | Python Tutorial | Edureka
Python Basics | Python Tutorial | EdurekaPython Basics | Python Tutorial | Edureka
Python Basics | Python Tutorial | EdurekaEdureka!
 
Chapter 8 getting started with python
Chapter 8 getting started with pythonChapter 8 getting started with python
Chapter 8 getting started with pythonPraveen M Jigajinni
 
Introduction to Python IDLE | IDLE Tutorial | Edureka
Introduction to Python IDLE | IDLE Tutorial | EdurekaIntroduction to Python IDLE | IDLE Tutorial | Edureka
Introduction to Python IDLE | IDLE Tutorial | EdurekaEdureka!
 
PART 7 - Python Tutorial | Dictionaries In Python With Examples
PART 7 - Python Tutorial | Dictionaries In Python With ExamplesPART 7 - Python Tutorial | Dictionaries In Python With Examples
PART 7 - Python Tutorial | Dictionaries In Python With ExamplesShivam Mitra
 

What's hot (20)

Python Basics
Python BasicsPython Basics
Python Basics
 
Phython Programming Language
Phython Programming LanguagePhython Programming Language
Phython Programming Language
 
Python ppt
Python pptPython ppt
Python ppt
 
Python programming
Python  programmingPython  programming
Python programming
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An Introduction
 
Interactive Python PPT with animations
Interactive Python PPT with animationsInteractive Python PPT with animations
Interactive Python PPT with animations
 
Unit 2 python
Unit 2 pythonUnit 2 python
Unit 2 python
 
Python by Rj
Python by RjPython by Rj
Python by Rj
 
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Learn Python Programming | Python Programming - Step by Step | Python for Beg...Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
11 Unit1 Chapter 1 Getting Started With Python
11   Unit1 Chapter 1 Getting Started With Python11   Unit1 Chapter 1 Getting Started With Python
11 Unit1 Chapter 1 Getting Started With Python
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
 
Python : Data Types
Python : Data TypesPython : Data Types
Python : Data Types
 
Python Basics | Python Tutorial | Edureka
Python Basics | Python Tutorial | EdurekaPython Basics | Python Tutorial | Edureka
Python Basics | Python Tutorial | Edureka
 
Chapter 8 getting started with python
Chapter 8 getting started with pythonChapter 8 getting started with python
Chapter 8 getting started with python
 
Python
PythonPython
Python
 
Python Basics
Python BasicsPython Basics
Python Basics
 
Introduction to Python IDLE | IDLE Tutorial | Edureka
Introduction to Python IDLE | IDLE Tutorial | EdurekaIntroduction to Python IDLE | IDLE Tutorial | Edureka
Introduction to Python IDLE | IDLE Tutorial | Edureka
 
PART 7 - Python Tutorial | Dictionaries In Python With Examples
PART 7 - Python Tutorial | Dictionaries In Python With ExamplesPART 7 - Python Tutorial | Dictionaries In Python With Examples
PART 7 - Python Tutorial | Dictionaries In Python With Examples
 

Similar to VARIABLES AND DATA TYPES IN PYTHON GUIDE

VARIABLES AND DATA TYPES IN PYTHON NEED TO STUDY
VARIABLES AND DATA TYPES IN PYTHON NEED TO STUDYVARIABLES AND DATA TYPES IN PYTHON NEED TO STUDY
VARIABLES AND DATA TYPES IN PYTHON NEED TO STUDYRushikesh Kolhe
 
Python Programming 1.pptx
Python Programming 1.pptxPython Programming 1.pptx
Python Programming 1.pptxFrancis Densil Raj
 
Class_X_PYTHON_J.pdf
Class_X_PYTHON_J.pdfClass_X_PYTHON_J.pdf
Class_X_PYTHON_J.pdfSanjeedaPraween
 
Programming with Python: Week 1
Programming with Python: Week 1Programming with Python: Week 1
Programming with Python: Week 1Ahmet Bulut
 
Unit-I-PPT-1.ppt
Unit-I-PPT-1.pptUnit-I-PPT-1.ppt
Unit-I-PPT-1.pptChinmaya M. N
 
modul-python-part1.pptx
modul-python-part1.pptxmodul-python-part1.pptx
modul-python-part1.pptxYusuf Ayuba
 
Raspberry using Python Session 1
Raspberry using Python Session 1Raspberry using Python Session 1
Raspberry using Python Session 1Mohamed Abd Ela'al
 
Python Programming.pdf
Python Programming.pdfPython Programming.pdf
Python Programming.pdfssuser9a6ca1
 
intro to python.pptx
intro to python.pptxintro to python.pptx
intro to python.pptxUpasnaSharma37
 
Python Programming for Beginners
Python Programming for BeginnersPython Programming for Beginners
Python Programming for BeginnersDivyanganaBharadwaj
 
Python basics
Python basicsPython basics
Python basicsssuser4e32df
 
Python Demo.pptx
Python Demo.pptxPython Demo.pptx
Python Demo.pptxParveenShaik21
 
Python Demo.pptx
Python Demo.pptxPython Demo.pptx
Python Demo.pptxParveenShaik21
 
Python programming
Python programmingPython programming
Python programmingGanesh Bhosale
 
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdfsamiwaris2
 
Python Programming
Python ProgrammingPython Programming
Python ProgrammingSaravanan T.M
 

Similar to VARIABLES AND DATA TYPES IN PYTHON GUIDE (20)

VARIABLES AND DATA TYPES IN PYTHON NEED TO STUDY
VARIABLES AND DATA TYPES IN PYTHON NEED TO STUDYVARIABLES AND DATA TYPES IN PYTHON NEED TO STUDY
VARIABLES AND DATA TYPES IN PYTHON NEED TO STUDY
 
Python Programming 1.pptx
Python Programming 1.pptxPython Programming 1.pptx
Python Programming 1.pptx
 
Python 01.pptx
Python 01.pptxPython 01.pptx
Python 01.pptx
 
Class_X_PYTHON_J.pdf
Class_X_PYTHON_J.pdfClass_X_PYTHON_J.pdf
Class_X_PYTHON_J.pdf
 
Programming with Python: Week 1
Programming with Python: Week 1Programming with Python: Week 1
Programming with Python: Week 1
 
Unit-I-PPT-1.ppt
Unit-I-PPT-1.pptUnit-I-PPT-1.ppt
Unit-I-PPT-1.ppt
 
modul-python-part1.pptx
modul-python-part1.pptxmodul-python-part1.pptx
modul-python-part1.pptx
 
Python Module-1.1.pdf
Python Module-1.1.pdfPython Module-1.1.pdf
Python Module-1.1.pdf
 
Raspberry using Python Session 1
Raspberry using Python Session 1Raspberry using Python Session 1
Raspberry using Python Session 1
 
Python Programming.pdf
Python Programming.pdfPython Programming.pdf
Python Programming.pdf
 
intro to python.pptx
intro to python.pptxintro to python.pptx
intro to python.pptx
 
Python Programming for Beginners
Python Programming for BeginnersPython Programming for Beginners
Python Programming for Beginners
 
Python basics
Python basicsPython basics
Python basics
 
GE3151_PSPP_UNIT_2_Notes
GE3151_PSPP_UNIT_2_NotesGE3151_PSPP_UNIT_2_Notes
GE3151_PSPP_UNIT_2_Notes
 
Python Demo.pptx
Python Demo.pptxPython Demo.pptx
Python Demo.pptx
 
Python Demo.pptx
Python Demo.pptxPython Demo.pptx
Python Demo.pptx
 
Python programming
Python programmingPython programming
Python programming
 
Python (3).pdf
Python (3).pdfPython (3).pdf
Python (3).pdf
 
Python Programming
Python ProgrammingPython Programming
Python Programming
 
Python1
Python1Python1
Python1
 

More from Shivam Mitra

Preparing for SRE Interviews
Preparing for SRE InterviewsPreparing for SRE Interviews
Preparing for SRE InterviewsShivam Mitra
 
PART 4 - Python Tutorial | If Else In Python With Examples
PART 4 - Python Tutorial | If Else In Python With ExamplesPART 4 - Python Tutorial | If Else In Python With Examples
PART 4 - Python Tutorial | If Else In Python With ExamplesShivam Mitra
 
PART 9 - Python Tutorial | While Loop In Python With Examples
PART 9 - Python Tutorial | While Loop In Python With ExamplesPART 9 - Python Tutorial | While Loop In Python With Examples
PART 9 - Python Tutorial | While Loop In Python With ExamplesShivam Mitra
 
PART 8 - Python Tutorial | User Input In Python With Examples
PART 8 - Python Tutorial | User Input In Python With ExamplesPART 8 - Python Tutorial | User Input In Python With Examples
PART 8 - Python Tutorial | User Input In Python With ExamplesShivam Mitra
 
PART 6 - Python Tutorial | Tuples In Python With Examples
PART 6 - Python Tutorial | Tuples In Python With ExamplesPART 6 - Python Tutorial | Tuples In Python With Examples
PART 6 - Python Tutorial | Tuples In Python With ExamplesShivam Mitra
 
PART 10 - Python Tutorial | Functions In Python With Examples
PART 10 - Python Tutorial | Functions In Python With ExamplesPART 10 - Python Tutorial | Functions In Python With Examples
PART 10 - Python Tutorial | Functions In Python With ExamplesShivam Mitra
 
PART 0 - Python Tutorial | Why should you learn python
PART 0 - Python Tutorial | Why should you learn pythonPART 0 - Python Tutorial | Why should you learn python
PART 0 - Python Tutorial | Why should you learn pythonShivam Mitra
 
Part 2 - Python Tutorial | Introduction to Lists
Part 2 - Python Tutorial | Introduction to ListsPart 2 - Python Tutorial | Introduction to Lists
Part 2 - Python Tutorial | Introduction to ListsShivam Mitra
 
Memory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memoryMemory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memoryShivam Mitra
 
Process Synchronization in operating system | mutex | semaphore | race condition
Process Synchronization in operating system | mutex | semaphore | race conditionProcess Synchronization in operating system | mutex | semaphore | race condition
Process Synchronization in operating system | mutex | semaphore | race conditionShivam Mitra
 
Process Scheduling Algorithms | Interviews | Operating system
Process Scheduling Algorithms | Interviews | Operating systemProcess Scheduling Algorithms | Interviews | Operating system
Process Scheduling Algorithms | Interviews | Operating systemShivam Mitra
 
Threads in Operating System | Multithreading | Interprocess Communication
Threads in Operating System | Multithreading | Interprocess CommunicationThreads in Operating System | Multithreading | Interprocess Communication
Threads in Operating System | Multithreading | Interprocess CommunicationShivam Mitra
 
Process management in operating system | process states | PCB | FORK() | Zomb...
Process management in operating system | process states | PCB | FORK() | Zomb...Process management in operating system | process states | PCB | FORK() | Zomb...
Process management in operating system | process states | PCB | FORK() | Zomb...Shivam Mitra
 
Introduction to operating system, system calls and interrupts
Introduction to operating system, system calls and interruptsIntroduction to operating system, system calls and interrupts
Introduction to operating system, system calls and interruptsShivam Mitra
 
What is Internet and How it Works
What is Internet and How it WorksWhat is Internet and How it Works
What is Internet and How it WorksShivam Mitra
 
OSI Model Layers and Internet Protocol Stack
OSI Model Layers and Internet Protocol StackOSI Model Layers and Internet Protocol Stack
OSI Model Layers and Internet Protocol StackShivam Mitra
 
Basics of Stock Market
Basics of Stock MarketBasics of Stock Market
Basics of Stock MarketShivam Mitra
 
Assets vs liability
Assets vs liabilityAssets vs liability
Assets vs liabilityShivam Mitra
 
Pycricbuzz - a python library to fetch live cricket scores
Pycricbuzz -  a python library to fetch live cricket scoresPycricbuzz -  a python library to fetch live cricket scores
Pycricbuzz - a python library to fetch live cricket scoresShivam Mitra
 

More from Shivam Mitra (19)

Preparing for SRE Interviews
Preparing for SRE InterviewsPreparing for SRE Interviews
Preparing for SRE Interviews
 
PART 4 - Python Tutorial | If Else In Python With Examples
PART 4 - Python Tutorial | If Else In Python With ExamplesPART 4 - Python Tutorial | If Else In Python With Examples
PART 4 - Python Tutorial | If Else In Python With Examples
 
PART 9 - Python Tutorial | While Loop In Python With Examples
PART 9 - Python Tutorial | While Loop In Python With ExamplesPART 9 - Python Tutorial | While Loop In Python With Examples
PART 9 - Python Tutorial | While Loop In Python With Examples
 
PART 8 - Python Tutorial | User Input In Python With Examples
PART 8 - Python Tutorial | User Input In Python With ExamplesPART 8 - Python Tutorial | User Input In Python With Examples
PART 8 - Python Tutorial | User Input In Python With Examples
 
PART 6 - Python Tutorial | Tuples In Python With Examples
PART 6 - Python Tutorial | Tuples In Python With ExamplesPART 6 - Python Tutorial | Tuples In Python With Examples
PART 6 - Python Tutorial | Tuples In Python With Examples
 
PART 10 - Python Tutorial | Functions In Python With Examples
PART 10 - Python Tutorial | Functions In Python With ExamplesPART 10 - Python Tutorial | Functions In Python With Examples
PART 10 - Python Tutorial | Functions In Python With Examples
 
PART 0 - Python Tutorial | Why should you learn python
PART 0 - Python Tutorial | Why should you learn pythonPART 0 - Python Tutorial | Why should you learn python
PART 0 - Python Tutorial | Why should you learn python
 
Part 2 - Python Tutorial | Introduction to Lists
Part 2 - Python Tutorial | Introduction to ListsPart 2 - Python Tutorial | Introduction to Lists
Part 2 - Python Tutorial | Introduction to Lists
 
Memory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memoryMemory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memory
 
Process Synchronization in operating system | mutex | semaphore | race condition
Process Synchronization in operating system | mutex | semaphore | race conditionProcess Synchronization in operating system | mutex | semaphore | race condition
Process Synchronization in operating system | mutex | semaphore | race condition
 
Process Scheduling Algorithms | Interviews | Operating system
Process Scheduling Algorithms | Interviews | Operating systemProcess Scheduling Algorithms | Interviews | Operating system
Process Scheduling Algorithms | Interviews | Operating system
 
Threads in Operating System | Multithreading | Interprocess Communication
Threads in Operating System | Multithreading | Interprocess CommunicationThreads in Operating System | Multithreading | Interprocess Communication
Threads in Operating System | Multithreading | Interprocess Communication
 
Process management in operating system | process states | PCB | FORK() | Zomb...
Process management in operating system | process states | PCB | FORK() | Zomb...Process management in operating system | process states | PCB | FORK() | Zomb...
Process management in operating system | process states | PCB | FORK() | Zomb...
 
Introduction to operating system, system calls and interrupts
Introduction to operating system, system calls and interruptsIntroduction to operating system, system calls and interrupts
Introduction to operating system, system calls and interrupts
 
What is Internet and How it Works
What is Internet and How it WorksWhat is Internet and How it Works
What is Internet and How it Works
 
OSI Model Layers and Internet Protocol Stack
OSI Model Layers and Internet Protocol StackOSI Model Layers and Internet Protocol Stack
OSI Model Layers and Internet Protocol Stack
 
Basics of Stock Market
Basics of Stock MarketBasics of Stock Market
Basics of Stock Market
 
Assets vs liability
Assets vs liabilityAssets vs liability
Assets vs liability
 
Pycricbuzz - a python library to fetch live cricket scores
Pycricbuzz -  a python library to fetch live cricket scoresPycricbuzz -  a python library to fetch live cricket scores
Pycricbuzz - a python library to fetch live cricket scores
 

Recently uploaded

EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)Dr. Mazin Mohamed alkathiri
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 

Recently uploaded (20)

Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 

VARIABLES AND DATA TYPES IN PYTHON GUIDE

  • 1. PART 1 VARIABLES AND DATA TYPES IN PYTHON • PART 0 – Installing python and syllabus • Playlist link in description • WANT TO LEARN PYTHON PROGRAMMING? (SUBTITLES) • SUBSCRIBE • TELEGRAM – FreeCodeSchool • Twitter – shivammitra4 • LinkedIn – shivammitra • Link in description
  • 2. CONTENT • What are variables ? • String data type • Numerical data type • Examples
  • 3. VARIABLES IN MATHS • A symbol used to represent a numerical value which can change • 2x = y + 1 ( Algebra ) • x = 1, y = 1 • x = 2, y = 3 • Ten years from now, Rohit will be three times older than he is today. What is his current age?
  • 4. WHAT ARE VARIABLES • Variables are used to store data • These data are stored in main memory when you run the program • Programming = data + logic • Different data types in python • Numbers • Strings • Lists • Tuple • Dictionary
  • 5. A SIMPLE EXAMPLE • What is print() here ? • What does it do ?
  • 6. WHAT ARE FUNCTIONS IN MATHS ? • Takes inputs and gives an output depending on the input • f(x) = x^2 • f(1) = 1 • f(2) = 4 • Programming functions also do the same. • Takes input and returns output ( not always ) • Many built-in functions are present in python • print() is one example – prints the input on screen • More about functions in a separate video
  • 7. WHY SHOULD I USE VARIABLES ?
  • 8. • Using variables makes programs simpler • Reduces repeated work
  • 9. Naming Variables • Can you give any name to the variables ? • What are errors ?
  • 10. WHAT ARE ERRORS IN PYTHON ? • My name is Shivam vs Is name Shivam my ? • My nam is Shivam vs My name is Shivam ? • My name are Shivam vs My name is Shivam ? • Every language has a syntax or a set of rules to follow while writing it • Python also has a syntax • If you do not follow it, you will get errors. • More about ”errors in python” in a separate video
  • 12. RULE 1 - Variable names can contain only letters, numbers, and underscores. They can start with a letter or an underscore, but not with a number.
  • 13. SUPPOSE YOU WANT TO WRITE TWO DIFFERENT MESSAGES ?
  • 14.
  • 15. RULE 2 - Spaces are not allowed in variable names, but underscores can be used to separate words in variable names.
  • 16. RULE 3 - Avoid using Python keywords and function names as variable names; that is, do not use words that Python has reserved for a particular programmatic purpose, such as the word print.
  • 17. WHAT ARE KEYWORDS IN PYTHON? • These are reserved words in python which are used to define the syntax of python language. • In English, “is”, “the”, “you” etc. are reserved words which defines the grammar. • Keywords have different meaning for Python language. • Do not use them in your variables or function names.
  • 18. LIST OF KEYWORDS IN PYTHON
  • 19.
  • 21. SOME OTHER IMPORTANT POINTS TO NOTE • Variable names should be short but descriptive. • name is better than writing n • message is better than writing m or my_name_message • Be careful when using the lowercase letter l and the uppercase letter O because they could be confused with the numbers 1 and 0.
  • 22. It can take some practice to learn how to create good variable names, especially as your programs become more interesting and complicated. As you write more programs and start to read through other people’s code, you’ll get better at coming up with meaningful names.
  • 23. AVOIDING NAME ERRORS WHEN USING VARIABLES
  • 24. FINDING THE DATA TYPE OF A VARIABLE • Use type() built-in function
  • 26. WHAT ARE STRINGS ? • A string is a series of characters • Characters – alphabets, digits, special characters, white spaces • Anything inside quotes is considered a string in Python • You can use single or double quotes around your strings
  • 27.
  • 28.
  • 29. SINGLE QUOTE VS DOUBLE QUOTE ? • You can use any of these • Be consistent • Exceptions – print these text on screen: • The language 'Python' is named after Monty Python, not the snake. • I told my friend, "Python is my favorite language!"
  • 30. ASSIGNMENT: Try to find out if it is possible to print first message by using single quotes and second by using double quotes and how ?
  • 33. • print() vs message.lower() • These built-in functions are specific to strings. • print() is specific to multiple data types • The dot(.) operator acts on the variable and converts it into upper/lower cases • The original data doesn’t change
  • 34. TITLE FUNCTION • Converts the first character of each word into upper case
  • 35. LEN FUNCTION • Outputs the length of the string • A single character is of length 1 • Characters can be alphabets or digits or punctuation or white spaces
  • 36. STRIP FUNCTIONS – strip(), lstrip(), rstrip() • Remove the extra whitespaces from a string
  • 37. rstrip() – remove whitespace at right end
  • 38. lstrip() – remove whitespace from left end
  • 39. strip() – remove spaces from both ends
  • 41. COMBINE THESE TWO TO PRODUCE FULL NAME
  • 42. Use f-strings • Feature is available from python 3.6 • Start string with f – f stands for format • Put braces around variable name
  • 43.
  • 44.
  • 46. Adding Whitespace to Strings with Tabs or Newlines • In programming, whitespace refers to any nonprinting character, such as spaces, tabs, and end-of-line symbols. • You can use whitespace to organize your output so it’s easier for users to read.
  • 47. Add a tab to your text
  • 48. Add newline to your text
  • 50. What are numbers ? • Integers = 1, 2, 3 • Floats = 1.2, 2.55 • These data are used very frequently in a program.
  • 51. INTEGERS • You can add, subtract, multiply and divide python integers
  • 52.
  • 53. • Python uses two multiplication symbols to represent exponents.
  • 54. MULTIPLE OPERATORS IN ONE EXPRESSION
  • 55. • The spacing in these examples has no effect on how Python evaluates the expressions • Clarity • More about precedence of operators in a future video
  • 56. FLOATS • Python calls any number with a decimal point a float. • This term is used in most programming languages, and it refers to the fact that a decimal point can appear at any position in a number. • Example: 1.2, 12.35
  • 57.
  • 58. This happens in all languages and is of little concern. Python tries to find a way to represent the result as precisely as possible, which is sometimes difficult given how computers have to represent numbers internally.
  • 62. MULTIPLE ASSIGNMENTS • You can assign values to more than one variable using just a single line. • This can help shorten your programs and make them easier to read. • You’ll use this technique most often when initializing a set of numbers.
  • 63. CONSTANTS IN PYTHON • A constant is like a variable whose value stays the same throughout the life of a program. • Python doesn’t have built-in constant types, but Python programmers use all capital letters to indicate a variable should be treated as a constant and never be changed.