Page 341 - Information_Practice_Fliipbook_Class11
P. 341
Program 3: Write a program that accepts three colours from the user. If the user enters orange, red and green,
respectively, the message "Indian Flag" is displayed, otherwise, the message "Not an Indian Flag" is displayed.
Ans. '''
Objective: To accept 3 colours and check whether it is the Indian flag or not
Input: color1, color2, color3 - strings
Output: appropriate message
'''
color1 = input("Enter the first color: ").strip().lower()
color2 = input("Enter the second color: ").strip().lower()
color3 = input("Enter the third color: ").strip().lower()
if color1 == "orange" and color2 == "white" and color3 == "green":
print("Indian Flag")
else:
print("Not an Indian Flag")
Program 4: Write a program to accept two numbers and print all prime numbers between those two numbers.
Ans. '''
Objective: To accept two numbers and print all prime numbers between them
Input: num – numeric value
Output: prime numbers between start to end (inclusive)
'''
start = int(input("Enter the starting number: "))
end = int(input("Enter the ending number: "))
if start >= end:
print("Invalid input. The starting number should be less than the ending
number.")
else:
print(f"Prime numbers between {start} and {end}:")
for num in range(start, end + 1):
if num <= 1:
continue
Practical 327

