Palindrome string
Class 11 Computer Science · Strings · Write the program · 4 marks
- Read the question and the sample tests.
- Write your Python program in the editor.
- Run Code to check it on the sample tests (no marks).
- Submit Answer for evaluation: hidden tests award the marks. Nothing is saved here.
Question
Write a program that reads a word and checks whether it is a palindrome, ignoring the difference between capital and small letters. For example "Madam" is a palindrome. Input: one line, a word. Output: exactly one line, either Palindrome or Not a palindrome
Sample tests
Use these examples to check your program. Your output must match the Expected Output exactly.
Madam
Palindrome
Python
Not a palindrome
Evaluation: when you submit, your program is also checked against 4 hidden tests that you cannot see. Marks come from the hidden tests only. Each test you pass earns its marks, so a partly correct program gets part marks. Prompt text passed to input() is not counted as output.
Your program
Write the whole program, including any import lines it needs. The editor starts empty; Reset Code clears it. Submit your answer before leaving the page.
Approach (open it after you have tried)
Convert the word to lowercase first so that "Madam" compares equal to "madaM" reversed. The slice w[::-1] uses a step of -1 to give the string reversed. A palindrome equals its reverse.
Practise all 65 Class 11 programs
This page has 10 programs. The complete Class 11 Python Lab has 65, and keeps your best score and chapter progress.
Other Class 11 programs: Simple interest · Grade from marks · Prime or composite · Alternating series · Right triangle of stars · Linear search in a list · Search in a tuple · Character frequency with a dictionary · Circle with the math module