Quiz # 9

This week’s quiz consisted of creating a program to determine the distance between two points. You can check the mathematical way to do that here.

I did this quiz in two different ways. The first one was by defining a function with four different parameters -(x1, y1, x2,y2)- and asking the user for each value one by one:


In the final output, I first had it displaying all the decimals in the answer. However, I didn’t like the way it looked, so I asked my teacher Ken how to make it so it only showed two decimals. We searched on the internet and found in this page the following image that shows how to do it:

General way of working of the string modulo operator

I did it, and this is how my program ran:


The second way I in which I solved this quiz was by defining the function with only two parameters, each containing two values: the x and the y of the point. To do this, I used lists, like this:


And here is the way it ran:


2 thoughts on “Quiz # 9

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