Skip to content

Instantly share code, notes, and snippets.

@ngbala6
Created October 1, 2021 09:20
Show Gist options
  • Select an option

  • Save ngbala6/61c1c68793b4d5d877dadb36b0be03e9 to your computer and use it in GitHub Desktop.

Select an option

Save ngbala6/61c1c68793b4d5d877dadb36b0be03e9 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"collapsed": true,
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"### Palindrome Sample"
]
},
{
"cell_type": "code",
"execution_count": 16,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Palindrome\n"
]
}
],
"source": [
"s = \"savas\"\n",
"\n",
"if s == s[::-1]:\n",
" print(\"Palindrome\")\n",
"else:\n",
" print(\"Not a Palindrome\")"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 17,
"outputs": [
{
"data": {
"text/plain": "[1, 2]"
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Example\n",
"\n",
"s = [0,1,2,3,4,5]\n",
"\n",
"# Returns the index of 1 to 3\n",
"s[1:3]"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 18,
"outputs": [
{
"data": {
"text/plain": "[0, 2, 4]"
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Gives the output array that by 2,4,6 of an array.\n",
"s[::2]"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"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.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment