Python Exercises-Iterations
Python Exercises-Iterations
6x1=6
6 x 2 = 12
.
.
.
.
6 x 10 = 60
8. Accept ‘n’ numbers from the user and display whether each number is odd or even.
9. Find the sum of first ‘n’ numbers.
10. Accept ‘n’ numbers and display their sum.
11. Accept ‘n’ numbers and display how many positive numbers, negative numbers or zeroes were entered.
12. Accept a maximum of 15 numbers or till the user enters ‘0’ indicating the end. Add up all the numbers divisible
by 4 and display the result.
13. Accept a number and display whether it is a prime number or not.
14. Accept a number and display the number of digits in it.
15. Find the sum of digits of a number.
16. Reverse a number.
17. Check if given number is palindrome or not.
18. Print the Fibonacci series (first ‘n’ terms)
19. Check if given number is an Armstrong number or not.
20. Find the factorial of given number.
21. Accept two numbers and find the value of one number raised to the power of another. (a b)
22. Accept a number and display it’s binary, hexadecimal and octal equivalent.
23. Accept a binary number and display its decimal equivalent.
24. Accept a hexa-decimal number and display its decimal equivalent.
25. Accept an octal number and display its decimal equivalent.
26. Accept a number from the user and print the following pattern. (Assume number entered is 3)
0 3
1 2
2 1
3 0
* * 1 1 1
** ** 12 22 23
*** *** 123 333 456
**** ** 1234 4444 7 8 9 10
***** * 12345 55555
29. Print the truth tables of AND, OR and NOT gates without using IF statements.
30. Evaluate the series:
3 5 7
x x x
sin (x) = x - + - + ………..
3! 5! 7!
31. Accept a positive integer and display the prime factors of the number.