Created
September 4, 2019 15:00
-
-
Save rezapci/05fa463fb6f48606a35943132819cbb5 to your computer and use it in GitHub Desktop.
Untitled2.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2019-09-04T14:50:47.623399Z", | |
"start_time": "2019-09-04T14:50:47.617416Z" | |
}, | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "# Reference to Flowcharts:\n# https://drive.google.com/file/d/1MxReXi2rVMhkFsbYynmA2gXycnVpdrwP/view?usp=sharing\n\n# Perform logical bitwise operations \"AND\", \"OR\", etc. on the numbers 5 and 6.\n# Perform a bitwise shift over the number 5 to the right and left by two characters.\n# Explain the result.\n\na = 5\nb = 6\n\nprint(\"{} & {} = {} ({})\".format(a, b, a & b, bin(a & b)))\n\nprint(\"{} | {} = {} ({})\".format(a, b, a | b, bin(a | b)))\n\nprint ( \"The bitwise shift of the number {} to the right by two digits: {} ( {} ) \" .format (a, a >> 2 , bin (a >> 2 )))\n\nprint ( \" Bitwise shift of the number {} to the left by two characters: {} ( {} ) \" .format (a, a << 2 , bin (a << 2 )))", | |
"execution_count": 2, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": "5 & 6 = 4 (0b100)\n5 | 6 = 7 (0b111)\nThe bitwise shift of the number 5 to the right by two digits: 1 ( 0b1 ) \n Bitwise shift of the number 5 to the left by two characters: 20 ( 0b10100 ) \n" | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "", | |
"execution_count": null, | |
"outputs": [] | |
} | |
], | |
"metadata": { | |
"gist": { | |
"id": "", | |
"data": { | |
"description": "Untitled2.ipynb", | |
"public": true | |
} | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3", | |
"language": "python" | |
}, | |
"language_info": { | |
"name": "python", | |
"version": "3.7.3", | |
"mimetype": "text/x-python", | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"pygments_lexer": "ipython3", | |
"nbconvert_exporter": "python", | |
"file_extension": ".py" | |
}, | |
"nbTranslate": { | |
"hotkey": "alt-t", | |
"sourceLang": "en", | |
"targetLang": "fr", | |
"displayLangs": [ | |
"*" | |
], | |
"langInMainMenu": true, | |
"useGoogleTranslate": true | |
}, | |
"toc": { | |
"nav_menu": {}, | |
"number_sections": true, | |
"sideBar": true, | |
"skip_h1_title": false, | |
"base_numbering": 1, | |
"title_cell": "Table of Contents", | |
"title_sidebar": "Contents", | |
"toc_cell": false, | |
"toc_position": {}, | |
"toc_section_display": true, | |
"toc_window_display": false | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment