Python for loop examples
1.Sum integers from 1 to 100 in Python:
b=0 for i in range(100): b+=i print(b)
2.Adding odd numbers up to 10 :
c=0 for i in range(100): if i%2==1: c+=i print(c)
3.Coding that finds the sum of dimensions up to the number received from the user:
c=0 n=int(input("Bir sayı giriniz: ")) for i in range(n): c+=i print(c)
4.Adding even numbers up to 100:
a=0 for i in range (10): if i%2==0: a+=i print(a)
5. Manipulating a list with a for loop : You can change the star cursor.
list=("Hello") for i in list: print(i,end="*")
6.Printing the elements of a list one after the other:
list1=["Mozart","Beethoven","Schubert"] for i in list1: print(i)
7.Adding numbers in an array:
t=[3,4,5,6,7,8] a=0 for i in t: a+=i print(a)