Author Archives: Efrain Duarte

#QUIZ09 Solutions

I just have two misstake in the problem 2 and 3 problem.

For the first one I had help from my teacher, it just that it print “none”, so I have to call jus the fucntion, without print.

For the second I add a for loop, it was very easy, it just that I didnt read the instruction correctly.

here is my repository wich there are all my solutions: https://github.com/EfrainDuarte95/quiz09

 problem 1:https://github.com/EfrainDuarte95/quiz09/blob/master/q1.py

problem 2:https://github.com/EfrainDuarte95/quiz09/blob/master/q2.py

problem 3:https://github.com/EfrainDuarte95/quiz09/blob/master/q3.py

problem 4:https://github.com/EfrainDuarte95/quiz09/blob/master/q4.py

wsq15 Final dash

well for this wsq I had to make schedule,so far to here I had complete almost all of my masterys, and I had been doing the quizzes and wsq in time, I hope to continue like this.

There are 3 more weeks until we finish our semester and I missing 7 masterys, but I need 8 points, so at least one of my masterys I will make a video explainig all about of the mastery that I choose.For this week I will do 3 of them, and the next week will be done all of them.so my own dead line it will be 26 of may.Of course I have yet to do the quizzes and wsq of the weeks.

 

 

Babilonia

for this wsq i had to made a function that give the squared root of a number without using modules .

so here is my code: https://www.dropbox.com/s/997eudowr9vqews/wsq13.py?dl=0

#wsq14 Estimating e

for this wsq i had to made a function that calculate e and giveme with the decimal points that I wanted.

this is my code: https://www.dropbox.com/s/pwvwguqjr1h3dpt/wsq14.py?dl=0

Is in dropbox, because I had some problems with my repository in github, I will fixed.

wsq12 Greates common divisor

For this wsq I had to make a programm that ask to the user for two numbers, and the programm will return the greatest common divisor of thoose numbers. For made that possible I create a function for thath, and after that a I used statements for the two number when the user didnt insert positive integer numbers. I introduce something extra when the user want to know an other greates common divisor of other numbers.

here is my code: https://github.com/EfrainDuarte95/TC1014/blob/master/wsq12.py

 

Mastery23 Creation and use of lists in Python

In this mastery I will explain how to create and use a list in python.

Well firs a list is use it  to store values that you can use later for other purposes.Now the syntax of this ismthat first you have to put a name to that list, It could be what ever you want,followed od “=” and in brakets  it would be the values of the your list, using different comma-separated.This values can be numbers,strings,etc, it depend of you.Also is other way to made a lists is adding elements one by one, it could be in a loop for example.

when we use a loop to add elements to the list we have to write the right syntax which is this one: Firs the name of the liste,followed of a point, followed to a statement of adding for example appened,inserte, extend, etc. each of one of this has their own propuse, and for finish in parentheses the value of the varibles that you want in the list. Some examples are the following:

primos=[2,3,5,7,11,13]

fechas=[“lunes”,27,”octubre”,1997]

here are  links with more examples and information about lists: http://www.mclibre.org/consultar/python/lecciones/python_listas.html

http://docs.python.org.ar/tutorial/2/datastructures.html

Mastery 22 When to use what type of repetition in a program

I already talk about this in the last mastery, well like I said using recursion it will makw our code more easy to understand and shorter tha other repetition, but sometimes is not the better option.So we have to make the code longer and with more statements.If we want that our code be very effective all the time we have to be very carful about what type of repetition we are going to use, because yes the recursion is easier, but when the time is a priority we must not use the recursion type, because of the time, it takes more time than others.

Mastery 21 Use of recursion for repetitive algorithms

In this mastery I will explain the use of recursion for repetitive algorithms.One example is this one:

well first I can say that this is very helpful when you want that you function be easy to understand.

In this picture we can see that  the recursion is when we use the function inside the function.What I mean? well in this example we use the same function inside the fuction to get to the more simple value of the we want, so it work as a loop that will stop until it get to the last value.

Sometimes the recursion fuction a very helpful, but it depens that what it does the function, because if the function is a little complex the time that the function works its going to be mora than a non-recursion function.

here is a link about more information of what is an recursion fuction in python: http://www.python-course.eu/recursive_functions.php

 

Mastery 20 Use of loops with for

In this mastery I will explain the use of the loop for in python

First we use for when we now how many times the cycles is going to be repeated, so  the syntax is–> “for i in range(X)”

where “i” is just a variable that is changing his value each time that the loop is completed and “x” is the times of the cycle will be repeated.

here is a link that has examples of this: http://www.tutorialspoint.com/python/python_for_loop.htm

Mastery 14 Creating and using a Python module

In this mastery I will introduce you to how to create a module in python and use it. firs lets get clear what is a module.A module is Python files that contain pre-built functions. Now  to creat a module we have to creat a file with the extension “.py”,(that represen tha the file is a file python),and save it on the main folder of python.The direction of this folder can be found on C:Python34.

In this file you can create as many functions as you want after you create your function you save it. So now that your functions are in you module and your mudule is in you main folder of python, you can use it, writing “import” followed the name of the module, but that is not all, with import you open the module but now you have to choose which fuction you are going to use. You have to write the name of the module, point, the name of the function and in parentheses the variable to which we want to apply the function.

here is a video where you can learn very easy how to do it step by step: https://www.youtube.com/watch?v=xRQA1Fy1HFQ