Python Basic types

--Originally published at angelmendozas

Python has five basic types:

#Numbers

you can put them as:

a = 1 b = 3 or var_1=4 var_2=3 or delete them like (“del var”) or (“del var1[,var2[,var3]]] etc.

Also python supports four numerical types:

int (integers), long (long integers, can also be octal or hexadecimal), float (floating point real values) and complex (complex numbers).Captura de pantalla 2016-08-26 a las 8.07.18 p.m..png

#String

A string’s official definition is: “Strings in Python are identified as a contiguous set of characters represented in the quotation marks. Python allows for either pairs of single or double quotes. Subsets of strings can be taken using the slice operator ([ ] and [:] ) with indexes starting at 0 in the beginning of the string and working their way from -1 at the end.”

I made several strings, sentences to link one to another and printed them to have fun and made up sentences combined with the strings.

Captura de pantalla 2016-08-29 a las 10.29.17 a.m..png

The results were these (Elizabeth is a random name, don’t worry):

Captura de pantalla 2016-08-29 a las 10.29.07 a.m..png

#List

“Lists are the most versatile of Python’s compound data types. A list contains items separated by commas and enclosed within square brackets ([]). To some extent, lists are similar to arrays in C. One difference between them is that all the items belonging to a list can be of different data type.” -tutorialspoint.com

I made a basic list with words

Captura de pantalla 2016-08-29 a las 10.50.21 a.m..png

this is the result, it solved the 17×10^-4 and the other values were just put like they were in the list

Captura de pantalla 2016-08-29 a las 10.50.31 a.m..png

#Tuple

Tuples are the same as a list its just that the variables go inside of () instead of []

Captura de pantalla 2016-08-29 a las 11.15.47 a.m..png

Captura de pantalla 2016-08-29 a las 11.16.02 a.m..png

#Dictionary

According to tutorials point: “Python’s dictionaries are kind of hash table type. They work like associative arrays or hashes found in Perl and consist of key-value pairs. A dictionary key can be almost any Python type,

Captura de pantalla 2016-08-30 a las 10.46.13 a.m..png
Captura de pantalla 2016-08-30 a las 10.45.54 a.m..png
are usually numbers or strings. Values, on the other hand, can be any arbitrary Python object.”

Captura de pantalla 2016-08-30 a las 10.46.13 a.m..png

And the result is this…

Captura de pantalla 2016-08-30 a las 10.45.54 a.m..png

Resources

http://www.tutorialspoint.com/python/python_variable_types.htm