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 timothymush7/8a39f980c290b6b09f68355e1f26882b to your computer and use it in GitHub Desktop.
Save timothymush7/8a39f980c290b6b09f68355e1f26882b 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>Comparison operations</h3> "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Find the value of <code>i</code> that produces a <code>True</code> "
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"i=105\n",
"i>100"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 align=center>Branching </h3> "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Find the value of <code>x</code> that prints the statement: <code>\"this is a\"</code>"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"this is a\n"
]
}
],
"source": [
"x='a'\n",
"if(x=='a'):\n",
" print(\"this is a\")\n",
"else:\n",
" print(\"this is not a\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 align=center>Logic Operators</h3> "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"find the value of <code>y</code> that produces a <code>True</code> statement "
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"y=7\n",
"x=1\n",
"x>0 and y<10"
]
},
{
"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