Quiz # 11 pt. 1

Before the exam there was a quiz to be solved that would help us study and know more or less what type of problems could come in it. This quiz consisted of 10 questions, some of which were in previous quizzes or class exercises.

The first one we had already done. It was about getting the distance between two points, and I showed that in the following post:


The second asked to create a function that receives an n integer and creates a symetrical triangle in which the largest line has n elements. For example, if the number introduced is three, the function should create something like this:






At first I did it like this:triángulo

but my teacher told me I could’nt use the multiplication of strings to solve it, because this doesn’t really exist in other programming languages, so I had to think of another way to do it. I wrote two functions instead; one that would print each line, and one that would make the whole triangle:triángulo2triángulo_run

In the next exercise I created a factorial function, and I already have two posts about that:



Problem four was very simple. It just asked for a function that returns the average of a list of numbers:


And in number five, a function that returned the minimum number of four:minimumminimum_run

Another way to do it is like this:minimum2minimum2run

I’ll show the other five programs in the next post 🙂

One thought on “Quiz # 11 pt. 1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s