WSQ11 – Go Bananas

--Originally published at Hello World

still need to solve some issues!

http://stackoverflow.com/questions/6797984/how-to-convert-string-to-lowercase-in-python

Here are the instructions:

Write a function called find_bananas which receives a single parameter called filename (a string) and returns a positive integer which is the number of times the word (string) “banana”  (or “BANANA” ) is found in the file. The banana can be any case (‘BaNana’ or ‘BANANA’ or ‘banana’, etc) and they can be “stuck together” like “banAnaBANANA” (that counts as two). Create your own test file (plain text) to check your work.


WSQ13 – Cars

--Originally published at Elu's Blog

For this assignment these were my instructions:

File input/output is our access to permanent stores of data that last beyond the run time of our application.

Write a program that opens and reads the file 93cars.dat.txt and produces the following data:

  • average gas mileage in city (City MPG)
  • average gas mileage on highway (Highway MPG)
  • average midrange price of the vehicles in the set.

You can find the data set at the following link from the Journal of Statistics Education.

This is what I came up with:

Captura de pantalla 2017-04-24 a la(s) 21.08.37.png

Captura de pantalla 2017-04-24 a la(s) 21.08.50.png


WSQ10

--Originally published at Dude, Suckin' at something is the first step to being sorta good at something!

THANKS ELU ONCE AGAIN however this time I didn’t oponed your code this time you spiritually guided me throught the cyclic babylonian method. What I learn was to use the Babylonian method formula to generate a number which after several cicles it compared the last two results who are on a list and if the difference between the last two is less than 0.0001. Then the while will stop and print that answer.

THE CODE

WSQ10 CODE

THE RESULTS

WSQ10 SS


WSQ04 – Sum of Numb3rs

--Originally published at Wonder Universe

Soooo, I have a problem! I need to sum the integer numbers of a very specific range and I need to do it now! What the heck I am going to do?!?!?! It’s not like I’m a program-master-party-dude…or am I?

WSQ04_1

So, I came up with this. Bassically I make a function asking for two numbers, the lower and the higher. I make a range list where I sum every number ’till I get to the higher and then (and only then) I return the sum.

WSQ04_2

See?!? It even works!!!


Estimate e

--Originally published at My programming class blog


Estimate e:

In this assignment you will estimate the mathematical constant e. You should create a function called calculuate_e which receives one parameter called precision that should specify the number of decimal points of accuracy.
You will want to use the infinite series to calculate the value, stopping when the accuracy is reached (previous and current calculation are the same at the specified accuracy).


Here´s my code:
def factorial(x):
    if x==0:
        return 1
    else:
        return x * factorial(x - 1)

def estimate_e(estimation):
    guess= 1
    dif= 10
    e= 2
    x= 2
    while dif > precision:
        e =  e + 1/factorial(x)
        dif= e - guess
        guess= e
        x  =  x + 1
    return e

precision = float(input("Give the precision: "))
print (estimate_e(precision)) 

Fun with numbers

--Originally published at My programming class blog

Fun with numbers

  • The sum of the two numbers.
  • The difference of the two numbers.
  • The product of the two numbers.
  • The integer based division of the two numbers (so no decimal point). First divided by second.
  • The remainder of integer division of the two numbers.
So, to solve this exercise I came up with this:




Here´s the code:
x= input ("Write a number")
x=float (x)
y= input ("Write a number")
y=float (y)
n= (x + y)
n= float (n)
print ("The sum of both numbers is", n)
print("")
print ("")
n2=(x - y)
n2= float (n2)
print ("The difference of both numbers is", n2)
print("")
print("")
n3=(x*y)
n3=float(n3)
print ("The product of both numbers is", n3)
print ("")
print ("")
n4=(x/y)
n4= int (n4)
print ("The division between both numbers is", n4)
print("")
print("")
n5=(x%y)
n5=int(n5)
print ("The modulus operator between both numbers is", n5)
print("")




Quiz 8 (Fibonacci)

--Originally published at My programming class blog

The task:

  • Write a function that calculates returns the “nth” Fibonacci number where we define a function over the Fibonacci numbers mapping the naturals (starting with zero) to the Fibonacci series. So fibonacci(0) returns 0, fibonacci(1) returns 1, fibonacci(2) returns 1 and so on. Note that we are using the modern definition where the sequence starts with zero. You should try to implement this with two solutions: one with a loop and one with recursion. Which do you think is “better”, which looks more “elegant”, which is more “efficient”?
(Here´s a link to know what a fibonacci series looks like: https://en.wikipedia.org/wiki/Fibonacci_number)

So first let's go to the recursion solution, which in my opinion, is the easiest:




Here´s the code: 

def fib(x):
    if x==0:
        return 0
    elif x==1:
        return 1
    else:
        return fib(x-1)+fib(x-2)

x=int(input("Write a number:"))
print ("The fibonacci is:", fib(x))



Now let´s go to the Looping solution:


Here´s the code for the loop method:

def fib(x):
    if x==0:
        return 0
    if x==1:
        return 1
    a=0
    b=1
    for counter in range(x-1):
        c=a+b
        a=b
        b=c
    return c

x=int(input("Write a number:"))
print ("The fibonacci is:", fib(x))

My Virus

--Originally published at Hello World

via OSxdaily

 

My computer is not that young. And one day the worst happened: a virus was here. My teacher helped me a lot in the steps of cleaning up my computer. He told me to back up my computer with time machine. Then, we wipe out all the memory on the mac in order to install Sierra. It was easy and now my computer is like brand new.

If you ever encounter this problem, reading this can be really helpful https://support.apple.com/kb/PH25649?locale=en_US


WSQ 13

--Originally published at Python

What To Do

File input/output is our access to permanent stores of data that last beyond the run time of our application.

Write a program that opens and reads the file 93cars.dat.txt and produces the following data:

  • average gas mileage in city (City MPG)
  • average gas mileage on highway (Highway MPG)
  • average midrange price of the vehicles in the set.

You can find the data set at the following link from the Journal of Statistics Education.

Tengo que agradecer a https://pythoncoursesite.wordpress.com/2017/04/18/cars-%F0%9F%9A%97/ ya que la mayor parte del programa lo obtuve de ahi. Si bien le cambie algunas cosas y le agrege otras, en escencia es lo mismo.

2017-04-20 (1)2017-04-20 (2)

Final

Ganondorf death – The Legend of Zelda Wind Waker