# Code in Python Programming Language, Palindrome Numbers

The given assignment has a series of sub-questions. The answer has to be written which will be the lines of code in Python Programming Language.

1. In this exercise, a program has to be written to find the factors of a given number. Further to this, it has to be found out whether the factor is odd or even. The examiner is advocating use of Loop with if-else statements.
1. In this part, a code has to be written which accepts input as the sequence of words. These words would be printed as the output after the words are sorted out and arranged alphabetically.
1. This sub-question demands writing of a code that gives as output all the numbers between 1000 and 3000 (both inclusive) with a condition. The condition is, all the digits of the number should be even numbers. The output should be a comma separated sequence of numbers in a single line.
1. In this part, the examiner is asking students to write a code that accepts a sentence string as the input. The output would be an ordered set that gives total number of letters and numeric digits in the input separately.
1. Finally, students have to write a code which gives the result whether the number entered as input; is a palindrome number or not.

SOLUTION : –

{

“cells”: [

{

“cell_type”: “code”,

“execution_count”: 9,

“outputs”: [

{

“name”: “stdout”,

“output_type”: “stream”,

“text”: [

“Enter a number to find factors – 50\n”,

“1 is an odd factor\n”,

“2 is an even factor\n”,

“5 is an odd factor\n”,

“10 is an even factor\n”,

“25 is an odd factor\n”,

“50 is an even factor\n”

]

}

],

“source”: [

“x = input(\”Enter a number to find factors – \”)\n”,

“for i in range(x):\n”,

”    if x%(i+1) == 0:\n”,

”        if (i+1)%2 == 0:\n”,

”            print str(i+1)+’ is an even factor’\n”,

”        else:\n”,

”            print str(i+1)+’ is an odd factor'”

]

},

{

“cell_type”: “code”,

“execution_count”: 35,

“outputs”: [

{

“name”: “stdout”,

“output_type”: “stream”,

“text”: [

“Enter a string – afsdff\n”,

“[‘a’, ‘d’, ‘f’, ‘f’, ‘f’, ‘s’]\n”

]

}

],

“source”: [

“x = raw_input(‘Enter a string – ‘)\n”,

“x = list(x)\n”,

“x.sort()\n”,

“print x”

]

},

{

“cell_type”: “code”,

“execution_count”: 33,

“outputs”: [

{

“name”: “stdout”,

“output_type”: “stream”,

“text”: [

“2000, 2002, 2004, 2006, 2008, 2020, 2022, 2024, 2026, 2028, 2040, 2042, 2044, 2046, 2048, 2060, 2062, 2064, 2066, 2068, 2080, 2082, 2084, 2086, 2088, 2200, 2202, 2204, 2206, 2208, 2220, 2222, 2224, 2226, 2228, 2240, 2242, 2244, 2246, 2248, 2260, 2262, 2264, 2266, 2268, 2280, 2282, 2284, 2286, 2288, 2400, 2402, 2404, 2406, 2408, 2420, 2422, 2424, 2426, 2428, 2440, 2442, 2444, 2446, 2448, 2460, 2462, 2464, 2466, 2468, 2480, 2482, 2484, 2486, 2488, 2600, 2602, 2604, 2606, 2608, 2620, 2622, 2624, 2626, 2628, 2640, 2642, 2644, 2646, 2648, 2660, 2662, 2664, 2666, 2668, 2680, 2682, 2684, 2686, 2688, 2800, 2802, 2804, 2806, 2808, 2820, 2822, 2824, 2826, 2828, 2840, 2842, 2844, 2846, 2848, 2860, 2862, 2864, 2866, 2868, 2880, 2882, 2884, 2886, 2888,\n”

]

}

],

“source”: [

“for i in range(1000, 3001):\n”,

”    if ((i%10)%2==0 and ((i%100)/10)%2==0 and ((i%1000)/100)%2==0 and ((i%10000)/1000)%2==0):\n”,

”        print str(i)+’,’,”

]

},

{

“cell_type”: “code”,

“execution_count”: 40,

“outputs”: [

{

“name”: “stdout”,

“output_type”: “stream”,

“text”: [

“Enter a string – python0325\n”,

“LETTERS: 6 DIGITS: 4\n”

]

}

],

“source”: [

“x = raw_input(‘Enter a string – ‘)\n”,

“\n”,

“letters = 0\n”,

“digits = 0\n”,

“\n”,

“for i in x:\n”,

”    if i.isalpha():\n”,

”        letters = letters+1\n”,

”    elif i.isdigit():\n”,

”        digits = digits+1\n”,

”    else:\n”,

”        pass\n”,

“\n”,

“print ‘LETTERS: ‘+str(letters)+’ DIGITS: ‘+str(digits)”

]

},

{

“cell_type”: “code”,

“execution_count”: 56,

“outputs”: [

{

“name”: “stdout”,

“output_type”: “stream”,

“text”: [

“Enter a Number: 12345\n”,

“Not a palindrome number\n”

]

}

],

“source”: [

“a = raw_input(\”Enter a Number: \”)\n”,

“\n”,

“if a==a[::-1]:\n”,

”    print(‘Palindrome number’)\n”,

“else:\n”,

”    print(‘Not a palindrome number’)\n”

]

}

],

“kernelspec”: {

“display_name”: “Python 2”,

“language”: “python”,

“name”: “python2”

},

“language_info”: {

“codemirror_mode”: {

“name”: “ipython”,

“version”: 2

},

“file_extension”: “.py”,

“mimetype”: “text/x-python”,

“name”: “python”,

“nbconvert_exporter”: “python”,

“pygments_lexer”: “ipython2”,

“version”: “2.7.16”

}

},

“nbformat”: 4,

“nbformat_minor”: 2

}