This post will have 5 simple python programs. They are

- print using python
- check palindrome
- Armstrong number
- Find the greater number
- print prime numbers in a range

All these programs are provided along with a code snippet in this part. More programs on the next part.

**1. Print using python**

This simple code snippet shows how to print using python.

The simplest way to produce output is using the print() function where you can pass zero or more expressions separated by commas. This function converts the expressions you pass into a string before writing to the screen.

**2. Check palindrome**

Given a string, write a python function to check if it is palindrome or not. A string is said to be palindrome if reverse of the string is same as string. For example, “radar” is palindrome, but “radix” is not palindrome.

A positive integer of n digits is called an Armstrong number of order n (order is number of digits) if.

abcd... = pow(a,n) + pow(b,n) + pow(c,n) + pow(d,n) + ....

**4. Greatest of two numbers**

**5. Prime numbers in a range**

A positive integer greater than 1 which has no other factors except 1 and the number itself is called a prime number. 2, 3, 5, 7 etc. are prime numbers as they do not have any other factors. But 6 is not prime (it is composite) since, 2 x 3 = 6.

More programs in the next part.

Wow! What an excellent article!!! It is very helpful for me. I’ve learnt a lot of things from this post, thank you. If anyone wants to learn more you can also visit https://sisayed360.blogspot.com/

ReplyDelete