Plz Explain the code.. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Plz Explain the code..

i=2 while i<=19: print(i+5) I*=7

22nd Dec 2020, 9:36 AM
คгשเภ๔ кย๓คг
คгשเภ๔ кย๓คг - avatar
5 Answers
+ 3
Arvind Kumar I see you have completed the Python course. What part of the code don't you understand?
22nd Dec 2020, 9:43 AM
David Ashton
David Ashton - avatar
+ 3
It's a while loop, which will work until the condition is true. So here: 2 <= 19 returns true and print 2 + 5 = 7 now i *= 7, i = i * 7 = 2 * 7 = 14 again 14 <= 19 is true and print 14 + 5 = 19 now i *= 7, i = i * 7 = 14 * 7 = 98 now 98 <= 19 is false, so it will stop here. finally output will be 7, 19
22nd Dec 2020, 9:59 AM
A͢J
A͢J - avatar
+ 3
Arvind Kumar I found that too, so after I finished the course, I started over at the beginning of the lessons and worked my way through them slowly and practiced writing my own codes for each new concept. I used Google a lot. As it helped to see each new concept from several different viewpoints, I looked them up in tutorials like https://www.programiz.com/JUMP_LINK__&&__python__&&__JUMP_LINK-programming https://www.learnpython.org and https://docs.python.org/3.8/tutorial/ It was a slower process but it was worth it because the knowledge stuck better. 🙂
22nd Dec 2020, 2:58 PM
David Ashton
David Ashton - avatar
+ 2
Use indentation properly
22nd Dec 2020, 9:40 AM
Sahil Singh
Sahil Singh - avatar
+ 2
David Ashton sir🙏🏻 yeah I have completed the Python course.but whenever I go for revision and challenge someone I face this kind of random doubts.
22nd Dec 2020, 9:53 AM
คгשเภ๔ кย๓คг
คгשเภ๔ кย๓คг - avatar