Quiz 1

In this Quiz I needed to create 3 programs, they were very easy. In the first one I needed to create a program to get the volume of a cylinder with a given radius and height by the user.

prog1

prog1running

The second program was about making multiplication, division and getting the reminder between two numbers.

prog2prog2running

The third and last part of the quiz was making something similar of the second program but now with addition and substraction.

prog3runningprog3

The quiz was easy, I finished it in time in class.

 

 

 

 

 

 

 

Quiz #1

Este es el primer quiz del curso de la materia Soluciones de problemas con programación, este quiz consiste en la elaboración de 3 programas, con la finalidad de reforzar los temas vistos en los primeros WSQ’S.

1111

Programa 1

Gracias a este programa, el usuario puede obtener el volumen de un cilindro, esta es la primera vez que utilizo el tipo float, que consiste en poder trabajar con números decimales.

Quiz 1 Prog1

Link GitHub: Quiz 1 prog 1

Programa 2

Este programa es similar al WSQ03, el cual consiste en realizar las siguientes operaciones:

  • Resta
  • Multiplicación
  • División
  • División con residuo

En este caso no se utilizó float, sino que se utilizó int.

Quiz 1 Prog2

Link GitHub: Quiz 1 prog 2

Programa 3

Este es el ultimo programa realizado para este primer quiz, muy parecido al programa 2, esta vez, el programa no te da el residuo de la división, esto es porque se utilizó el tipo float, por lo tanto se utilizan decimales.

Quiz 1 Prog3

Link GitHub: Quiz 1 prog 3

 

 

 

Time of the truth 📝📚

aD0PNnK_700b
(credits goes to http://9gag.com/gag/aD0PNnK)
☞ For the first program we had to write a program that asked the user for two values (radius, height) of type float and prints the volume (V=¶r2* h) of a cylinder with that radius/height as a float.

☞ The second program requested the user for two integer numbers, then use those two numbers to calculate and print the following:
* the product (multiplication) of the two numbers
* the INTEGER division of the two numbers
* the remainder from division of the two numbers

☞ The third one asked for the same as #2 but usingfloat numbers instead, in this program there won’t be remainder, so itshows the result of addition, subtraction, multiplication and division.

The github link for quiz #1 → https://github.com/mfcanov/Quiz-1.git

QUIZ#1

quiz1

quizz1
#1. En este programa nos piden calcular el volumen de un cilindro, así que como ya hemos visto antes primero debemos conocer la formula, que es pi*r^2*h. Sabiendo la formula sabemos que podemos definir pi en la libreria comose puede ver en la linea 2, como estamos utilizando una potencia y quizimos utilizar la función pow, esta es una función que va dentro de la librería cmath, por lo cual se debe agregar tal cual como aparece en la línea 3, entonces sabemos que las variables que tenemos que tener son el radio y la altura que serán las que se pedirán al usuario, y se debe poner el volumen que es donde se guardara el resultado. Dentro del main se piden dichas variables al usuario y se pone la formula con las variables para que se lleve a cabo, por ultimo se manda llamar el resultado que en este caso se le puso “volumen” como se observa en la linea 19.
quizzz1
Cómo se muestra ahí, esta compilado.
quizzzz1
#2. Este es un programa para calcular tres operaciones diferentes, donde se habla de la multiplicación, división y module, entonces como ya sabemos se pide al usuario las variables, osea los números con los cuales se llevarán acabo las operaciones, en este caso se guardaran como a y b, y se debe poner un nombre a cada operación donde quedara guardado el resultado, en este caso para hacerlo más evidente y sin pierde, se les dará el nombre de dicha operación, llamándolas: multiplicación, división y module. Dentro del main se piden las variables al usuario y se llevan a cabo textualmente las operaciones mandándolas llamar como dije previamente en cada una de ellas.

 

quizzzzz1
Aquí se muestra compilado, haciendo la multiplicación que es 3*4=12, la división que es 3/4=0 y el module

quizzzzzz1
quizzzzzzz1

Continue reading “QUIZ#1”

⁄⁄⁄Quiz 1⁄⁄⁄

Photograph credit

Well quiz 1 really woke us up didn’t it? We had to do three programs in one quiz. This time is different from my previous posts. Usually I give a link to my original, more complex code and a link to a simpler code that gets the job done. This time I’m not gonna make a tutorial but rather explain how my programs work and why they work.

The first one is to calculate the volume of a cylinder, the second is to do a program similar to WSQ03 using type int and the last one was the same as the second one expect using type float.

code:

Prog1.cpp

Prog2.cpp

Prog3.cpp

Here is the quiz(I got it from ALEXHFOO‘s BLOG): captura-de-pantalla-2016-02-09-a-las-11-50-01

And now for the explanation on how these programs work.

Made by Orlando Lara

 

Quiz01 – Defining and Testing

First quiz, and as I had no computer to work with, I answered it on paper. The first step was to create a python file named prog1.py that contains a function that has a cylinder’s radius and a height as parameters and outputs the cylinder’s volume. Now let’s test what I did:

———————————————————————-

Screen Shot 2016-02-09 at 8.59.09 AM

———————————————————————-

There’s the function, but that’s just the beginning, let’s test it, of course :

———————————————————————-

Editor : 

Screen Shot 2016-02-09 at 9.25.32 AM

Terminal : 

Screen Shot 2016-02-09 at 9.33.35 AM

———————————————————————-

To prove my answer as correct I  called my function with a and b as parameters, when a and b are inputs by the user, raw_input returns data as strings, that’s why I call float on it. Here I am using python 2.7.11, if you are using python 3 you’d have to change raw_input for input and add parentheses when calling print on volume: print(volume(a, b)).

Next is the second part. As expected, the new python file is named prog2.py, it should ask for two numbers and return their product, their integer division, and the remainder from their division. This is what I turned in : 

———————————————————————-

Editor : 

Screen Shot 2016-02-09 at 9.32.40 AM

Terminal : 

Screen Shot 2016-02-09 at 9.31.46 AM

———————————————————————-

This second part didn’t ask to use float numbers, but integers, thus int is called on the input. It wasn’t necessary to edit this any further to prove the answer correct, as it proves itself.

This is my post for the first quiz on my Programming Fundamentals course.