Page 502 - ComputerScience_Class_11
P. 502
Program 11: Write a program to enter any number and check it is a cyclo number or not. If the first and last digit of a
number are same then it is called a cyclo number.
Example: 232,2342 etc.
Program 11.py
File Edit Format Run Options Window Help
a=int(input('Enter any number: '))
c=a
l=a%10
while a>9:
a=a//10
if l==a:
print(c,'is cyclo number')
else:
print(c,'is not a cyclo number')
Output
Enter any number: 121
121 is cyclo number
The Nested Loop
A nested loop is a loop inside another loop. In Python, you can have one loop inside another for loop or while loop. The
outer loop controls the number of times the inner loop is executed. This structure is useful when you need to perform
repeated operations on multi-dimensional data (like grids, matrices or tables) or need to loop through several levels
of data.
Syntax:
for outer_variable in outer_sequence:
for inner_variable in inner_sequence:
# Code to be executed for each combination of outer_variable and inner_variable
Working of nested loop
The working of nested loop is given below:
1. The outer loop runs once and for each iteration, the inner loop runs completely.
2. The inner loop runs as many times as the outer loop instructs, so the total number of iterations is the product of the
outer and inner loop's iteration counts.
Program 12: Write a program to print the following pattern:
1
12
123
1234
500 Touchpad Computer Science (Ver. 3.0)-XI

