Class XI Computer Science Loop Assignment for First Weekly Test
1. Write a Python script to input an integer n and generate following sequence:
a) 1, 2, 3, 4, …, (n-1), n
b) n, n-1, n-2, …, 2, 1
c) 1, 3, 5, 7, …, (2n-3), (2n-1)
d) 2, 4, 6, 8, …, (2n-2), 2n
e) 5n, 5n-5, 5n-10, …, 10, 5
2. Write a Python script to input an integer n and find the sum of the following sequence:
a) 1+2+3+4+…+(n-1)+n
b) 2+4+6+8+…+(2n-2)+2n
c) 1+3+5+7+…+(2n-3)+(2n-1)
d) 4+8+12+…+(4n-4)+4n
e) 7n+(7n-7)+(7n-14)+…+14+7
3. Write a Python script to input an integer n and find the sum of the following sequence:
a) (1)+(1+2)+(1+2+3)+ … +(1+2+3+…+n)
b) (2)+(2+4)+(2+4+6)+ … +(2+4+6+…+2n)
c) (1)+(1+3)+(1+3+5)+ … +(1+3+5+…+2n-1)
d) (5)+(5+10)+(5+10+15)+…+(5+10+15+…+5n)
e) (8)+(8+16)+(8+16+24)+…+(8+16+24+…+8n)
4. Write a Python script to input an integer n and find the sum of the following sequence:
a) 1!+2!+3!+4!+…+n!
b) 2!+4!+6!+8!+…+(2n)!
c) 1!+3!+5!+7!+…+(2n-1)!
5. Write a Python script to input a floating-point x and an integer n; find the sum of the
following sequence:
a) 1+x+x2+x3+…+xn
b) 1+x2+x4+x6+…+x2n
c) 1+x+x3+x5+…+x2n-1
1 1 1 1
d) 1+ x + 2 + 3 + …+ n
x x x
6. Write a Python script to input a floating-point x and an integer n; find the sum of the
following sequence:
2 3 n
x x x x
a) 1+ + + +…+
1! 2! 3 ! n!
2 3 n
x x x x
b) 1− + − + …(−1)n
1! 2! 3! n!
2 4 6 2n
x x x x
c) 1+ + + +…+
2! 4 ! 6 ! (2 n)!
3 5 2 n−1
x x x x
d) 1+ + + +…+
1! 3 ! 5 ! (2n−1)!