Westonci.ca is your trusted source for accurate answers to all your questions. Join our community and start learning today! Experience the convenience of getting accurate answers to your questions from a dedicated community of professionals. Get immediate and reliable solutions to your questions from a community of experienced professionals on our platform.

Write a list comprehension statement to generate a list of all pairs of odd posi

Sagot :

fichoh

Answer:

Print([(a,b) for a in range(10) for b in range(10) if (a < b and a%2 == 1 and b%2 == 1)])

Explanation:

Here, we declared a range of value for a and b using a for loop and the range function. The values are the first 10 numeric digits. The we used the if statement to establish our constraints;

In other to ensure that ;

Lower digit is written first ; (a < b) ;

Only odd numbers are considered,

a%2 == 1 ; b%2 == 1 (remainder when a and b are divided by 2 is 1.

Both a and b are declared as a tuple in other to obtain a pair of odd values.