Computer Science, asked by sadaffarheen104, 1 month ago

WAP to print all numbers between 50 and 100 which are not divisible by 3 and 5?​

Answers

Answered by surajgupta82
0

Answer:

Hope it will help you!!☺☺☺

Attachments:
Answered by Equestriadash
1

The following co‎des have been written using Python.

\tt for\ i\ in\ range(50, 101):\\{\ \ \ \ \ }if\ i\%3\ !=\ 0\ and\ i\%5\ !=\ 0:\\{\ \ \ \ \ }{\ \ \ \ \ }print(i)

We use a for loop, an iteration statement used to perform repeated-checking over a given range. In the loop, the range given is (50, 101), indicating that the traversing variable 'i', takes each value from 50 up to 100 and proceeds with the succeeding commands. The reason we give 101 instead of 100 is because the range function always excludes the last value. We use a conditional statement to check the divisibility of the number with 3 and 5. If they aren't divisible by both the numbers, they get printed, as per the question. In the conditional statement, we use a logical operator \tt and to ensure that both conditions, the divisibility by 3 and the divisibility by 5 are satisfied, and not just one out of the two.

Similar questions