Python Daily Question - 121

Опубликовано: 12 Июль 2026
на канале: coding_with_mani
14
0

Python Daily Question - 121

Step-by-Step Explanation:

1. Initialization:
a = 8
b = 8

Both a and b are initialized with the value 8.

2. Outer Loop:
for i in range(8, 9):

This loop will run only once with i being 8 because range(8, 9) includes only the number 8.

3. Inner Loop:
for j in range(i):

Since i is 8, this inner loop will run 8 times with j taking values from 0 to 7.

4. Inner Loop Body:
a = a - 1

This statement decreases the value of a by 1 in each iteration of the inner loop.
After 8 iterations, a will be 8 - 8 = 0.

5. Decrement b:
b = b - 2

This statement is outside the inner loop but inside the outer loop, so it will execute once after the inner loop completes.
This decreases b by 2, so b becomes 8 - 2 = 6.

6. Print Statements:
print(str(b))
print(str(a))

These statements print the final values of b and a as strings.

Summary of Changes:

a starts at 8 and is decremented 8 times, so it ends at 0.
b starts at 8 and is decremented once by 2, so it ends at 6.

Final Output:
6
0

So, the final values of b and a are printed as 6 and 0, respectively.



























#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