Python Classroom Notes – 19/April/2024

loops

while "<expression>":
   body..
   ...
   ...
  • while executes the body as long as expression is true
  • Project euler problem 1 using while
index = 1
sum = 0
while index < 10:
    if index%3 == 0 or index%5 == 0:
        sum += index
    index += 1
print(sum)

for item in <collection/sequence>:
   body

  • Lets learn a python function to generate numerical sequence

  • Refer Here for loops program

  • Refer Here for project euler problem 2 solution

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Plugin for Social Media by Acurax Wordpress Design Studio

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%