Python program to check whether the given number is prime or not.

Pythonlogo

#To check whether the input number is prime or not

try: #It runs if the input is an integer
a=int(input('Enter a natural number greater than 1'))
if a>1:
for b in range(2,a):
if(a%b)==0:
print(a,'is not a prime number')
break
else:
print(a, 'is a prime number')
else:
print('Please enter a valid number')
except ValueError: #If the user is naughty and enters other than an integer
print('Please enter a valid number')

Adhere

Discussions

Dctf

Rabin Kalikote • Computer

To convert temperature in Celsius to Fahrenheit scale.

// To convert temperature in Celcius to Fahrenheit scale. #include <stdio.h>#include <conio.h>int main(){    float dc, fer;    printf("...

0 Questions 2 Likes 147 Views

Note author's details.