PYTHON
Python Features
• Free and Open Source
• High-level language
• Interpreted
• Object oriented
• Indentation
• portable
• GUI Support
• Dynamically typed
• Rich library
• Extensible &emmbedable
Python Data Types
• Python Data types are the classification or categorization of data items. It
represents the kind of value that tells what operations can be performed on a
particular data.
CLASSIFICATION
• The following are the standard or built-in data types in Python:
• Numeric
• Sequence Type
• Boolean
• Set
• Dictionary
• Binary Types( memoryview , bytearray , bytes )
• To define the values ​
​
of various data types of Python and check their data
types we use the type() function
Numeric Data Types in Python
• The numeric data type in Python represents the data that has a numeric
value. A numeric value can be an integer, a floating number, or even a
complex number.
• These values are defined as
Python int
Python float
Python complex
Integers – This value is represented by int class. It contains positive or negative whole
numbers (without fractions or decimals).
Float – This value is represented by the float class. It is a real number with a floating-
point representation. It is specified by a decimal point.
• Complex Numbers – A complex number is represented by a complex class. It is
specified as (real part) + (imaginary part)j . For example – 2+3j
• a = 5
• print("Type of a ", type(a))
• b = 5.0
• print("nType of b ", type(b))
• c = 2 + 4j
• print("nType of c ", type(c))
Output
Type of a: <class 'int'>
Type of b: <class 'float'>
Type of c: <class
'complex'>
Sequence Data Types in Python
• A sequence is a data type that represents an ordered collection of items.
Sequences are one of the most fundamental types of data structures in
Python, and they can hold a collection of items (elements) in a specific
order:
• Python String
• Python List
• Python Tuple
• Strings in Python can be created using single quotes, double quotes, or even
triple quotes.
• String1 = 'Welcome to the Geeks World'
• print("String with the use of Single Quotes: ")
• print(String1)
• String1 =
• print("nString with the use of Double Quotes: ")
• print(String1)
• List are just like arrays, declared in other languages which is an ordered
collection of data. It is very flexible as the items in a list do not need to be of
the same type
• In Python, list is a collection data type that is ordered, mutable (changeable), and
allows duplicate elements.
• Creating a List in Python
• Lists in Python can be created by just placing the sequence inside the square
brackets[]
• # Creating a list of fruits
• fruits = ["apple", "banana", "cherry", "date"]
• # Accessing elements of the list
• print(fruits[0]) # Output: apple
• print(fruits[2]) # Output: cherry
• # Modifying an element in the list
• fruits[1] = "blueberry"
• print(fruits) # Output: ['apple', 'blueberry', 'cherry', 'date']
• # Adding elements to the list
• fruits.append("elderberry")
• print(fruits) # Output: ['apple', 'blueberry', 'cherry', 'date', 'elderberry']
• # Removing an element from the list
• fruits.remove("date")
• print(fruits) # Output: ['apple', 'blueberry', 'cherry', 'elderberry']
• # Slicing the list (extracting a portion of the list)
• sublist = fruits[1:3]
• print(sublist) # Output: ['blueberry', 'cherry']
Program to print sum of two number

PYTHON DATA TYPE in python using v .pptx

  • 1.
  • 2.
    Python Features • Freeand Open Source • High-level language • Interpreted • Object oriented • Indentation • portable
  • 3.
    • GUI Support •Dynamically typed • Rich library • Extensible &emmbedable
  • 4.
    Python Data Types •Python Data types are the classification or categorization of data items. It represents the kind of value that tells what operations can be performed on a particular data.
  • 5.
    CLASSIFICATION • The followingare the standard or built-in data types in Python: • Numeric • Sequence Type • Boolean • Set • Dictionary • Binary Types( memoryview , bytearray , bytes )
  • 7.
    • To definethe values ​ ​ of various data types of Python and check their data types we use the type() function Numeric Data Types in Python • The numeric data type in Python represents the data that has a numeric value. A numeric value can be an integer, a floating number, or even a complex number.
  • 8.
    • These valuesare defined as Python int Python float Python complex Integers – This value is represented by int class. It contains positive or negative whole numbers (without fractions or decimals). Float – This value is represented by the float class. It is a real number with a floating- point representation. It is specified by a decimal point.
  • 9.
    • Complex Numbers– A complex number is represented by a complex class. It is specified as (real part) + (imaginary part)j . For example – 2+3j • a = 5 • print("Type of a ", type(a)) • b = 5.0 • print("nType of b ", type(b)) • c = 2 + 4j • print("nType of c ", type(c))
  • 10.
    Output Type of a:<class 'int'> Type of b: <class 'float'> Type of c: <class 'complex'>
  • 11.
    Sequence Data Typesin Python • A sequence is a data type that represents an ordered collection of items. Sequences are one of the most fundamental types of data structures in Python, and they can hold a collection of items (elements) in a specific order: • Python String • Python List • Python Tuple
  • 12.
    • Strings inPython can be created using single quotes, double quotes, or even triple quotes. • String1 = 'Welcome to the Geeks World' • print("String with the use of Single Quotes: ") • print(String1) • String1 = • print("nString with the use of Double Quotes: ") • print(String1)
  • 13.
    • List arejust like arrays, declared in other languages which is an ordered collection of data. It is very flexible as the items in a list do not need to be of the same type • In Python, list is a collection data type that is ordered, mutable (changeable), and allows duplicate elements. • Creating a List in Python • Lists in Python can be created by just placing the sequence inside the square brackets[]
  • 14.
    • # Creatinga list of fruits • fruits = ["apple", "banana", "cherry", "date"] • # Accessing elements of the list • print(fruits[0]) # Output: apple • print(fruits[2]) # Output: cherry • # Modifying an element in the list • fruits[1] = "blueberry" • print(fruits) # Output: ['apple', 'blueberry', 'cherry', 'date']
  • 15.
    • # Addingelements to the list • fruits.append("elderberry") • print(fruits) # Output: ['apple', 'blueberry', 'cherry', 'date', 'elderberry'] • # Removing an element from the list • fruits.remove("date") • print(fruits) # Output: ['apple', 'blueberry', 'cherry', 'elderberry'] • # Slicing the list (extracting a portion of the list) • sublist = fruits[1:3] • print(sublist) # Output: ['blueberry', 'cherry']
  • 16.
    Program to printsum of two number