Tag Archives: #45

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!

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.

#WSQ04

Mi nombre es Jorge Cervantes, y estoy estudiando Ingeniería en Mecatronica en el Tecnológico de Monterrey campus Guadalajara. La cual fue una de las mejores decisiones que e tomado asta el momento ya que mi carrera es algo que me gusta estudiar y en un futuro no muy lejano poder implementar un trabajo basado en ello ya que la programación, la mecánica y electrónica son temas que me fascinan y estoy dispuesto a provechar todo de ello.

Por el momento no practico ningún deporte pero me gusta mucho ir a gym y el americano. Y pasar tiempo con mis amigos. 😛

Bye

Yo y my friends

A little about me #WSQ04

 #TC1014

My name is Ana Karen Zazueta Pimentel, I’m 19 years old and I`m studying animation and digital art. When I was a child I always wanted to be a vet because I love animals the most, but for personal motives I decided not to, and instead turned to my other interests: videogames and animated series.

I’m very awkward and shy with people and I don’t tend to speak a lot, but when I do (usually with my closets friends and family), I can keep going for hours in a very loud voice while doing silly jokes.

I like to play the violin, though I`m just a beginner and it really doesn’t sound pleasant, I know how to make handmade plushies, I love to bake sweets and pastries for my family and friends, also I love to create stories and draw new characters, I would daydream about it all day long if I could!

My hero is, even if it sound silly for others, an anime character named Naruto, who I deeply respect due to him never giving up and always striving to be the best even in the worst situations. My favourite videogames are the pokemon series, and I also enjoy the Zelda and fire emblem series.

One of the things I want to do in the future is to open an animal sanctuary, so they can have another chance in life and meet someone who adopts them and gives them love.

 

Fun with numbers #WSQ03

 #TC1014

Okay, this is my first program in python. The code was easy to come up with, but I actually had more trouble running it in the terminal, and after several tries I finally know how to do it.

Flipped Classroom #WSQ02

 #TC1014

Before watching the video I never heard the term “Flipped Classroom”. Instead of taking the lessons in the class, students take the lessons online in their homes. For this reason there is more time in class to ask questions and finish more activities, therefore it is a more relaxing experience for the students.

The only problem with this way of teaching is that not all students are used to have such a flexible class, and they might not know what to do at first. But I think that eventually anyone can get used to it and start to like it.

http://www.knewton.com/flipped-classroom/