Logo

dev-resources.site

for different kinds of informations.

Understanding the Usage of break and continue Keywords

Published at
11/15/2024
Categories
programming
breakandcontinue
Author
Hasan Mahmud Rhidoy
Categories
2 categories in total
programming
open
breakandcontinue
open
Understanding the Usage of break and continue Keywords

break āĻāĻŦāĻ‚ continue āĻ•ā§€āĻ“ā§ŸāĻžāĻ°ā§āĻĄā§‡āĻ° āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ° āĻĻā§‡āĻ–āĻžāĻ¨ā§‹āĻ° āĻœāĻ¨ā§āĻ¯ āĻ†āĻŽāĻ°āĻž āĻāĻ•āĻŸāĻŋ āĻ‰āĻĻāĻžāĻšāĻ°āĻŖ āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ° āĻ•āĻ°āĻŦ āĻ¯āĻž āĻ†āĻĒāĻ¨āĻžāĻ° āĻŦāĻžāĻ¸ā§āĻ¤āĻŦ āĻœā§€āĻŦāĻ¨ā§‡āĻ° āĻĒā§āĻ°āĻŦāĻ˛ā§‡āĻŽā§‡āĻ° āĻ¸āĻžāĻĨā§‡ āĻŽāĻŋāĻ˛ āĻ°ā§‡āĻ–ā§‡ āĻ¤ā§ˆāĻ°āĻŋ āĻ•āĻ°ā§‡āĻ›āĻŋāĨ¤

Break

āĻ†āĻĒāĻ¨āĻŋ āĻāĻ•āĻŸāĻŋ āĻ˛āĻŸāĻžāĻ°āĻŋāĻ° āĻŸāĻŋāĻ•āĻŋāĻŸ āĻ•āĻŋāĻ¨ā§‡āĻ›ā§‡āĻ¨ āĻāĻŦāĻ‚ āĻāĻ•āĻŸāĻŋ āĻ¨āĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āĻŸ āĻ¨āĻŽā§āĻŦāĻ° āĻĒāĻžāĻ“āĻ¯āĻŧāĻžāĻ° āĻ¸āĻžāĻĨā§‡ āĻ¸āĻžāĻĨā§‡ āĻ–ā§‡āĻ˛āĻž āĻĨāĻžāĻŽāĻžāĻ¤ā§‡ āĻšāĻŦā§‡āĨ¤ āĻ¯āĻĻāĻŋ āĻ†āĻĒāĻ¨āĻŋ ā§­ āĻ¨āĻŽā§āĻŦāĻ°āĻŸāĻŋ āĻĒāĻžāĻ¨, āĻ¤āĻžāĻšāĻ˛ā§‡ āĻ–ā§‡āĻ˛āĻž āĻĨāĻžāĻŽāĻŦā§‡āĨ¤

tickets = [1, 3, 5, 7, 9, 11, 13]
lucky_number = 7
found = False

for ticket in tickets:
    if ticket == lucky_number:
        found = True
        break  # āĻ˛ā§āĻĒ āĻĨā§‡āĻ•ā§‡ āĻŦā§‡āĻ°āĻŋāĻ¯āĻŧā§‡ āĻ¯āĻžāĻŦā§‡āĻ¨ āĻ•āĻžāĻ°āĻŖ āĻ˛āĻžāĻ•āĻŋ āĻ¨āĻŽā§āĻŦāĻ° āĻĒāĻžāĻ“āĻ¯āĻŧāĻž āĻ—ā§‡āĻ›ā§‡āĨ¤
    print(f"Checked ticket: {ticket}")

if found:
    print("Lucky number found!")
else:
    print("Lucky number not found.")

Continue

