The return from the variables

Always in Jr High the most difficult thing for the majority of the people is algebra, find the x. Now in programming languages the variables are back, but we call them in Python basic types.

The amount of basic types differ between authors, in this blog we are going to consider five, why? because Anacleto said so, so don´t complain. The five data types are:

  1. Numbers

    • Integers ‘Int
    • Decimals ‘Float
    • Complex ‘Complexnumbers
  2. String

    A ‘String official definition is: «a contiguous set of characters represented in the quotation marks». Some other information of Strings:

    • 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.
    • The plus (+) sign is the string concatenation operator and the asterisk (*) is the repetition operator.
    • Here is one example:string0_1
    • Here is what is printed:
  3. List

    Python´s Lists are very similar to what C users know as Arrays, the advantage is that in Python the items inside a List, can be from different data types.

    • A list contains items separated by commas and enclosed within square brackets ([])
    • The values stored in a list can be accessed using the slice operator ([ ] and [:]) with indexes starting at 0 in the beginning of the list and working their way to end -1.
    • The plus (+) sign is the list concatenation operator, and the asterisk (*) is the repetition operator.
    • Here I have one example list0_1
    • Here is what shows when you run the program in Cygwin list0_2
  4. Tuple

    Tuples are lists not-editable or updatable, are kind of static lists. The difference is that instead of braces, they use parenthesis ‘()’

    • I have here one examplelist0_1
    • Here is what it prints list0_2
  5. Dictionary

    • A dictionary is similar to an array in Java, but you can personalize many things, for example keys, the keys or the places where you save the information, so you can set 5 o ‘w’ or ‘dove’ as a key
    • The second thing is the levels, they don´t matter you can continue storing and storing information inside.
    • What can I store inside the keys? everything, even objects.
    • Dictionaries are enclosed by curly braces «{ }» and values can be assigned and accessed using square braces «[]».
    • Here is one example I found in the blog of Angel dictionary

 

 

References:

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

Python Basic types

Deja un comentario