Computer Science, asked by dharshankanish2, 6 hours ago

Write a python program to display all 3 digit even numbers.​

Answers

Answered by HarishAS
7

\underline{\tt{Program}}:\\ \\ \texttt{for i in range (100,1000): }\\ \\ {\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ } \texttt{if i\%2==0: }\\ \\ {\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ } {\ \ \ \ \ \ \ \ \ \ } \texttt{print(i)}

Explanation :

Here i am checking all the numbers from 100 to 999 using a for loop and printing it if the remainder when they are divided by 2 is 0 .

Because all even numbers are divisible by 2 and gives remainder 0.

Hope this help : )

Answered by NirmalPandya
0

In Python, we can use a for loop to iterate through all the 3 digit numbers from 100 to 999, and then use an if statement to check if each number is even or not. If a number is even, it can be printed to the console using the print() function.

Here's a Python program that displays all 3 digit even numbers:

for num in range(100, 1000):

   if num % 2 == 0:

       print(num)

This program uses a for loop to iterate through all the numbers from 100 to 999. For each number, it checks whether it is even (i.e., divisible by 2) using the modulo operator %. If the number is even, it is printed to the console using the print() function.

Note that the program could be modified to store the even numbers in a list or other data structure if desired.

#SPJ3

Similar questions