Python Daily Question - 135
Step by step Explanation:-
1. List Initialization:
a = [2, 6, 8, 12, 18, 20, 24]
A list a is created with the elements: 2, 6, 8, 12, 18, 20, 24.
2. For Loop:
for i in a:
This loop iterates over each element in the list a.
3. If Condition:
if i % 6 == 0:
print(i)
For each element i in the list, the condition checks if i is divisible by 6 (i.e., the remainder when i is divided by 6 is zero).
If the condition is true, it prints the value of i.
Detailed Iteration:
First Iteration:
i = 2
2 % 6 != 0 (condition is false)
The value 2 is not printed.
Second Iteration:
i = 6
6 % 6 == 0 (condition is true)
The value 6 is printed.
Third Iteration:
i = 8
8 % 6 != 0 (condition is false)
The value 8 is not printed.
Fourth Iteration:
i = 12
12 % 6 == 0 (condition is true)
The value 12 is printed.
Fifth Iteration:
i = 18
18 % 6 == 0 (condition is true)
The value 18 is printed.
Sixth Iteration:
i = 20
20 % 6 != 0 (condition is false)
The value 20 is not printed.
Seventh Iteration:
i = 24
24 % 6 == 0 (condition is true)
The value 24 is printed.
Summary:
The code iterates over the list a and prints the elements that are divisible by 6.
Final Answer:
6
12
18
24
#coding_with_mani #python #code #viral #youtubeshorts #shorts #short #youtube #code #india #code #viral #youtubeshorts #shorts #short #youtube #code #india
#pythonquestions #python #coding #youtube #pythonprogramming #code #programminglanguage #pythonprogramming
#shorts #python #code #viral #trending #youtubeshorts #sql #sqlserver #data #database #daily #dailyshorts #dailyquestions #dailyseries