In: Computer Science
Write a python program which asks the user to enter a positive number that is greater than 30 called, “num2” and then does the following: o 1) Print all numbers between 1 and “num2” that are divisible by 2 and 3. o 2) Print all numbers between 1 and “num2” that are either divisible by 6 or 7. o 3) Print all numbers between 1 and “num3” that is not divisible by 5
Python program :
num2 = int(input("Please enter a positive number greater than 30: ")) # ask number from user
print("The number that are divisible by 2 and 3 are:")
for val in range(1,num2+1): # prints numbers divisible by both 2 and 3
if val%2==0 and val%3==0:
print(val)
print()
print("The number that are divisible by 6 or 7 are:")
for val in range(1,num2+1): # prints numbers divisible by 6 or 7
if val%6==0 or val%7==0:
print(val)
print()
print("The number that are not divisible by 5 are:")
for val in range(1,num2+1): # prints numbers which are not divisible by 5
if val%5!=0:
print(val)
Output :