Sunday, July 19, 2020

Python Class 175 (Even Numbers) - Kapil

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.

Blockchain: 101 (By - Kapil Sharma)

 https://testing-mines.blogspot.com/2021/10/blockchain-101-by-kapil-sharma.html Blockchain through the following attributes: Distributed:  T...