Skip to main content

Featured

Write a Python Program to find palindrome of a given string

If you reverse the word then you get the same word that word is palindrome. def   palindrome ( str ):     pointer =  str       rev_str =  reversed (pointer)       if   list (pointer) ==  list (rev_str):         print ( "It is palindrome" )       else :         print ( "It is not palindrome" )  palindrome( 'level' ) palindrome( 'madam' ) palindrome( 'life' ) palindrome( 'refer' ) Output:  It is palindrome It is palindrome It is not palindrome It is palindrome

Creating a python program

 To create a python program:

           Lets start with a simple program. It is traditional in programming to start with "hello world" program

Open your default python editor that is your IDLE

Create a new file type

Print("hello world")

Save it as sample.py

Now click on run module or f5

Output: hello world

This how you create a program in python

Variable and Datatype:

             Variable is nothing but a alphabet which holds the data . There are different types of data type like int, float, string, Boolean, list, tuples, dictionary

1. Int- int is integer nothing but a whole number

2. Float- it is a floating point numbers

3. String-nothing but a text, string is always  enclosed by quotation marks

4. List, tubles and dictionary are called sequence we will see that in future post

Creating variables:

         Creating variables in python is very simple, we just choose a name and assign a value

mynumber = 10

mytext = "hello"

Now we have defined our variable, we can start to use them. For example we could print the value

Print(mynumber)
Print(mytext)

Output: 10

                 Hello

To make it more clear

Value=10

Number= int(value)

Because sometimes int values that is numbers can be taken as string so we can use like it

In next post lets see about the operators in python


Comments

Popular Posts