If you click on this post…

--Originally published at Py(t)hon

This time we are going to see   the conditional if and how does it work. The conditionals statement performed different actions depending on how the boolean was evaluated false or true. The general form of the “if” statement is the follow.

If BOOLEAN :

STATEMENTS

There are some important things to remember about the if statement when use:

  • The colon (:) is required. It separates the header from the body.
  • The line after the colon must be indented. It is standard in Python to use four spaces for indenting.
  • All lines indented the same amount after the colon will be executed whenever the BOOLEAN_EXPRESSION is true.

Here is an example:

if-1

Here is a tutorial if you didn’t get it:

That’s all #Pug#Tec#ISC#If#Python#Basic


Modules and libraries

--Originally published at Py(t)hon

This time we are going to see the Modules or Libraries what are those things, in simple terms they are Python files that contain definitions and statements, this ones can be imported or well created by yourself.

To import one of this modules and use it in your program is very easy, you just type “import” follow by the name of the python file (without the suffix .py). Then when you are going to use it for pi or cos(x) you have to first type the name of the module, then the pi or the cos(x). Here is an example:

modules 1

With the previous function we did with the help of the module math, we are going to use it as a module:

modules2

That’s the basic of modules and libraries, see you next time. Here i leave you a youtube tutorial maybe you understand it better with this video. #Pug#Python#Modules#Libraries#Tc101


Calling & Creating Functions

--Originally published at Py(t)hon

I think is time to start with functions, i’m no experts at this topic so maybe we can learn together, let’s go

First, what is a function? Very simple, is a piece of reusable code that can be call upon whenever you need it. In other words, if you are going to repeat a code several time the best you can do is create a function, so you don’t have to write it all over again and again. Is to make your life easier.

To create a function you have to start with def follow by parenthesis (), inside this parenthesis goes the parameters necessary, if needed of course, after the parenthesis goes a colon (:) and then to close it, use the return function follow by the value statement, if you don’t want it to return anything, just leave a blank space, the system will take it like None.

Here is my example:

def1.png

In this example I can call whenever I want the areacuadro function, that will be all:) #Pug#Tec#TC101#Functions

Here is a webpage where you can find it better explain link

 

 


Input = not so difficult

--Originally published at Py(t)hon

Hi again, today we are going to see how to make an input, it is actually not that hard so i think you won’t have any difficulties.

So this is how it goes:

Something = input ( whatever you want to ask)

Then you can go like:

Print = (“This” + Something + “ is very nice”)

Here is one example:

input1

Inputs are not difficult so don’t waste a lot of time with them, focus on more important things, but if you have difficulties you can always ask Ken.


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…