Author Archives: Ismael Lizárraga

Creation and use of Ranges. Mastery 25.

The range function of Python allow us to create that, ranges. A sequence of numbers. It can be used with one, two or three parameters. Examples to be explained.

One parameter:

A one parameter range, is written by putting the word range followed by a parenthesis with a number. Example:

But, what numbers does this range contain inside of it? Let’s use the list function to find out…

We can see that range(8) contains numbers from 0 to 8. Therefore, range(n) contains numbers from 0 to n-1.

Two Parameter:

A range with two parameter is written with 2 numbers separated by a coma inside the parenthesis. Example:

What numbers does this range contains inside of it? Let’s find out…

This range contains numbers from two to six. Therefore, range(a,b) contains numbers from a to b-1.

Three paratemers:

If we use three parameters, the third one represents the increment between each value of the sucesion. The first one is the initial parameter, the second one the upper value not included. Example:

This range contains number starting from 2, increasing by 3 until 24.

Ranges also work with negative numbers. The range function is used commonly alongside for loops.

Creating Python functions. Mastery 12.

To create a Python function you need to write the word def followed by an space and the name of your function with a parenthesis, in the parenthesis you should write a letter for as many arguments you want the function to have, after the right parenthesis you put ‘:’. See examples following.

 

To define a function without argument you write:

def mensaje():

                print (“Este es el mensaje contenido por la función”)

To define a function with one arguments, you write:

def mostrar(a):

                print(a)

To define a function with two arguments, you write:

def sum(a,b)

                print (a+b)

 

and so on!

Calling Python Functions. Mastery 11.

Mastery 11. Calling Python Functions
To call a Python function you need to write the name of the given function and the argument(s) you want to use for that function.
Per example, if I have a function that sum its two arguments, I call it by writing its name followed by a parenthesis with the arguments I want to use for the function.
If the name of my function is sum and it needs to arguments. I write:
Sum (3,4)
Here’s a screenshot of how a function that sum its two arguments would work.

And it will print the following results:
7
9
88
Which corresponds to the sum of both arguments of the function.

On to numbers. WSQ08.

What I did in this WSQ, was a program which perform basic calculations between two numbers, as I did in WSQ03. The difference here, is that this time I’m using functions to perform the calculations. Every calculation has its own function and everyone define two parameters. The program ask the user for the inputs and then, it calls each function to perform the calculations and print its results.

Take a look at my code: https://www.dropbox.com/s/l0sxka8vole3e4m/wsq08.py?dl=0

 

Basic Types and How to Use it in Python. Mastery 09.

A type in Python is a category of data which have the same characteristics that distinguishes them as a class or group.

The basic types in Python are integers, float and strings.

Integers are whole numbers from negative to infinitive. An integer could be -100, 32, 34, 1234, etc.

Float numbers are numbers with decimal point, such as 3.1416, -2.39, 3.2, etc. 

String data contains a string of letters enclosed between quotation marks. If numbers are between quotation marks (like ‘17’ or ‘3.4’ ) their type is string.

 

Assigning a type to a variable

To assign the string type to a variable, you need to write something like this I your code:

M = ‘This is the string of letters I want to assign to the M variable’

Being This is the string of letters I want to assign to the M variable the string set of characters you want to assign to the variable.

To assign the integer type to a variable, you need to write the name of your variable, followed by an equal sign and the number after it. Like in here:

                B = 2

To assign the float type to a variable, you need to write the name of your variable, followed by an equal sign and the number with decimal point after it. Like in here:

                C = 3.1416

 

Assigning a type to a variable through an input.

To assign the integer type to a variable in Python through an input, you need to write the following line of code:

A = int(input(“Write the number you want to assign the integer type”))

Being write the number you want to assign the integer type an example of message to print in the shell.

To assign the float type to a variable in Python through an input, you need to write pretty much the same, but using float instead of int.

B = float(input(“Write the number you want to assign the float type”))

Being write the number you want to assign the float type an example of message to print in the shell.

To assign the string type to a variable in Python through an input, you need to write a similar line of code like in the previous examples.

                C= str(input(“Write the string of data you want to assign to this variable”))

This is pretty much how a type works in Python.

Sum of Numbers, WSQ07

Another program is here!

 

What this program does is sum all the numbers between the range of two given numbers,

 

take a look: https://www.dropbox.com/s/sa23z2x0kr7m0k6/wsq07.py?dl=0

Picking a Number, WSQ06

I’ve written a new program to share with you.

 

