Python’s Types of Data

--Originally published at Py(t)hon

Python has five standard types of data:

  • Numbers
  • Strings
  • Lists
  • Tuples
  • Dictionary

The number type data is used to store numerical values, this are created when you assign a value to the object.

var1 = 5

var2= 15

Pythons support four different numerical types:

  • int ( signed integers )
  • long ( long integers, they can also be represented in octal and hexadecimal)
  • float ( floating point real values)
  • complex (complex numbers)

Some examples, for a clearer view:

int long float complex
10 51924361L 0.0 3.14j
100 -0x19323L 15.20 45.j
-786 0122L -21.9 9.322e-36j
080 0xDEFABCECBDAECBFBAEl 32.3+e18 .876j
-0490 535633629843L -90. -.6545+0J
-0x260 -052318172735L -32.54e100 3e+26J
0x69 -4721885298529L 70.2-E12 4.53e-7j

In the other hand we have the String which are a set of values represented inside a quotation mark.  Python allows either pairs of single or double. Subsets of the string can be made by a slice operator ([] and [:]). Every set starts at 0 to -1. You can include the sing (+) to add something else and the (*) to repeat that string a number of times. Here is an example for a better understanding:

string1

The next type is the list, where you will find items separated by commas and inside brackets, you can access to this list like the string but the difference is that it will appear the complete list of the place you chose, not only a letter or a value; also like the previous you can add something with the (+) and repeat the list with the (*) and example:

list1

The tuples are very similar to the lists, but the main difference is that the tuples are enclosed between parenthesis and not brackets as the list, and another main point is that

tuple 1
dictionarie1
Continue reading "Python’s Types of Data"

Zen of Python

--Originally published at Py(t)hon

The Pythoneer Tim Peters channeled the benevolent dictator of life guiding principles for Python’s design into 20 aphorisms, only 19 of which have been written down.

1- Beautiful is better than ugly.
2- Explicit is better than implicit.
3- Simple is better than complex.
4- Complex is better than complicated.
5- Flat is better than nested.
6- Sparse is better than dense.
7- Readability counts.
8- Special cases aren't special enough to break the rules.
9- Although practicality beats purity.
10- Errors should never pass silently.
11- Unless explicitly silenced.
12- In the face of ambiguity, refuse the temptation to guess.
13- There should be one-- and preferably only one --obvious way to do it.
14- Although that way may not be obvious at first unless you're Dutch.
15- Now is better than never.
16- Although never is often better than *right* now.
17- If the implementation is hard to explain, it's a bad idea.
18- If the implementation is easy to explain, it may be a good idea.
19- Namespaces are one honking great idea -- let's do more of those!

You can find this information in: https://www.python.org/dev/peps/pep-0020/

#Zen#Pug#TC101#Tec#Python


Print (Programing + Math)

--Originally published at Py(t)hon

This time we are going to see how to write and run basic math operations in Python, first we have to know the signs:

“+” is for summing

“-” is for subtracting

“*” is for multiplying

“/” is for dividing

“%” is for the remain of the division

Let’s start, for the past operations it doesn’t matter how many values do you want to sum, subtract, multiply or divide, it could be two to infinity, the important thing here is the sign.

Sum:

math1

Subtraction:

math2

Multiplication:

math3

Division & Remain:

math4

Here is the video that help me learned this stuff?

#Pug#Basic#TC101#Python#ISC It will continue…


#Comments??

--Originally published at Py(t)hon

8ici2juxmrk88
Image via GIPHY

Continuing with Python, it’s time to learn about the comments, which are no more than pieces of codes that are not supposed to be run by the interpreter. This comments help the programmer understand better the code, and also if for any reason you get confuse, you can find your path once again by reading the comments.

For us to start a comment in Python there is only one requirement, to star with a number sing #.comentarios 1

As you can see, the comments where not run, only the function “print”. There is another use for the comments, let say you have a piece of the code that you don’t want the interpreter to run, but also you don’t want to erase it. What to do? The answer is simple, just turn it into a comment.

comentarios 2 comentarios3

For the people that is using eclipse to program, there are certain thing you can do to make your life easier, and your programing, on the top left corner in there is the option “Source” in there you will find two buttons one is Comment and the other one Uncomment, by selecting the piece of code and clicking on of these buttons you will be able to turn that piece of code into a comment or make that comment a piece of code again?.

comentarios4

Here is the video that help me understand comments …

#TC101#Pug#Comments#Nomoreplease#ISC#Tec

 


Learning the basics

--Originally published at Py(t)hon

Continuing with the course, there are certain topic about Python we have to master. Some of them are basics but since most of us are new at this, they suit us well.

We are going to begin with the basic output “print”, which is pretty easy to understand.

First you have to write print, then open a parenthesis and between quotations marks you write a message, the message that you want the user to appear, the message maybe between single or double quotation marks, either way Python will accept it.

print 1

Here is a video explaining it #Pug#Print#Python#ISC#TC101

It will continue…


Week 1

--Originally published at angelmendozas

We learned how to do our first “Hello World”, it was great to learn this kind of stuff that little by little get us closer to bigger things, I’m glad we have such an encouraging teacher like Ken, I already feel the force in me like in a Luke Skywalker level, there’s a bunch more to learn through the next weeks and months but I’m looking forward to doing more cool stuff (like hacking the pentagon or something like that, jk) #LOL