This commit is contained in:
2025-08-19 22:28:36 +05:30
parent 7825e98a93
commit 839a835f2a

78
src/basic/loops.py Normal file
View File

@@ -0,0 +1,78 @@
# i = 10
# while i < 20:
# print(i)
# i += 1
# i = 1
# while i < 6:
# print(i)
# if i == 3:
# break
# i += 1
# # Looping Through a String
# for letter in "Anikuttan":
# print(letter)
# fruits = ["apple", "banana", "cherry"]
# for x in fruits:
# print(x)
# fruits = ["apple", "banana", "cherry"]
# for x in fruits:
# if x == "banana":
# break
# print(x)
# range()
# for i in range(4): # output 0 to 3
# print(i)
# for i in range(4, 8): # Output 4 to 7
# print(i)
# for x in range(2, 30, 3): # start, stop, step
# print(x)
# # Else in For Loop
# for x in range(6): # Print all numbers from 0 to 5, and print a message when the loop has ended
# print(x)
# else:
# print("Finally finished!")
# for x in range(6):
# if x == 3:
# # else block will not be executed if the loop is stopped by a break statement.
# break
# print(x)
# else:
# print("Finally finished!")
# adj = ["red", "big", "tasty"]
# fruits = ["apple", "banana", "cherry"]
# for x in adj:
# for y in fruits:
# print(x, y)
# students = [{
# "name": "Ani",
# "subject": "Tamil"
# }, {
# "name": "Kuttan",
# "subject": "English"
# }]
# for value in students:
# print(value['name'])