SlideShare a Scribd company logo
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 ?
PART 1 - Python Tutorial | Variables and Data Types in Python
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
PART 1 - Python Tutorial | Variables and Data Types 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
PART 1 - Python Tutorial | Variables and Data Types in Python
PART 1 - Python Tutorial | Variables and Data Types in Python
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
PART 1 - Python Tutorial | Variables and Data Types in Python
PART 1 - Python Tutorial | Variables and Data Types in Python
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
PART 1 - Python Tutorial | Variables and Data Types in Python
• 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
PART 1 - Python Tutorial | Variables and Data Types in Python
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 (20)

Python made easy
Python made easy Python made easy
Python made easy
Abhishek kumar
 
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
Shivam Mitra
 
Introduction To Python | Edureka
Introduction To Python | EdurekaIntroduction To Python | Edureka
Introduction To Python | Edureka
Edureka!
 
PART 3 - Python Tutorial | For Loop In Python With Examples
PART 3 - Python Tutorial | For Loop In Python With ExamplesPART 3 - Python Tutorial | For Loop In Python With Examples
PART 3 - Python Tutorial | For Loop In Python With Examples
Shivam Mitra
 
Beginning Python Programming
Beginning Python ProgrammingBeginning Python Programming
Beginning Python Programming
St. Petersburg College
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
Mohammed Sikander
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
Haitham El-Ghareeb
 
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYAChapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Maulik Borsaniya
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
MaheshPandit16
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Ayshwarya Baburam
 
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Edureka!
 
Pointers in C
Pointers in CPointers in C
Pointers in C
Monishkanungo
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
AkshayAggarwal79
 
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
Shivam Mitra
 
Phython Programming Language
Phython Programming LanguagePhython Programming Language
Phython Programming Language
R.h. Himel
 
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesPython - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Andrew Ferlitsch
 
Python
PythonPython
Python
Sangita Panchal
 
Strings in Python
Strings in PythonStrings in Python
Strings in Python
Amisha Narsingani
 
Looping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonLooping Statements and Control Statements in Python
Looping Statements and Control Statements in Python
PriyankaC44
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An Introduction
Swarit Wadhe
 
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
Shivam Mitra
 
Introduction To Python | Edureka
Introduction To Python | EdurekaIntroduction To Python | Edureka
Introduction To Python | Edureka
Edureka!
 
PART 3 - Python Tutorial | For Loop In Python With Examples
PART 3 - Python Tutorial | For Loop In Python With ExamplesPART 3 - Python Tutorial | For Loop In Python With Examples
PART 3 - Python Tutorial | For Loop In Python With Examples
Shivam Mitra
 
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYAChapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Maulik Borsaniya
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
MaheshPandit16
 
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Edureka!
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
AkshayAggarwal79
 
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
Shivam Mitra
 
Phython Programming Language
Phython Programming LanguagePhython Programming Language
Phython Programming Language
R.h. Himel
 
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesPython - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Andrew Ferlitsch
 
Looping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonLooping Statements and Control Statements in Python
Looping Statements and Control Statements in Python
PriyankaC44
 
Python - An Introduction
Python - An IntroductionPython - An Introduction
Python - An Introduction
Swarit Wadhe
 

