Python

Read & Print Prime Numbers In A Range Using Sieve Of Eratosthenes In Python

In this Basic Python Program, we will have a look at how to “print prime numbers in a range” with the help of Python Programming Language. Python Program To Print Prime Numbers In a Range n=int(input(“Enter upper limit of range: “)) sieve=set(range(2,n+1)) while sieve:     prime=min(sieve)     print(prime,end=”\t”)     sieve-=set(range(prime,n+1,prime))  print() In the above Python Program, we printed …

Read & Print Prime Numbers In A Range Using Sieve Of Eratosthenes In Python Read More »

Print All Integers That Aren’t Divisible By Either 2 Or 3 And Lie Between 1 And 50 In Python.

In this Basic Python Program, we will have a look at how to “print all integers that are not divisible by either 2 or 3” with the help of Python Programming Language. Python Program  To Print All Integers That Aren’t Divisible By Either 2 Or 3 And Lie Between 1 And 50   for i in …

Print All Integers That Aren’t Divisible By Either 2 Or 3 And Lie Between 1 And 50 In Python. Read More »

Print An Identity Matrix In Python

In this Basic Python Program, we will have a look at how to “print an Identity Matrix” with the help of Python Programming Language. Python Program To Print An Identity Matrix n=int(input(“Enter a number: “)) for i in range(0,n):     for j in range(0,n):         if(i==j):             print(“1″,sep=” “,end=” “)         else:             print(“0″,sep=” “,end=” “)     print() In the above …

Print An Identity Matrix In Python Read More »

Read A Number N And Print The Natural Numbers Summation Pattern In Python

In this Basic Python Program, we will have a look at how to “print the natural numbers summation pattern” with the help of Python Programming Language. Python Program To Read A Number N And Print The Natural Numbers Summation Pattern n=int(input(“Enter a number: “)) for j in range(1,n+1):     a=[]     for i in range(1,j+1):         print(i,sep=” “,end=” …

Read A Number N And Print The Natural Numbers Summation Pattern In Python Read More »

Read A Number N And Print The Series “1+2+…..+N= In Python

In this Basic Python Program, we will have a look at how to print the series 1+2+…..+N with the help of Python Programming Language. Python Program To Read a Number N and Print the Series 1+2+…+N  n=int(input(“Enter a number: “)) a=[] for i in range(1,n+1):     print(i,sep=” “,end=” “)     if(i<n):         print(“+”,sep=” “,end=” “)     a.append(i) print(“=”,sum(a)) print() …

Read A Number N And Print The Series “1+2+…..+N= In Python Read More »

Find the Smallest Divisor of an Integer in python

In this Basic Python Program, we will have a look at how to “Find the smallest divisor of an integer” with the help of Python Programming Language. Python Program To Find the Smallest Divisor of an integer n=int(input(“Enter an integer:”)) a=[] for i in range(2,n+1):     if(n%i==0):         a.append(i) a.sort() print(“Smallest divisor is:”,a[0]) In the above program, …

Find the Smallest Divisor of an Integer in python Read More »