What is meant by data types?
In computer language, a data type is a classification of data that determines the operations that can be performed on it and the way it is stored in memory. Data types specify the type of data that a variable can hold, and each programming language has its own set of data types.
Data types in Python
Numeric data types:
int (integer) - whole numbers
float - numbers with decimal points
complex - numbers with a real and imaginary part
Sequence data types:
list - ordered, mutable sequence of elements
tuple - ordered, immutable sequence of elements
range - sequence of numbers
Text data type:
- str (string) - a sequence of characters
Mapping data type:
- dict (dictionary) - collection of key-value pairs
Set data type:
- set - collection of unique elements
Boolean data type:
- bool - True or False
What is meant by data structure?
Organizing and storing data in a computer program so that it can be accessed and used efficiently. Basically data structure are designed to efficiently store, retrieve and manipulate data in a way that is optimized for specific types of operations, such as searching, sorting, inserting, or deleting data.
Data structures in Python
Lists: A list is an ordered, mutable collection of elements. Lists are denoted by square brackets [ ] and each element is separated by a comma.
Tuples: A tuple is an ordered, immutable collection of elements. Tuples are denoted by parentheses ( ) and each element is separated by a comma.
Sets: A set is an unordered, mutable collection of unique elements. Sets are denoted by curly braces { } or the set() constructor.
Dictionaries: A dictionary is an unordered, mutable collection of key-value pairs. Dictionaries are denoted by curly braces { } and each key-value pair is separated by a colon.
Arrays: An array is a collection of elements of the same data type, stored in contiguous memory locations. In Python, arrays can be created using the array module.
Queues: A queue is a collection of elements that follows the First-In-First-Out (FIFO) principle. Python provides a built-in queue module for creating queues.
Stacks: A stack is a collection of elements that follows the Last-In-First-Out (LIFO) principle. Python provides a built-in list data type that can be used as a stack.
Here comes the end to this task.
Reach me on:
Github-> https://github.com/Hrmn97
Twitter -> https://twitter.com/Harman9765
LinkedIn -> https://www.linkedin.com/in/chetan-harman-56310424a
Website -> https://devhrmn.netlify.app/