WSQ12

--Originally published at Site Title

Estimating e

 

What To Do

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).

 

Code/Código:

codepreci

 

Python:

precipy

 

 

Gracias a mi compañero Marco por ayudarme con este problema. Pueden encontar su blog en el siguiente enlace:

https://eosthel.wordpress.com/2017/05/02/python-conventions/

 


WSQ11

--Originally published at Site Title

GO BANANAS!

What To Do

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.

 

Code/Código:

11

Python:

bananapy

 

 


WSQ04

--Originally published at Site Title

SUM OF NUMBERS

What to Do:

Write a program that asks for a range of integers and then prints the sum of the numbers in that range (inclusive).

You can use a formula to calculate this of course but what we want you to do here is practice using a loop to do repetitive work.

For example, the sum from 6 to 10 would be 0 + 6 + 7 + 8 + 9 + 10.

Notice our sum starts with zero (why?) and then we add each number in the range provided by the user. Just for fun, what is the mathematical formula to do this calculation?

 

Qué hacer:

Escriba un programa que solicite un rango de números enteros y luego imprime la suma de los números en ese rango (inclusive).

Puedes usar una fórmula para calcular esto por supuesto pero lo que queremos que hagas aquí es practicar usando un bucle para hacer un trabajo repetitivo.

Por ejemplo, la suma de 6 a 10 sería 0 + 6 + 7 + 8 + 9 + 10.

Observe que nuestra suma comienza con cero (¿por qué?) Y luego agregamos cada número en el rango proporcionado por el usuario. Sólo por diversión, ¿cuál es la fórmula matemática para hacer este cálculo?

 

Code/Código:

 

sumacode

 

Python:

 

sumapy

 

 


WSQ03

--Originally published at Site Title

PICK A NUMBER

What to Do:

Write a program that picks a random integer in the range of 1 to 100.

There are different ways to make that happen, you choose which one works best for you.

It then prompts the user for a guess of the value, with hints of ’too high’ or ’too low’ from the program.

The program continues to run until the user guesses the integer. You could do something extra here including telling there user how many guesses they had to make to get the right answer.

You might want to check that your program doesn’t always use the same random number is chosen and you should also split your problem solving into parts. Perhaps only generate the random number and print that as a first step.

 

Qué hacer:

Escriba un programa que elija un número entero aleatorio en el rango de 1 a 100.

Hay diferentes maneras de hacer que suceda, usted elige cuál funciona mejor para usted.

A continuación, solicita al usuario una estimación del valor, con indicaciones de ‘demasiado alto’ o ‘demasiado bajo’ del programa.

El programa continúa funcionando hasta que el usuario adivina el entero. Usted podría hacer algo adicional aquí incluyendo decir allí al usuario cuántas conjeturas tuvieron que hacer para conseguir la respuesta correcta.

Es posible que desee comprobar que su programa no siempre utiliza el mismo número aleatorio es elegido y también debe dividir su resolución de problemas en partes. Tal vez sólo generar el número aleatorio e imprimir que como un primer paso.

 

Code/Código:

randomcode

 

Python:

randompy

 


WSQ02

--Originally published at Site Title

TEMPERATURE

What to Do:

Write a program that will prompt the user for a temperature in Fahrenheit and then convert it to Celsius. You may recall that the formula is C = 5 ∗ (F − 32)/9.

 

Qué hacer:

Escriba un programa que le pedirá al usuario una temperatura en Fahrenheit y luego lo convertirá en Celsius. Puede recordar que la fórmula es C = 5 * (F – 32) / 9.

 

Code/Código:

tempcode

 

Python:

tempy

 

 

 


WSQ-01

--Originally published at Site Title

Fun with numbers

What to Do

Ask the user for two integer values, then use those two values to calculate and show the following:

  • 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.

 

 Qué hacer:

Pida al usuario dos valores enteros, luego,  use esos dos valores para calcular y mostrar lo siguiente:

  • La suma de los dos números.
  • La diferencia de los dos números.
    El producto de los dos números.
  • La división basada en enteros de los dos números (no hay punto decimal). Primero dividido por segundo.
  • El resto de la división entera de los dos números.

 

 

Code/Código:

code

 

Python:

py