SIZ Education | Data-types in Python | by @faizan2sheikh

in Steem Infinity Zone4 years ago

Hello steemians, I hope you all are having an amazing time learning, in today's post I am going to give you a brief overview of data types or basic data structures that are fundamental in python and are essential to implement different algorithms in python programming language.

Numeric

The numeric type typically represents mathematical values or numbers.
They are subdivided into three types:

  • Integer

This type of numeric value represents values that have no decimal values in them.
They are generally indicated as int in python. For e.g. 0, 1, -34, etc.

  • Float

These types of numeric values represent the values involving floating decimals in them.
They are generally indicated as float in python. For e.g. 0.78, 5.7, -2.4, etc.

  • Complex

Complex numbers represent imaginary values of mathematic, like the root of negative numbers.
They are generally indicated as complex in python. For e.g. 5+3i, 2-2i, etc.

Dictionaries

Dictionaries are very fundamental data structures used in python, they consist of a key having a corresponding value, all keys are unique and map to some value. Dictionaries can contain multiple items enclosed with in curly braces.

dict={'s':101,'r':234}

where 's' and 'r' represent the keys and numbers represent the values. Any value from dictionary can be accessed using the key according to the following syntax.

dict['key']

Booleans

Boolean is a very essential data types and has only two values, it is either true or false, the number 0 represents the 'false' and all other numbers represent 1 or true.

state=true

Booleans are very helpful for making flags in python and used for condition checking in loops generally.

Set

Sets are implemented to store various items in a single variable. Set is one of the 4 built-in data types used to store collections of data in python. Curly braces are required to declare a set.
Sets are unchangeable, heterogeneous, and unordered collections of data having each value unique with no repetitions.

set1={2,54,656,565,3,'faizan'}

Sequence Type

The sequence type typically represents iterable data types.
They are subdivided into three types:

  • Strings

Strings are very fundamental data types used to represent names or any alphanumeric data.

name='faizan2sheikh'

Any character from the string can be accessed using its index.

name[2]   # this would refer to 'i' in name starting indexing from 0
  • List

A list or array is an ordered and mutable data structure used to store a collection of data.

list1=[1,454,3432,'faizan',true]

Square brackets are used to write the syntax of arrays, any value from the array can be accessed using its index.

list1=[1,454,3432,'faizan',true]
# To access 'faizan'
list1[3]
  • Tuple

A tuple is an ordered and immutable data structure used to store a collection of data. Immutable means that it can not be modified after declaration.

tuple1={1,454,3432,'faizan',true}

Curly braces are used to write the syntax of the tuple, any value from the tuple can be accessed using its index.

tuple1={1,454,34,'fan',false}
# To access '34'
tuple1[2]

Conclusion

That's the complete overview of data types used in python, I hope to receive positive reviews from the community. Apart from it, I highly appreciate any correction in the above-shared data. Hope you all enjoyed learning. Thanks for reading my post!

Thanks to:
@cryptokraze
@siz-official
@vvarishayy
@arie.steem
@suboohi

Sort:  
 4 years ago 

THank you Faizan. Indeed you're a quality creator. Thank you for sharing your knowledge with us.

#club5050

Thanks for appreciation, it matters!

 4 years ago 

Good post dear friend keep it up bro and keep learn with our steem fellows and friends my best wishes for you.

Regards, Faran Nabeel

Thanks man

 4 years ago 

Hello @faizan2sheikh, Welcome to our community Steemit-Garden. You can write posts about nature, flowers, gardens, vegetables every day.
Join this community get booming support! Thanks for your joining 😊.

Pink Blooming Bridal Bouquets Sales Presentation (1).gif

#affable #venezuela #club5050

Coin Marketplace

STEEM 0.13
TRX 0.33
JST 0.034
BTC 110258.44
ETH 4278.25
USDT 1.00
SBD 0.83