Python File Codes Set 1
Python File Codes Set 1
I) for() statement
1) Print ‘n’ multiples of ‘m’.
2) Ask user to enter ‘n’ numbers and then check all the numbers to be odd or even.
3) Write code to check if a number is odd or even. If it is odd, print its next n
consecutive numbers. If it is even, print its next n multiples.
4) Print the following series: 1/2., 2/4, 3/9. ---- n/n2
5) Print square of ‘n’ numbers in the following format:
1x1=1
2x2=4
.
.
n xn =n2
III) while() statement
1) Print sum of first n odd numbers.
2) Print user name number of times he wants
3) Write code to accept numbers till the time user keeps saying “yes”. In the end print the
sum of all the numbers and the total number of times the user typed “yes”.
4) Print the following pattern
*
**
***
****
5) Give one example of infinite loop