Author Archives: Gilberto Rogel García

#QUIZ09 Solutions #TC1014

Codes: here

 

#WSQ11 Yo soy 196

The hardest WSQ so far. I needed lots of help from other school partners.

Code: Click here

Gilberto Rogel García a01630171

#WSQ13 Babylonian Method

Code link here

Picture with examples:

I couldnt understand what the babylonian method was until i looked into Eutimio’s wsq13 which had a video that explained how to do so. I also added two prints (the ones that are as commentary) to help understand what the code does better.

Link to the video:Babylonian method

#WSQ12 Greatest Common Divisor

Code Link

Code running picture:

#WSQ14 Estimating e

I created a function called calculuate_e which receives one parameter called precision that specifies the number of decimal points of accuracy. 

Github link

Picture of the code running:

#mastery23 Creation and use of lists in Python

#mastery22 When to use what type of repetition in a program

In program i think it’s better to make iterative solutions, i’ll show you why:

Recursive solution:

The difference is that when using a recursion it takes alot of time to print as you can see in the picture, iterative solution printed the answer when recursive solution is still calculating the fibonacci of 100.

It is also convenient to use recursion because an infinite loop occurs with iteration if the loop test never becomes false.

The difference is that iteration ends terminates when the loop condition falls whereas recursion terminates when a base case is recognized.

Here are some of the differences of both: http://malhar2010.blogspot.mx/2010/12/difference-between-recursion-and.html

Gilberto Rogel García

#mastery21 Use of recursion for repetitive algorithms

A recursion is when you make a function and call it inside of itself. The recursion has a condition, this condition is that the recursive function has to have an end (to terminate) in order to be in the program.

A common example of this is the fibonacci sequence:

Gilberto Rogel García 

#mastery20 Use of loops with “for”

“i” is the variable that is often used in “for” loops (an iterative loop which means you keep doing something over and over again

For each of the numbers or the things in the range make “i” refer to them and each of those loops is going to refer to each one of those numbers or things

What this program does is that it assigns “i” to every element in that range without including the last number (10)

#mastery19 Use of loops with “while”

The “while” loop is a loop (duh) that allows us to repeat actions as long as the condition is true or until the condition becomes false.

This code shows a little example of a while loop:

x is equal to cero and what the “while” means is that when x is lower than three, it will print x and it will turn x into an accumulator that adds one every time that the “while” makes a loop unti x becomes equal or greater than three.