Similar to PART 1 - Python Tutorial | Variables and Data Types in Python (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
Rushikesh Kolhe
 
20BCT23 – PYTHON PROGRAMMING.pptx
20BCT23 – PYTHON PROGRAMMING.pptx20BCT23 – PYTHON PROGRAMMING.pptx
20BCT23 – PYTHON PROGRAMMING.pptx
gokilabrindha
 
Python (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizePython (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualize
IruolagbePius
 
Python Data Types
Python Data TypesPython Data Types
Python Data Types
athithanvijay
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
Kamal Acharya
 
Python Programming
Python ProgrammingPython Programming
Python Programming
Saravanan T.M
 
BASICS OF PYTHON usefull for the student who would like to learn on their own
BASICS OF PYTHON usefull for the student who would like to learn on their ownBASICS OF PYTHON usefull for the student who would like to learn on their own
BASICS OF PYTHON usefull for the student who would like to learn on their own
Nandini485510
 
Python_Modullllllle_2-_AFV._Funda-1.pptx
Python_Modullllllle_2-_AFV._Funda-1.pptxPython_Modullllllle_2-_AFV._Funda-1.pptx
Python_Modullllllle_2-_AFV._Funda-1.pptx
tissot723
 
Basics of Python Programming
Basics of Python ProgrammingBasics of Python Programming
Basics of Python Programming
ManishJha237
 
Python Programming 1.pptx
Python Programming 1.pptxPython Programming 1.pptx
Python Programming 1.pptx
Francis Densil Raj
 
Copy_of_Programming_Fundamentals_CSC_104__-_Session_3.pdf
Copy_of_Programming_Fundamentals_CSC_104__-_Session_3.pdfCopy_of_Programming_Fundamentals_CSC_104__-_Session_3.pdf
Copy_of_Programming_Fundamentals_CSC_104__-_Session_3.pdf
faridafatawu07
 
python_class.pptx
python_class.pptxpython_class.pptx
python_class.pptx
chandankumar943868
 
CODING WITH PYTHON PART 1
CODING WITH PYTHON PART 1CODING WITH PYTHON PART 1
CODING WITH PYTHON PART 1
Buxoo Abdullah
 
Python 01.pptx
Python 01.pptxPython 01.pptx
Python 01.pptx
AliMohammadAmiri
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxparts_of_python_programming_language.pptx
parts_of_python_programming_language.pptx
Koteswari Kasireddy
 
Python for beginner, learn python from scratch.pptx
Python for beginner,  learn python from scratch.pptxPython for beginner,  learn python from scratch.pptx
Python for beginner, learn python from scratch.pptx
olieee2023
 
Pythonintro
PythonintroPythonintro
Pythonintro
Hardik Malhotra
 
#Code2Create: Python Basics
#Code2Create: Python Basics#Code2Create: Python Basics
#Code2Create: Python Basics
GDGKuwaitGoogleDevel
 
Python Data Types with realistical approach.pptx
Python Data Types with realistical approach.pptxPython Data Types with realistical approach.pptx
Python Data Types with realistical approach.pptx
MuhammadUmar890FETBS
 
AmI 2015 - Python basics
AmI 2015 - Python basicsAmI 2015 - Python basics
AmI 2015 - Python basics
Luigi De Russis
 
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
Rushikesh Kolhe
 
20BCT23 – PYTHON PROGRAMMING.pptx
20BCT23 – PYTHON PROGRAMMING.pptx20BCT23 – PYTHON PROGRAMMING.pptx
20BCT23 – PYTHON PROGRAMMING.pptx
gokilabrindha
 
Python (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualizePython (Data Analysis) cleaning and visualize
Python (Data Analysis) cleaning and visualize
IruolagbePius
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
Kamal Acharya
 
BASICS OF PYTHON usefull for the student who would like to learn on their own
BASICS OF PYTHON usefull for the student who would like to learn on their ownBASICS OF PYTHON usefull for the student who would like to learn on their own
BASICS OF PYTHON usefull for the student who would like to learn on their own
Nandini485510
 
Python_Modullllllle_2-_AFV._Funda-1.pptx
Python_Modullllllle_2-_AFV._Funda-1.pptxPython_Modullllllle_2-_AFV._Funda-1.pptx
Python_Modullllllle_2-_AFV._Funda-1.pptx
tissot723
 
Basics of Python Programming
Basics of Python ProgrammingBasics of Python Programming
Basics of Python Programming
ManishJha237
 
Copy_of_Programming_Fundamentals_CSC_104__-_Session_3.pdf
Copy_of_Programming_Fundamentals_CSC_104__-_Session_3.pdfCopy_of_Programming_Fundamentals_CSC_104__-_Session_3.pdf
Copy_of_Programming_Fundamentals_CSC_104__-_Session_3.pdf
faridafatawu07
 
CODING WITH PYTHON PART 1
CODING WITH PYTHON PART 1CODING WITH PYTHON PART 1
CODING WITH PYTHON PART 1
Buxoo Abdullah
 
parts_of_python_programming_language.pptx
parts_of_python_programming_language.pptxparts_of_python_programming_language.pptx
parts_of_python_programming_language.pptx
Koteswari Kasireddy
 
Python for beginner, learn python from scratch.pptx
Python for beginner,  learn python from scratch.pptxPython for beginner,  learn python from scratch.pptx
Python for beginner, learn python from scratch.pptx
olieee2023
 
Python Data Types with realistical approach.pptx
Python Data Types with realistical approach.pptxPython Data Types with realistical approach.pptx
Python Data Types with realistical approach.pptx
MuhammadUmar890FETBS
 
AmI 2015 - Python basics
AmI 2015 - Python basicsAmI 2015 - Python basics
AmI 2015 - Python basics
Luigi De Russis
 
Ad

More from Shivam Mitra (18)

Preparing for SRE Interviews
Preparing for SRE InterviewsPreparing for SRE Interviews
Preparing for SRE Interviews
Shivam 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 Examples
Shivam 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 Examples
Shivam 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 Examples
Shivam 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 Examples
Shivam 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 Examples
Shivam 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 python
Shivam 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 memory
Shivam 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 condition
Shivam Mitra
 
Process Scheduling Algorithms | Interviews | Operating system
Process Scheduling Algorithms | Interviews | Operating systemProcess Scheduling Algorithms | Interviews | Operating system
Process Scheduling Algorithms | Interviews | Operating system
Shivam 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 Communication
Shivam 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 interrupts
Shivam 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 Works
Shivam 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 Stack
Shivam Mitra
 
Basics of Stock Market
Basics of Stock MarketBasics of Stock Market
Basics of Stock Market
Shivam Mitra
 
Assets vs liability
Assets vs liabilityAssets vs liability
Assets vs liability
Shivam 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 scores
Shivam Mitra
 
Preparing for SRE Interviews
Preparing for SRE InterviewsPreparing for SRE Interviews
Preparing for SRE Interviews
Shivam 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 Examples
Shivam 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 Examples
Shivam 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 Examples
Shivam 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 Examples
Shivam 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 Examples
Shivam 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 python
Shivam 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 memory
Shivam 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 condition
Shivam Mitra
 
Process Scheduling Algorithms | Interviews | Operating system
Process Scheduling Algorithms | Interviews | Operating systemProcess Scheduling Algorithms | Interviews | Operating system
Process Scheduling Algorithms | Interviews | Operating system
Shivam 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 Communication
Shivam 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 interrupts
Shivam 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 Works
Shivam 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 Stack
Shivam Mitra
 
Basics of Stock Market
Basics of Stock MarketBasics of Stock Market
Basics of Stock Market
Shivam Mitra
 
Assets vs liability
Assets vs liabilityAssets vs liability
Assets vs liability
Shivam 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 scores
Shivam Mitra
 
Ad

Recently uploaded (20)

Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptxDiptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Arshad Shaikh
 
LDMMIA Reiki Yoga Next Week Grad Updates
LDMMIA Reiki Yoga Next Week Grad UpdatesLDMMIA Reiki Yoga Next Week Grad Updates
LDMMIA Reiki Yoga Next Week Grad Updates
LDM & Mia eStudios
 
How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18
Celine George
 
Black and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdfBlack and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdf
AnnasofiaUrsini
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 SlidesHow to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...
Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...
Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...
National Information Standards Organization (NISO)
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18
Celine George
 
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptxSEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
PoojaSen20
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
EduSkills OECD
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
Respiratory System , Urinary System
Respiratory  System , Urinary SystemRespiratory  System , Urinary System
Respiratory System , Urinary System
RushiMandali
 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
Strengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptxStrengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptx
SteffMusniQuiballo
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big CycleRay Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptxDiptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Arshad Shaikh
 
LDMMIA Reiki Yoga Next Week Grad Updates
LDMMIA Reiki Yoga Next Week Grad UpdatesLDMMIA Reiki Yoga Next Week Grad Updates
LDMMIA Reiki Yoga Next Week Grad Updates
LDM & Mia eStudios
 
How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18How to Manage Maintenance Request in Odoo 18
How to Manage Maintenance Request in Odoo 18
Celine George
 
Black and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdfBlack and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdf
AnnasofiaUrsini
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 SlidesHow to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18How to Manage Upselling of Subscriptions in Odoo 18
How to Manage Upselling of Subscriptions in Odoo 18
Celine George
 
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptxSEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
SEXUALITY , UNWANTED PREGANCY AND SEXUAL ASSAULT .pptx
PoojaSen20
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
Trends Spotting Strategic foresight for tomorrow’s education systems - Debora...
EduSkills OECD
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
Respiratory System , Urinary System
Respiratory  System , Urinary SystemRespiratory  System , Urinary System
Respiratory System , Urinary System
RushiMandali
 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
 
Final Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptxFinal Sketch Designs for poster production.pptx
Final Sketch Designs for poster production.pptx
bobby205207
 
Strengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptxStrengthened Senior High School - Landas Tool Kit.pptx
Strengthened Senior High School - Landas Tool Kit.pptx
SteffMusniQuiballo
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big CycleRay Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 

PART 1 - Python Tutorial | Variables and Data Types in Python

  • 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 ?
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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.