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:

https://pythoncoursesite.wordpress.com/2017/03/13/quiz-9/

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:

T

TT

TTT

TT

T

At first I did it like this:

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:

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

https://pythoncoursesite.wordpress.com/2017/02/26/a-look-back-to-my-programs-pt-2-recursion/

https://pythoncoursesite.wordpress.com/2017/02/16/factorial-calculator/

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:

Another way to do it is like this:

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

### Like this:

Like Loading...

## One thought on “Quiz # 11 pt. 1”