python | for loop lab
For loop
1. Write a program which accept a number ‘N’ and then find the sum of the integer from 1 to 2, then 1 to 3 then 1 to 4 and so forth until it display the sum of integers from 1 to N.
2. Write a program to print a factorial table using for loop
For ex 1! 1
2! 2
3! 6
3. Write a program to test whether a given number is prime or not.?(Use GOTO statement).
4. Above program without goto statement.
5. Print all the prime numbers between two given numbers.
6. Write a program to compute the sum of first ‘N’ terms (n>=1) of the series
1-3+5-7+9……………………
For loop Nesting
7.Write a program to print the multiplication table
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
.
.
1. Write a program which accept a number ‘N’ and then find the sum of the integer from 1 to 2, then 1 to 3 then 1 to 4 and so forth until it display the sum of integers from 1 to N.
2. Write a program to print a factorial table using for loop
For ex 1! 1
2! 2
3! 6
3. Write a program to test whether a given number is prime or not.?(Use GOTO statement).
4. Above program without goto statement.
5. Print all the prime numbers between two given numbers.
6. Write a program to compute the sum of first ‘N’ terms (n>=1) of the series
1-3+5-7+9……………………
For loop Nesting
7.Write a program to print the multiplication table
1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
.
.
0 comments:
Post a Comment