numbers = [1,2,3,4,5]
for num in numbers:
if num % 2 == 0:
print(num, "- is even number.")
continue
print(num, "- is odd number.")
else:
print("\n")
print("For loop exited.")
--------------------------------------
num = int(input("Please enter the number:"))
isDivisible = False
i = 2
while i < num:
if num % i == 0:
isDivisible = True
print("{} is divisible by {}".format(num,i))
break
i +=1
if isDivisible:
print("{} is NOT a prime number".format(num))
else:
print("{} is a prime number".format(num))
-----------------------------------------------------------
===============================================================
https://github.com/bornfreesoul/PythonLessons
https://www.youtube.com/channel/UCe0rLJmSQXNoK2Mo2eMVuvg
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.