# Example 1 x = [3,6,8,2,1] total = 0 n = len(x) for i in range(n): total = total + x[i] print(total) # Example 2 print() x = [3,6,8,2,1] total = 0 n = len(x) for i in range(0,n): total = total + x[i] print(total) # Example 3 print() x = [4, 5.2, 'Car', [1,2,3]] n = len(x) for i in range(0,n): print(x[i]) # Example 4 print() x = [4, 5.2, 'Car', [1,2,3]] for i in x: print(i) # Example 5 s = "Today is Monday" for i in s: print(i) # Example 6 print(' ') s = "Today is Monday" n = len(s) for i in range(0,n): print(s[i]) # Example 7 # Tabluate y = sin(x)*cos(x) on [0,2pi] for some input # value of n print(' ') print(' ') import math as m n = int(input('Input n ')) a = 0 b = 2*m.pi h = (b-a)/n x = [] y = [] for i in range(1,n+2): temp1 = a + (i-1)*h temp2 = m.sin(temp1)*m.cos(temp1) x.append(temp1) y.append(temp2) print(temp1, temp2) # Example 8 # Tabluate y = sin(x)*cos(x) on [0,2pi] for some input # value of n print(' ') print(' ') # import math as m n = int(input('Input n ')) a = 0 b = 2*m.pi h = (b-a)/n x = [] y = [] for i in range(0,n+1): temp1 = a + i*h temp2 = m.sin(temp1)*m.cos(temp1) x.append(temp1) y.append(temp2) # x.append(a+i*h) # y.append(m.sin(x[i])*m.cos(x[i])) print(temp1, temp2)