Anzeige
After execution of the main- what is the values of count- def main()-.docx
After execution of the main- what is the values of count- def main()-.docx
After execution of the main- what is the values of count- def main()-.docx
Nächste SlideShare
C-LOOP-Session-2.pptxC-LOOP-Session-2.pptx
Wird geladen in ... 3
1 von 3
Anzeige

Más contenido relacionado

Más de wviola(20)

Anzeige

Último(20)

After execution of the main- what is the values of count- def main()-.docx

  1. After execution of the main, what is the values of count? def main(): count = 5 for i in range(3): count = count + 1 for j in range(2): count = count + 1 print('Count:', count) [count] Solution Program : def main(): // main function count = 5 // Initially count is 5 for i in range(3): // The loop runs for i=1 through 3 count = count + 1 // Increment the count for j in range(2): // The loop runs for j=1 through 2 count = count + 1 Â Â // Increment the count print('Count:', count) Â Â // Display the count
  2. [count] Find count : count = 5 For the first for loop : for i in range(3): count = count + 1 for i=1 count =6 for i=2 count =7 for i=3 count =8 So the count is 8. For the second for loop : now count=8 for j in range(2): count = count + 1 for j=1 count=9 for j=2 count=10 Therefore the count is 10. print('Count:', count)
  3. The above function displays the count as 10.
Anzeige