It’s kind of a game… It chooses automatically a number between 1 and 100, and it challenges you to guess what numbers has been picked.

 

Give it a look! https://www.dropbox.com/s/i04qtp4cwqg9y7k/wsq06.py?dl=0

 

Temperature, WSQ05.

For this WSQ I made a program which is able to convert a given temperature in farenheit to celsius and it also tells you if water is able to boil at that given temperature.

I receive a friend’s help on how to use the use if conditional on python.

 

If you want to take a look about how it works, there’s my code for you to look!

https://www.dropbox.com/s/rzha1mywvq94s4k/wsq05.py?dl=0

 

About Me.

I’ve been writing on this blog for a while now but I never got the chance to take a brief time to share a little with you all, and is something I want to now, I’m not the best person when it comes to talking about me but I’ll write a list with random toughts as they come to my mind.

 

  1. My complete name is Ismael Lizárraga González.
  2. I’m 18 and I was born in Tepic, Nayarit, México.
  3. When a child I lived in Mazatlan and Los Cabos.
  4. I’m majoring on Electronic And Computer Engineering at Tec de Monterrey, Campus Guadalajara.
  5. Even tough I’m studying and engineering career, I will always have the doubt of what could have been of me I if decided to study something on Finance and Economics.
  6. I really, really love my university but I will always want to know how it is and how it feels to study at ITAM (Instituto Tecnológico de México).
  7. My favorite colors are blue and gray 🙂
  8. If you look at the sky you always see variations of those two…
  9. My favorite band could be U2 or Avenged Sevenfold.
  10. My favorite solo artist is Madonna.
  11. I’m very inspired by Steve Jobs.
  12. When I think of Steve Jobs or Madona, I always think about how is that they are able to stay relevant and going big all over again, even tought the pass of years and decades.
  13. Right now I’m watching the TV series, Gotham.
  14. I really enjoyed How I Met Your Mother.
  15. I’m both, an iOS and Android user. Yes, I have the best of both worlds.
  16. I have two diplomas signed by a Secretary of Public Education.
  17. And also, I have one signed by the US ambassador to Mexico, Anthony Wayne.
  18. At 12 I met Mexico´s ex-president, Felipe Calderón.
  19. My friends and family are the most important thing to me in this world.
  20. I got one less problem without you. (Yes, I’m listening that song.)
  21. If I were able to have the opportunity of being a succesful actor on broadway, I would take it in less than a heartbeat.
  22. I made a promise to myself to travel to New York as soon as I can.
  23. Also, I made a promise to myself of going back to Washington, DC.
  24. I would love to go to Spain.
  25. Right now, I feel like I’m in one of those trancissions moments in my life, over the last two months I’ve been thinking a lot about all the things I have in my life, everything I lived and trying to accept a lot of things as they are, it seems like I would not be over thinking about it anytime soon.
  26. Writing random thoughts on me is a funny thing to do.
  27. The only thing I don’t like about Guadalajara is the traffic.
  28. I fantasize a lot about my perfect life, I’m on my way to it!
  29. This semester I’m taking 4 out of 7 courses in english.
  30. Yeah, you know I’m all about that bass. (Yes, now listening that song!)
  31. I procrastinate A LOT, I’m trying to do it every time less but damn, it’s so hard!
  32. Even tough my home town is a small city, I really love living there, everything is just a few minutes away.
  33. When I travel, I always go deep on thinking about life.
  34. I have a crush on Lea Michele and Cobie Smulders.
  35. I always say a lot that they are my favorite women.
  36. Nothing is better than a friend, a good walk and a really good talk.
  37. My three best male friends name’s are Ulises, Oscar and Jorge.
  38. I really want to go to an U2 concert before they retire, also to a Madonna’s one.
  39. I’m really looking forward to the rest of my university years, they seem kind of exciting to me.
  40. I’m badly in love with Tacos, who isn’t?
  41. I think this is it.

There they are! A funny thing to do, I should do this more often. Have any questions? write to me on twitter! @IsmaLga

Fun With Numbers WSQ03.

Hello there, it’s bee a while since the last time I took some of my time to put something in here.

 

I’ve realized the WSQ03, called fun with numbers, I made a python program able to calculate and show the results of the sum, difference, division and multiplication of two given numbers.

I found the resources to made this, trough some search on the internet about the use of basic operators in Python.

 

 

Here’s my .py file so you all can take a look 🙂

 

https://www.dropbox.com/s/nig5hr7mo3tnu29/wsq03.py?dl=0