Skip to content

Beza12/Python-Excercise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Data Types in python

What is data type

A data type is an attribute of a piece of data that tells a device how the end-user might interact with the data. You can also think of them as categorizations that different coding programs might combine in order to execute certain functions.Most programming languages including C++ and Java use the same basic data types.Each programming language uses a different combination of data types.

Data types

Python use standard or built-in data types:

Numeric Data Type

In Python, numeric data type represents the data that has a numeric value. The numeric value can be an integer, a floating number, or even a complex number. These values are defined as int, float, and complex classes in Python.

  • Integers: This data type is represented with the help of int class. It consists of positive or negative whole numbers
  • Float: The float class represents this type. It is a true number with a floating-point representation. It is specified by a decimal point.
  • Complex Numbers: Complex numbers are represented by complex classes. It is specified as (real part) + (imaginary part)j,
String data type

The string is a sequence of Unicode characters. A string may be a collection of 1 or more characters put during a quotation mark, double-quote, or triple-quote.We can perform several operations in strings like Concatenation, Slicing, and Repetition. -Concatenation: It includes the operation of joining two or more strings together. -Slicing: Slicing is a technique for extracting different parts of a string.

  • Repetition: It means repeating a sequence of instructions a certain number of times.
List data type

A list is formed (or created) by placing all the items (elements) inside square brackets [ ], separated by commas.It can have any number of items that may or may not be of different types (integer, float, string, etc.).A list is mutable, which suggests we will modify the list

Tuple data type

A tuple is defined as an ordered collection of Python objects. The only difference between a tuple and a list is that tuples are immutable, i.e., tuples can’t be modified once created. It is represented by a tuple class. We can represent tuples using parentheses ( ).

Set data type

A set is an unordered collection of items. Every set element is exclusive (no duplicates) and must be immutable (cannot be changed).We can represent set using { }

Dictionary data type

In Python, Dictionary is an unordered collection of data values that stores data values like a map. Unlike other Data Types with only a single value as an element, a Dictionary consists of a key-value pair. Key-value is provided within the dictionary to form it more optimized. A colon (:) separates each key-value pair during a Dictionary, in the representation of a dictionary data type. Meanwhile, a comma (,) separates each key.

About

data type

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages