PYTHON DATA TYPE in python using v .pptx

urvashipundir04 47 views 16 slides Oct 14, 2024
Slide 1
Slide 1 of 16
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16

About This Presentation

PYTHON DATA TYPE in python using v .pptx


Slide Content

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 i s 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
Tags