## Tuesday, October 6, 2020

Solution Exercise 763: python algorithm to find all tuples verifying some conditions #### Exercise 763

Write a python algorithm as function which take as argument an integer n and return the list of all tuples (p , q) of positive integers p and q shch that the Euclidean division of p by q gives 3 as the quotient and 2 as the remainder.

#### Solution

``````def listTuples(n):
# Initializing the list of all tuples (p,q)
listTup = []

for i in range(1 , n + 1):
for j in range(1 , i + 1):
if (i%j == 2 and i//j == 3):
listTup.append((i,j))

return listTup
# Testing algorithm for n = 24
print('The list of all tuples (p,q) is  : ' , listTuples(24))
# The output is : The list of all tuples (p,q) is  :  [(11, 3), (14, 4), (17, 5), (20, 6), (23, 7)]``````

Younes Derfoufi
my-courses.net

## Python Exercises With Solutions

1. Python Arithmetic Exercises
2. Equations & System Of Equations
3. Polynomials and Functions
4. Python Arithmetic Exercises
5. Numpy, Matplolib, Sympy , Scipy - Exercises
6. Python Arithmetic Exercises

Younes Derfoufi

## Sample Text 