10 - Write a program in Python to generate the following pattern using nested loops:
12345
1234
123
12
1
for i in range(5,0,-1):
for j in range(1,i+1):
print(j,end='')
print()
Output:
12345
1234
123
12
1
12345
1234
123
12
1
for i in range(5,0,-1):
for j in range(1,i+1):
print(j,end='')
print()
Output:
12345
1234
123
12
1
1
22
333
4444
55555
for i in range(1,6):
for j in range(1,i+1):
print(i,end='')
print()
Output:
1
22
333
4444
55555
1
12
123
1234
12345
for i in range(1,6):
for j in range(1,i+1):
print(j,end='')
print()
Output:
1
12
123
1234
12345
11111
22222
33333
44444
55555
for i in range(1,6):
for j in range(1,6):
print(i,end='')
print()
Output:
11111
22222
33333
44444
55555
12345
12345
12345
12345
12345
for i in range(1,6):
for j in range(1,6):
print(j,end='')
print()
Output:
12345
12345
12345
12345
12345
a=int(input("Enter First Number: "))
b=int(input("Enter Second Number: "))
c=int(input("Enter Third Number: "))
if a<=b and a<=c:
print(a," is smallest number")
elif b<=a and b<=c:
print(b," is smallest number")
else:
print(c," is smallest number")
Output:
Enter First Number: 8
Enter Second Number: 5
Enter Third Number: 6
5 is smallest number
Enter First Number: 7
Enter Second Number: 9
Enter Third Number: 2
2 is smallest number
Enter First Number: 4
Enter Second Number: 6
Enter Third Number: 9
4 is smallest number
a=int(input("Enter First Number: "))
b=int(input("Enter Second Number: "))
c=int(input("Enter Third Number: "))
if a>=b and a>=c:
print(a," is largest number")
elif b>=a and b>=c:
print(b," is largest number")
else:
print(c," is largest number")
Output:
Enter First Number: 6
Enter Second Number: 7
Enter Third Number: 8
8 is largest number
Enter First Number: 8
Enter Second Number: 7
Enter Third Number: 4
8 is largest number
Enter First Number: 5
Enter Second Number: 9
Enter Third Number: 7
9 is largest number
Enter First Number: 7
Enter Second Number: 7
Enter Third Number: 7
7 is largest number
a=int(input("Enter First Number: "))
b=int(input("Enter Second Number: "))
if a<b:
print(a," is smaller than ",b)
elif b<a:
print(b,"is smaller than ",a)
else:
print("Both numbers are equal")
Output:
Enter First Number: 5
Enter Second Number: 3
3 is smaller than 5
Enter First Number: 6
Enter Second Number: 9
6 is smaller than 9
Enter First Number: 5
Enter Second Number: 5
Both numbers are equal
a=int(input("Enter First Number: "))
b=int(input("Enter Second Number: "))
if a>b:
print(a," is greater than ",b)
elif b>a:
print(b,"is greater than ",a)
else:
print("Both numbers are equal")
Output:
Enter First Number: 5
Enter Second Number: 3
5 is greater than 3
Enter First Number: 6
Enter Second Number: 9
9 is greater than 6
Enter First Number: 5
Enter Second Number: 5
Both numbers are equal
msg=input("Enter a message: ")
print("Your Message is : ",msg)
Output:
Enter a message: Python
Your Message is : Python