āĻāĻ•āĻŸāĻŋ āĻĒāĻ°ā§€āĻ•ā§āĻˇāĻžāĻ° āĻ–āĻžāĻ¤āĻž āĻŽā§‚āĻ˛ā§āĻ¯āĻžāĻ¯āĻŧāĻ¨ āĻ•āĻ°āĻ›ā§‡āĻ¨ āĻ¯ā§‡āĻ–āĻžāĻ¨ā§‡ āĻĒā§āĻ°āĻ¤āĻŋāĻŸāĻŋ āĻ›āĻžāĻ¤ā§āĻ°ā§‡āĻ° āĻ¨āĻŽā§āĻŦāĻ° āĻ¯āĻžāĻšāĻžāĻ‡ āĻ•āĻ°āĻ¤ā§‡ āĻšāĻŦā§‡āĨ¤ āĻ¯āĻĻāĻŋ āĻ•ā§‹āĻ¨ā§‹ āĻ›āĻžāĻ¤ā§āĻ°ā§‡āĻ° āĻ¨āĻŽā§āĻŦāĻ° ā§Šā§Š-āĻāĻ° āĻ•āĻŽ āĻšāĻ¯āĻŧ, āĻ¤āĻžāĻšāĻ˛ā§‡ āĻ¤āĻžāĻ•ā§‡ āĻĢā§‡āĻ˛ āĻšāĻŋāĻ¸ā§‡āĻŦā§‡ āĻšāĻŋāĻšā§āĻ¨āĻŋāĻ¤ āĻ•āĻ°ā§‡ āĻĒāĻ°āĻŦāĻ°ā§āĻ¤ā§€ āĻ›āĻžāĻ¤ā§āĻ°ā§‡āĻ° āĻ¨āĻŽā§āĻŦāĻ° āĻĻā§‡āĻ–āĻ¤ā§‡ āĻšāĻŦā§‡, āĻ•āĻŋāĻ¨ā§āĻ¤ā§ āĻ•ā§‹āĻ¨ā§‹ āĻ—ā§āĻ°ā§‡āĻĄ āĻ¯ā§‹āĻ— āĻ•āĻ°āĻž āĻšāĻŦā§‡ āĻ¨āĻžāĨ¤

scores = [45, 67, 29, 75, 33, 48, 55]
passing_score = 33
total_score = 0
num_passed = 0

for score in scores:
    if score < passing_score:
        print(f"Score {score} is below passing mark.")
        continue  # āĻāĻ‡ āĻ›āĻžāĻ¤ā§āĻ°ā§‡āĻ° āĻ¸ā§āĻ•ā§‹āĻ° āĻ¯ā§‹āĻ— āĻ¨āĻž āĻ•āĻ°ā§‡ āĻĒāĻ°āĻŦāĻ°ā§āĻ¤ā§€ āĻ›āĻžāĻ¤ā§āĻ°ā§‡āĻ° āĻ•āĻžāĻ›ā§‡ āĻ¯āĻžāĻŦā§‡āĻ¨āĨ¤
    total_score += score
    num_passed += 1

if num_passed > 0:
    average_score = total_score / num_passed
else:
    average_score = 0

print("Average Score of Passed Students:", average_score)

āĻāĻ‡ āĻ‰āĻĻāĻžāĻšāĻ°āĻŖāĻ—ā§āĻ˛āĻŋ āĻŦāĻžāĻ¸ā§āĻ¤āĻŦ āĻœā§€āĻŦāĻ¨ā§‡āĻ° āĻŦāĻŋāĻ­āĻŋāĻ¨ā§āĻ¨ āĻ¸āĻŽāĻ¸ā§āĻ¯āĻžāĻ¯āĻŧ break āĻāĻŦāĻ‚ continue āĻ•ā§€āĻ“ā§ŸāĻžāĻ°ā§āĻĄā§‡āĻ° āĻŦā§āĻ¯āĻžāĻŦāĻšāĻžāĻ° āĻĻā§‡āĻ–āĻžāĻ¯āĻŧāĨ¤ āĻāĻ‡āĻ­āĻžāĻŦā§‡ āĻ†āĻĒāĻ¨āĻŋ āĻŦāĻŋāĻ­āĻŋāĻ¨ā§āĻ¨ āĻ¸āĻŽāĻ¸ā§āĻ¯āĻžāĻ¯āĻŧ āĻāĻ‡ āĻĻā§āĻŸāĻŋ āĻ•ā§€āĻ“āĻ¯āĻŧāĻžāĻ°ā§āĻĄ āĻ•ā§€āĻ­āĻžāĻŦā§‡ āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ° āĻ•āĻ°āĻŦā§‡āĻ¨ āĻ¤āĻž āĻŦā§āĻāĻ¤ā§‡ āĻĒāĻžāĻ°ā§‡āĻ¨āĨ¤

Featured ones: