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

PPTX
Introduction to python for Beginners
PDF
Python Basics
PDF
Begin with Python
PPTX
Python
PPTX
Group By, Having Clause and Order By clause
PDF
Operators in python
PPTX
Introduction to pandas
PPTX
Data and information
Introduction to python for Beginners
Python Basics
Begin with Python
Python
Group By, Having Clause and Order By clause
Operators in python
Introduction to pandas
Data and information

What's hot (20)

PPTX
Python variables and data types.pptx
PPTX
PART 3 - Python Tutorial | For Loop In Python With Examples
PPTX
Intro to Python Programming Language
PPTX
PART 7 - Python Tutorial | Dictionaries In Python With Examples
PPTX
Part 2 - Python Tutorial | Introduction to Lists
PPTX
Functions in python
PPTX
Lecture Introduction to Python 2024.pptx
PDF
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
PDF
Introduction to python
PPTX
USE OF PRINT IN PYTHON PART 2
PDF
Introduction to python
PPTX
Python-00 | Introduction and installing
PDF
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
PDF
Python If Else | If Else Statement In Python | Edureka
ODP
Python Presentation
PPTX
Python 101: Python for Absolute Beginners (PyTexas 2014)
PPTX
Pseudocode
PPT
Python ppt
PDF
Function arguments In Python
Python variables and data types.pptx
PART 3 - Python Tutorial | For Loop In Python With Examples
Intro to Python Programming Language
PART 7 - Python Tutorial | Dictionaries In Python With Examples
Part 2 - Python Tutorial | Introduction to Lists
Functions in python
Lecture Introduction to Python 2024.pptx
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Introduction to python
USE OF PRINT IN PYTHON PART 2
Introduction to python
Python-00 | Introduction and installing
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Python If Else | If Else Statement In Python | Edureka
Python Presentation
Python 101: Python for Absolute Beginners (PyTexas 2014)
Pseudocode
Python ppt
Function arguments In Python
Ad

Similar to PART 1 - Python Tutorial | Variables and Data Types in Python (20)

PPTX
VARIABLES AND DATA TYPES IN PYTHON NEED TO STUDY
PPTX
2. Getting Started with Python second lesson .pptx
PPTX
Python Programming 1.pptx
PDF
Computer Related material named Phython ok
PDF
Python Basics Understanding Variables.pdf
PDF
Python Basics Understanding Variables.pdf
PPTX
Python 01.pptx
PDF
Python_Programming_PPT Basics of python programming language
PDF
Class_X_PYTHON_J.pdf
PPTX
Introduction to python
PPTX
Exploring Data Science Using Python Tools
KEY
Programming with Python: Week 1
PPT
Unit-I-PPT-1.ppt
PPTX
modul-python-part1.pptx
PPTX
Pyhton problem solving introduction and examples
PPTX
Introduction to Python Basics for PSSE Integration
PPTX
Python unit 2 is added. Has python related programming content
PPTX
Python Data types like mutable and immutable
PPTX
Topic 2 - Python, Syntax, Variables.pptx
PDF
Python Module-1.1.pdf
VARIABLES AND DATA TYPES IN PYTHON NEED TO STUDY
2. Getting Started with Python second lesson .pptx
Python Programming 1.pptx
Computer Related material named Phython ok
Python Basics Understanding Variables.pdf
Python Basics Understanding Variables.pdf
Python 01.pptx
Python_Programming_PPT Basics of python programming language
Class_X_PYTHON_J.pdf
Introduction to python
Exploring Data Science Using Python Tools
Programming with Python: Week 1
Unit-I-PPT-1.ppt
modul-python-part1.pptx
Pyhton problem solving introduction and examples
Introduction to Python Basics for PSSE Integration
Python unit 2 is added. Has python related programming content
Python Data types like mutable and immutable
Topic 2 - Python, Syntax, Variables.pptx
Python Module-1.1.pdf
Ad

More from Shivam Mitra (18)

PPTX
Preparing for SRE Interviews
PPTX
PART 4 - Python Tutorial | If Else In Python With Examples
PPTX
PART 9 - Python Tutorial | While Loop In Python With Examples
PPTX
PART 8 - Python Tutorial | User Input In Python With Examples
PPTX
PART 6 - Python Tutorial | Tuples In Python With Examples
PPTX
PART 10 - Python Tutorial | Functions In Python With Examples
PPTX
PART 0 - Python Tutorial | Why should you learn python
PPTX
Memory management in operating system | Paging | Virtual memory
PPTX
Process Synchronization in operating system | mutex | semaphore | race condition
PPTX
Process Scheduling Algorithms | Interviews | Operating system
PPTX
Threads in Operating System | Multithreading | Interprocess Communication
PPTX
Process management in operating system | process states | PCB | FORK() | Zomb...
PPTX
Introduction to operating system, system calls and interrupts
PPTX
What is Internet and How it Works
PPTX
OSI Model Layers and Internet Protocol Stack
PPTX
Basics of Stock Market
PPTX
Assets vs liability
PPTX
Pycricbuzz - a python library to fetch live cricket scores
Preparing for SRE Interviews
PART 4 - Python Tutorial | If Else 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 6 - Python Tutorial | Tuples In Python With Examples
PART 10 - Python Tutorial | Functions In Python With Examples
PART 0 - Python Tutorial | Why should you learn python
Memory management in operating system | Paging | Virtual memory
Process Synchronization in operating system | mutex | semaphore | race condition
Process Scheduling Algorithms | Interviews | Operating system
Threads in Operating System | Multithreading | Interprocess Communication
Process management in operating system | process states | PCB | FORK() | Zomb...
Introduction to operating system, system calls and interrupts
What is Internet and How it Works
OSI Model Layers and Internet Protocol Stack
Basics of Stock Market
Assets vs liability
Pycricbuzz - a python library to fetch live cricket scores

Recently uploaded (20)

PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Classroom Observation Tools for Teachers
PPTX
master seminar digital applications in india
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Computing-Curriculum for Schools in Ghana
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Cell Types and Its function , kingdom of life
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Basic Mud Logging Guide for educational purpose
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Classroom Observation Tools for Teachers
master seminar digital applications in india
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Computing-Curriculum for Schools in Ghana
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
102 student loan defaulters named and shamed – Is someone you know on the list?
O7-L3 Supply Chain Operations - ICLT Program
Cell Types and Its function , kingdom of life
STATICS OF THE RIGID BODIES Hibbelers.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Basic Mud Logging Guide for educational purpose
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Sports Quiz easy sports quiz sports quiz
human mycosis Human fungal infections are called human mycosis..pptx
FourierSeries-QuestionsWithAnswers(Part-A).pdf
TR - Agricultural Crops Production NC III.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx

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.