How to check if a number is prime in Python

💻 I wrote a simple Python program to check whether a number is prime or not. The program asks for input and outputs True if the number is prime, otherwise False. Here's the code 👇 num = int(input("Enter a number: ")) if num > 1:   for i in range(2, int(num ** 0.5) + 1):     if num % i == 0:       print(False)       break   else:     print(True) else:   print(False) https://lnkd.in/gaXhBG3Y #Python #Coding #Learning #Programming #Tech

  • diagram

To view or add a comment, sign in

Explore content categories