Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Floryndas/d28455791d8e3e1210aec3e1e312f499 to your computer and use it in GitHub Desktop.
Save Floryndas/d28455791d8e3e1210aec3e1e312f499 to your computer and use it in GitHub Desktop.
Created on Cognitive Class Labs
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 align=center>Slicing </h3>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Use slicing to find the first four elements of the following string:"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-1"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Letters=\"ABCDEFGHIJK\"\n",
"Letters[0:4] \n",
"Letters[::2]\n",
"Modif_Letters = Letters.replace(\"ABCD\", \"QWERT\")\n",
"Modif_Letters\n",
"Letters.find(\"GH\")\n",
"Modif_Letters.find(\"ABC\")\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 align=center>Strides are Good </h3> "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Use a stride value of two on the following string :"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Good'"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Good=\"GsoAo+d\"\n",
"Good[::2] "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 align=center>uppercase to UPPERCASE </h3> "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Convert the following string to uppercase using the method <code>upper()</code>"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [
{
"data": {
"text/plain": [
"'UPPERCASE'"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\"uppercase\".upper()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n",
"<small>Copyright &copy; 2018 IBM Cognitive Class. This notebook and its source code are released under the terms of the [MIT License](https://cognitiveclass.ai/mit-license/).</small>"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python",
"language": "python",
"name": "conda-env-python-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment