Quiz # 4

For this quiz I had to make a program that would print the smallest value and the sum of the square of three numbers given by the user (x,y, and z).

I decided to use conditionals to get the smallest value, like this:

if      x <= y <= z     or     x <= z <=y:
return x
elif   y <= x <=z    or    y <=z <=x:
return y
return z

At first I didn’t put the equals in the equation, so there was trouble when two inputs were the same. However, I then added them to my code and everything was fine! When I was done this is how it looked:


And this is how it ran:


One thought on “Quiz # 4

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