diff --git a/.ipynb_checkpoints/int_assignment-checkpoint.ipynb b/.ipynb_checkpoints/int_assignment-checkpoint.ipynb new file mode 100644 index 0000000..d77a3dd --- /dev/null +++ b/.ipynb_checkpoints/int_assignment-checkpoint.ipynb @@ -0,0 +1,507 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "id": "8A5Jw5NR1iEI" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " 9788672\n" + ] + } + ], + "source": [ + "#Declare an int value and store it in a variable. \n", + "x = 3\n", + "\n", + "\n", + "#Check the type and print the id of the same.\n", + "print(type(x),id(x))" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "id": "0YU8LFTn1rAX" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "9788736 9788736\n", + "140369480359472 140369480359120\n" + ] + } + ], + "source": [ + "#Take one int value between 0 - 256.\n", + "#Assign it to two different variables.\n", + "#Check the id of both the variables. It should come same. Check why?\n", + "x,y = 5,5\n", + "print(id(x),id(y))\n", + "##It is because the number is already there in memory, \n", + "##the variable gets pointed to respective number\n", + "\n", + "#Take one int value either less than -5 or greater than 256.\n", + "#Assign it to two different variables.\n", + "#Check the id of both the variables. It should come different.Check why?\n", + "x = -6\n", + "y = -6\n", + "print(id(x),id(y))\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "id": "YzEIG0ZZ1tSK" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "9\n", + "-1\n", + "20\n", + "0.8\n", + "4\n", + "0.8\n", + "625\n" + ] + } + ], + "source": [ + "#Arithmatic Operations on integers\n", + "#Take two different intger values.\n", + "#Store them in two different variables.\n", + "x,y = 4,5\n", + "#Do below operations on them:-\n", + " #Find sum of both numbers\n", + "print(x+y)\n", + " #Find differce between them\n", + "print(x-y) \n", + " #Find the product of both numbers.\n", + "print(x*y)\n", + " \n", + " #Find value after dividing first num with second number\n", + "print(x/y)\n", + "\n", + " #Find the remainder after dividing first number with second number\n", + "print(x%y)\n", + " \n", + " #Find the quotient after dividing first number with second number\n", + "print(x/y)\n", + "\n", + " \n", + " #Find the result of first num to the power of second number.\n", + "print(y**x)\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "id": "GGM7CdzA1wGn" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Comparison Operators on integers\n", + "#Take two different intger values\n", + "x,y = 5,6\n", + "#Store them in two different variables.\n", + "#Do below operations on them:-\n", + " #Compare se two numbers with below operator:-\n", + " #Greater than, '>'\n", + "x>y\n", + "x=y\n", + "x<=y\n", + " #Smaller than, '<'\n", + " #Greater than or equal to, '>='\n", + " #Less than or equal to, '<='\n", + "#Observe their output(return type should be boolean)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "id": "9x904sUE1y9t" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Equality Operator\n", + "#Take two different intger values.\n", + "#Store them in two different variables.\n", + "#Equuate them using equality operator (==, !=)\n", + "#Observe the output(return type should be boolean)\n", + "x,y == 5,5\n", + "x == y" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "v9-sAvlZZdoi" + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "yes\n" + ] + } + ], + "source": [ + "if(-9):\n", + " print(\"yes\")\n", + "else:\n", + " print(\"no\")" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "id": "JmQFHUwc11S-" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10\n", + "20\n", + "0\n", + "0\n", + "0\n", + "10\n", + "20\n", + "20\n", + "0\n", + "False\n", + "True\n" + ] + } + ], + "source": [ + "#Logical operators\n", + "#Observe the output of below code\n", + "#Cross check the output manually\n", + "# t and t/f\n", + "print(10 and 20) #----------------------------------------->Output is 20\n", + "print(0 and 20) #----------------------------------------->Output is 0\n", + "print(20 and 0) #----------------------------------------->Output is 0\n", + "print(0 and 0) #----------------------------------------->Output is 0\n", + "\n", + "print(10 or 20) #----------------------------------------->Output is 10\n", + "print(0 or 20) #----------------------------------------->Output is 20\n", + "print(20 or 0) #----------------------------------------->Output is 20\n", + "print(0 or 0) #----------------------------------------->Output is 0\n", + "\n", + "print(not 10) #----------------------------------------->Output is False\n", + "print(not 0) #----------------------------------------->Output is True" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "id": "-0tvoulX14Hi" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0\n", + "30\n", + "30\n", + "-13\n", + "0\n", + "50706024009129176059868128215040\n" + ] + } + ], + "source": [ + "#Bitwise Operators\n", + "#Do below operations on the values provided below:-\n", + "\n", + " #Bitwise and(&) -----------------------------------------> 10, 20 -------> Output is 0\n", + "print(10 & 20)\n", + "print(10 | 20)\n", + "print(10 ^ 20)\n", + "print(~12)\n", + "print(12 >> 10)\n", + "print(10 << 102)\n", + " #Bitwise or(|) -----------------------------------------> 10, 20 -------> Output is 30\n", + " #Bitwise(^) -----------------------------------------> 10, 20 -------> Output is 30\n", + " #Bitwise negation(~) ------------------------------------> 10 -------> Output is -11\n", + " #Bitwise left shift ------------------------------------> 10,2 -------> Output is 40\n", + " #Bitwise right shift ------------------------------------> 10,2 -------> Output is 2\n", + "#Cross check the output manually" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "-13" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "~12\n", + "# 12-> 00001100\n", + "# ~12->11110011\n", + "# 13-> 00001101\n", + "# 11110010 + 1 = 11110011-> 243" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "id": "YCcx-Qx016hg" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "False\n", + "False\n", + "True\n" + ] + } + ], + "source": [ + "#What is the output of expression inside print statement. Cross check before running the program.\n", + "a = 10\n", + "b = 10\n", + "print(a is b) #True or False?\n", + "print(a is not b) #True or False?\n", + "\n", + "a = 1000\n", + "b = 1000\n", + "print(a is b) #True or False?\n", + "print(a is not b) #True or False?" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "id": "Un2To3XN1_Il" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "20\n" + ] + } + ], + "source": [ + "#What is the output of expression inside print statement. Cross check before running the program.\n", + "print(10+(10*32)//2**5&20+(~(-10))<<2)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "id": "kGRb5RMd1_1I" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "True\n", + "True\n", + "True\n", + "False\n", + "True\n" + ] + } + ], + "source": [ + "#Membership operation\n", + "#in, not in are two membership operators and it returns boolean value\n", + "\n", + "print('2' in 'Python2.7.8')\n", + "print(10 in [10,10.20,10+20j,'Python'])\n", + "print(10 in (10,10.20,10+20j,'Python'))\n", + "print(2 in {1,2,3})\n", + "print(100 in {1:100, 2:200, 3:300})\n", + "print(10 in range(20))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "Es7iSvL92B9W" + }, + "outputs": [], + "source": [ + "#An integer can be represented in binary, octal or hexadecimal form.\n", + "#Declare one binary, one octal and one hexadecimal value and store them in three different variables.\n", + "#Convert 9876 to its binary, octal and hexadecimal equivalent and print their corresponding value." + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "id": "Hm0r03lH2E0i" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "80\n", + "3870\n", + "64222\n", + "0b1010000\n", + "0o7436\n", + "0xfade\n", + "0b1010000\n", + "0b1111101011011110\n", + "0o175336\n", + "0o7436\n", + "0x50\n", + "0xfade\n" + ] + } + ], + "source": [ + "#What will be the output of following:-\n", + "a = 0b1010000\n", + "print(a)\n", + "\n", + "b = 0o7436\n", + "print(b)\n", + "\n", + "c = 0xfade\n", + "print(c)\n", + "\n", + "print(bin(80))\n", + "\n", + "print(oct(3870))\n", + "\n", + "print(hex(64222))\n", + "\n", + "print(bin(0b1010000))\n", + "\n", + "print(bin(0xfade))\n", + "\n", + "print(oct(0xfade))\n", + "\n", + "print(oct(0o7436))\n", + "\n", + "print(hex(0b1010000))\n", + "\n", + "print(hex(0xfade))" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [], + "source": [ + "# suppression and regression.\n", + "\n", + "# You catch yourself doing it, That is fine for now. \n", + "# That sight that you know this, has already poked a hole inside it." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "colab": { + "name": "int_assignment.ipynb", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "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.8.10" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/Vatsal Mehta/int_assignment.ipynb b/Vatsal Mehta/int_assignment.ipynb new file mode 100644 index 0000000..d77a3dd --- /dev/null +++ b/Vatsal Mehta/int_assignment.ipynb @@ -0,0 +1,507 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "id": "8A5Jw5NR1iEI" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " 9788672\n" + ] + } + ], + "source": [ + "#Declare an int value and store it in a variable. \n", + "x = 3\n", + "\n", + "\n", + "#Check the type and print the id of the same.\n", + "print(type(x),id(x))" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "id": "0YU8LFTn1rAX" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "9788736 9788736\n", + "140369480359472 140369480359120\n" + ] + } + ], + "source": [ + "#Take one int value between 0 - 256.\n", + "#Assign it to two different variables.\n", + "#Check the id of both the variables. It should come same. Check why?\n", + "x,y = 5,5\n", + "print(id(x),id(y))\n", + "##It is because the number is already there in memory, \n", + "##the variable gets pointed to respective number\n", + "\n", + "#Take one int value either less than -5 or greater than 256.\n", + "#Assign it to two different variables.\n", + "#Check the id of both the variables. It should come different.Check why?\n", + "x = -6\n", + "y = -6\n", + "print(id(x),id(y))\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "id": "YzEIG0ZZ1tSK" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "9\n", + "-1\n", + "20\n", + "0.8\n", + "4\n", + "0.8\n", + "625\n" + ] + } + ], + "source": [ + "#Arithmatic Operations on integers\n", + "#Take two different intger values.\n", + "#Store them in two different variables.\n", + "x,y = 4,5\n", + "#Do below operations on them:-\n", + " #Find sum of both numbers\n", + "print(x+y)\n", + " #Find differce between them\n", + "print(x-y) \n", + " #Find the product of both numbers.\n", + "print(x*y)\n", + " \n", + " #Find value after dividing first num with second number\n", + "print(x/y)\n", + "\n", + " #Find the remainder after dividing first number with second number\n", + "print(x%y)\n", + " \n", + " #Find the quotient after dividing first number with second number\n", + "print(x/y)\n", + "\n", + " \n", + " #Find the result of first num to the power of second number.\n", + "print(y**x)\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "id": "GGM7CdzA1wGn" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Comparison Operators on integers\n", + "#Take two different intger values\n", + "x,y = 5,6\n", + "#Store them in two different variables.\n", + "#Do below operations on them:-\n", + " #Compare se two numbers with below operator:-\n", + " #Greater than, '>'\n", + "x>y\n", + "x=y\n", + "x<=y\n", + " #Smaller than, '<'\n", + " #Greater than or equal to, '>='\n", + " #Less than or equal to, '<='\n", + "#Observe their output(return type should be boolean)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "id": "9x904sUE1y9t" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Equality Operator\n", + "#Take two different intger values.\n", + "#Store them in two different variables.\n", + "#Equuate them using equality operator (==, !=)\n", + "#Observe the output(return type should be boolean)\n", + "x,y == 5,5\n", + "x == y" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "v9-sAvlZZdoi" + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "yes\n" + ] + } + ], + "source": [ + "if(-9):\n", + " print(\"yes\")\n", + "else:\n", + " print(\"no\")" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "id": "JmQFHUwc11S-" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10\n", + "20\n", + "0\n", + "0\n", + "0\n", + "10\n", + "20\n", + "20\n", + "0\n", + "False\n", + "True\n" + ] + } + ], + "source": [ + "#Logical operators\n", + "#Observe the output of below code\n", + "#Cross check the output manually\n", + "# t and t/f\n", + "print(10 and 20) #----------------------------------------->Output is 20\n", + "print(0 and 20) #----------------------------------------->Output is 0\n", + "print(20 and 0) #----------------------------------------->Output is 0\n", + "print(0 and 0) #----------------------------------------->Output is 0\n", + "\n", + "print(10 or 20) #----------------------------------------->Output is 10\n", + "print(0 or 20) #----------------------------------------->Output is 20\n", + "print(20 or 0) #----------------------------------------->Output is 20\n", + "print(0 or 0) #----------------------------------------->Output is 0\n", + "\n", + "print(not 10) #----------------------------------------->Output is False\n", + "print(not 0) #----------------------------------------->Output is True" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "id": "-0tvoulX14Hi" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0\n", + "30\n", + "30\n", + "-13\n", + "0\n", + "50706024009129176059868128215040\n" + ] + } + ], + "source": [ + "#Bitwise Operators\n", + "#Do below operations on the values provided below:-\n", + "\n", + " #Bitwise and(&) -----------------------------------------> 10, 20 -------> Output is 0\n", + "print(10 & 20)\n", + "print(10 | 20)\n", + "print(10 ^ 20)\n", + "print(~12)\n", + "print(12 >> 10)\n", + "print(10 << 102)\n", + " #Bitwise or(|) -----------------------------------------> 10, 20 -------> Output is 30\n", + " #Bitwise(^) -----------------------------------------> 10, 20 -------> Output is 30\n", + " #Bitwise negation(~) ------------------------------------> 10 -------> Output is -11\n", + " #Bitwise left shift ------------------------------------> 10,2 -------> Output is 40\n", + " #Bitwise right shift ------------------------------------> 10,2 -------> Output is 2\n", + "#Cross check the output manually" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "-13" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "~12\n", + "# 12-> 00001100\n", + "# ~12->11110011\n", + "# 13-> 00001101\n", + "# 11110010 + 1 = 11110011-> 243" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "id": "YCcx-Qx016hg" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "False\n", + "False\n", + "True\n" + ] + } + ], + "source": [ + "#What is the output of expression inside print statement. Cross check before running the program.\n", + "a = 10\n", + "b = 10\n", + "print(a is b) #True or False?\n", + "print(a is not b) #True or False?\n", + "\n", + "a = 1000\n", + "b = 1000\n", + "print(a is b) #True or False?\n", + "print(a is not b) #True or False?" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "id": "Un2To3XN1_Il" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "20\n" + ] + } + ], + "source": [ + "#What is the output of expression inside print statement. Cross check before running the program.\n", + "print(10+(10*32)//2**5&20+(~(-10))<<2)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "id": "kGRb5RMd1_1I" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "True\n", + "True\n", + "True\n", + "False\n", + "True\n" + ] + } + ], + "source": [ + "#Membership operation\n", + "#in, not in are two membership operators and it returns boolean value\n", + "\n", + "print('2' in 'Python2.7.8')\n", + "print(10 in [10,10.20,10+20j,'Python'])\n", + "print(10 in (10,10.20,10+20j,'Python'))\n", + "print(2 in {1,2,3})\n", + "print(100 in {1:100, 2:200, 3:300})\n", + "print(10 in range(20))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "Es7iSvL92B9W" + }, + "outputs": [], + "source": [ + "#An integer can be represented in binary, octal or hexadecimal form.\n", + "#Declare one binary, one octal and one hexadecimal value and store them in three different variables.\n", + "#Convert 9876 to its binary, octal and hexadecimal equivalent and print their corresponding value." + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "id": "Hm0r03lH2E0i" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "80\n", + "3870\n", + "64222\n", + "0b1010000\n", + "0o7436\n", + "0xfade\n", + "0b1010000\n", + "0b1111101011011110\n", + "0o175336\n", + "0o7436\n", + "0x50\n", + "0xfade\n" + ] + } + ], + "source": [ + "#What will be the output of following:-\n", + "a = 0b1010000\n", + "print(a)\n", + "\n", + "b = 0o7436\n", + "print(b)\n", + "\n", + "c = 0xfade\n", + "print(c)\n", + "\n", + "print(bin(80))\n", + "\n", + "print(oct(3870))\n", + "\n", + "print(hex(64222))\n", + "\n", + "print(bin(0b1010000))\n", + "\n", + "print(bin(0xfade))\n", + "\n", + "print(oct(0xfade))\n", + "\n", + "print(oct(0o7436))\n", + "\n", + "print(hex(0b1010000))\n", + "\n", + "print(hex(0xfade))" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [], + "source": [ + "# suppression and regression.\n", + "\n", + "# You catch yourself doing it, That is fine for now. \n", + "# That sight that you know this, has already poked a hole inside it." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "colab": { + "name": "int_assignment.ipynb", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "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.8.10" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/int_assignment.ipynb b/int_assignment.ipynb index 6090fff..d77a3dd 100644 --- a/int_assignment.ipynb +++ b/int_assignment.ipynb @@ -1,267 +1,507 @@ { - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "colab": { - "name": "int_assignment.ipynb", - "provenance": [] - }, - "kernelspec": { - "name": "python3", - "display_name": "Python 3" + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "id": "8A5Jw5NR1iEI" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " 9788672\n" + ] } + ], + "source": [ + "#Declare an int value and store it in a variable. \n", + "x = 3\n", + "\n", + "\n", + "#Check the type and print the id of the same.\n", + "print(type(x),id(x))" + ] }, - "cells": [ - { - "cell_type": "code", - "metadata": { - "id": "8A5Jw5NR1iEI" - }, - "source": [ - "#Declare an int value and store it in a variable. \n", - "\n", - "\n", - "\n", - "#Check the type and print the id of the same.\n", - "\n" - ], - "execution_count": null, - "outputs": [] - }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "id": "0YU8LFTn1rAX" + }, + "outputs": [ { - "cell_type": "code", - "metadata": { - "id": "0YU8LFTn1rAX" - }, - "source": [ - "#Take one int value between 0 - 256.\n", - "#Assign it to two different variables.\n", - "#Check the id of both the variables. It should come same. Check why?\n", - "\n", - "\n", - "\n", - "\n", - "#Take one int value either less than -5 or greater than 256.\n", - "#Assign it to two different variables.\n", - "#Check the id of both the variables. It should come different.Check why?\n", - "\n", - "\n" - ], - "execution_count": null, - "outputs": [] - }, + "name": "stdout", + "output_type": "stream", + "text": [ + "9788736 9788736\n", + "140369480359472 140369480359120\n" + ] + } + ], + "source": [ + "#Take one int value between 0 - 256.\n", + "#Assign it to two different variables.\n", + "#Check the id of both the variables. It should come same. Check why?\n", + "x,y = 5,5\n", + "print(id(x),id(y))\n", + "##It is because the number is already there in memory, \n", + "##the variable gets pointed to respective number\n", + "\n", + "#Take one int value either less than -5 or greater than 256.\n", + "#Assign it to two different variables.\n", + "#Check the id of both the variables. It should come different.Check why?\n", + "x = -6\n", + "y = -6\n", + "print(id(x),id(y))\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "id": "YzEIG0ZZ1tSK" + }, + "outputs": [ { - "cell_type": "code", - "metadata": { - "id": "YzEIG0ZZ1tSK" - }, - "source": [ - "#Arithmatic Operations on integers\n", - "#Take two different intger values.\n", - "#Store them in two different variables.\n", - "#Do below operations on them:-\n", - " #Find sum of both numbers\n", - " #Find differce between them\n", - " #Find the product of both numbers.\n", - " #Find value after dividing first num with second number\n", - " #Find the remainder after dividing first number with second number\n", - " #Find the quotient after dividing first number with second number\n", - " #Find the result of first num to the power of second number." - ], - "execution_count": null, - "outputs": [] - }, + "name": "stdout", + "output_type": "stream", + "text": [ + "9\n", + "-1\n", + "20\n", + "0.8\n", + "4\n", + "0.8\n", + "625\n" + ] + } + ], + "source": [ + "#Arithmatic Operations on integers\n", + "#Take two different intger values.\n", + "#Store them in two different variables.\n", + "x,y = 4,5\n", + "#Do below operations on them:-\n", + " #Find sum of both numbers\n", + "print(x+y)\n", + " #Find differce between them\n", + "print(x-y) \n", + " #Find the product of both numbers.\n", + "print(x*y)\n", + " \n", + " #Find value after dividing first num with second number\n", + "print(x/y)\n", + "\n", + " #Find the remainder after dividing first number with second number\n", + "print(x%y)\n", + " \n", + " #Find the quotient after dividing first number with second number\n", + "print(x/y)\n", + "\n", + " \n", + " #Find the result of first num to the power of second number.\n", + "print(y**x)\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "id": "GGM7CdzA1wGn" + }, + "outputs": [ { - "cell_type": "code", - "metadata": { - "id": "GGM7CdzA1wGn" - }, - "source": [ - "#Comparison Operators on integers\n", - "#Take two different intger values.\n", - "#Store them in two different variables.\n", - "#Do below operations on them:-\n", - " #Compare se two numbers with below operator:-\n", - " #Greater than, '>'\n", - " #Smaller than, '<'\n", - " #Greater than or equal to, '>='\n", - " #Less than or equal to, '<='\n", - "#Observe their output(return type should be boolean)" - ], - "execution_count": null, - "outputs": [] - }, + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Comparison Operators on integers\n", + "#Take two different intger values\n", + "x,y = 5,6\n", + "#Store them in two different variables.\n", + "#Do below operations on them:-\n", + " #Compare se two numbers with below operator:-\n", + " #Greater than, '>'\n", + "x>y\n", + "x=y\n", + "x<=y\n", + " #Smaller than, '<'\n", + " #Greater than or equal to, '>='\n", + " #Less than or equal to, '<='\n", + "#Observe their output(return type should be boolean)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "id": "9x904sUE1y9t" + }, + "outputs": [ { - "cell_type": "code", - "metadata": { - "id": "9x904sUE1y9t" - }, - "source": [ - "#Equality Operator\n", - "#Take two different intger values.\n", - "#Store them in two different variables.\n", - "#Equuate them using equality operator (==, !=)\n", - "#Observe the output(return type should be boolean)" - ], - "execution_count": null, - "outputs": [] - }, + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Equality Operator\n", + "#Take two different intger values.\n", + "#Store them in two different variables.\n", + "#Equuate them using equality operator (==, !=)\n", + "#Observe the output(return type should be boolean)\n", + "x,y == 5,5\n", + "x == y" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "v9-sAvlZZdoi" + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ { - "cell_type": "code", - "metadata": { - "id": "v9-sAvlZZdoi" - }, - "source": [ - "" - ], - "execution_count": null, - "outputs": [] - }, + "name": "stdout", + "output_type": "stream", + "text": [ + "yes\n" + ] + } + ], + "source": [ + "if(-9):\n", + " print(\"yes\")\n", + "else:\n", + " print(\"no\")" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "id": "JmQFHUwc11S-" + }, + "outputs": [ { - "cell_type": "code", - "metadata": { - "id": "JmQFHUwc11S-" - }, - "source": [ - "#Logical operators\n", - "#Observe the output of below code\n", - "#Cross check the output manually\n", - "\n", - "print(10 and 20) #----------------------------------------->Output is 20\n", - "print(0 and 20) #----------------------------------------->Output is 0\n", - "print(20 and 0) #----------------------------------------->Output is 0\n", - "print(0 and 0) #----------------------------------------->Output is 0\n", - "\n", - "print(10 or 20) #----------------------------------------->Output is 10\n", - "print(0 or 20) #----------------------------------------->Output is 20\n", - "print(20 or 0) #----------------------------------------->Output is 20\n", - "print(0 or 0) #----------------------------------------->Output is 0\n", - "\n", - "print(not 10) #----------------------------------------->Output is False\n", - "print(not 0) #----------------------------------------->Output is True" - ], - "execution_count": null, - "outputs": [] - }, + "name": "stdout", + "output_type": "stream", + "text": [ + "10\n", + "20\n", + "0\n", + "0\n", + "0\n", + "10\n", + "20\n", + "20\n", + "0\n", + "False\n", + "True\n" + ] + } + ], + "source": [ + "#Logical operators\n", + "#Observe the output of below code\n", + "#Cross check the output manually\n", + "# t and t/f\n", + "print(10 and 20) #----------------------------------------->Output is 20\n", + "print(0 and 20) #----------------------------------------->Output is 0\n", + "print(20 and 0) #----------------------------------------->Output is 0\n", + "print(0 and 0) #----------------------------------------->Output is 0\n", + "\n", + "print(10 or 20) #----------------------------------------->Output is 10\n", + "print(0 or 20) #----------------------------------------->Output is 20\n", + "print(20 or 0) #----------------------------------------->Output is 20\n", + "print(0 or 0) #----------------------------------------->Output is 0\n", + "\n", + "print(not 10) #----------------------------------------->Output is False\n", + "print(not 0) #----------------------------------------->Output is True" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "id": "-0tvoulX14Hi" + }, + "outputs": [ { - "cell_type": "code", - "metadata": { - "id": "-0tvoulX14Hi" - }, - "source": [ - "#Bitwise Operators\n", - "#Do below operations on the values provided below:-\n", - " #Bitwise and(&) -----------------------------------------> 10, 20 -------> Output is 0\n", - " #Bitwise or(|) -----------------------------------------> 10, 20 -------> Output is 30\n", - " #Bitwise(^) -----------------------------------------> 10, 20 -------> Output is 30\n", - " #Bitwise negation(~) ------------------------------------> 10 -------> Output is -11\n", - " #Bitwise left shift ------------------------------------> 10,2 -------> Output is 40\n", - " #Bitwise right shift ------------------------------------> 10,2 -------> Output is 2\n", - "#Cross check the output manually" - ], - "execution_count": null, - "outputs": [] - }, + "name": "stdout", + "output_type": "stream", + "text": [ + "0\n", + "30\n", + "30\n", + "-13\n", + "0\n", + "50706024009129176059868128215040\n" + ] + } + ], + "source": [ + "#Bitwise Operators\n", + "#Do below operations on the values provided below:-\n", + "\n", + " #Bitwise and(&) -----------------------------------------> 10, 20 -------> Output is 0\n", + "print(10 & 20)\n", + "print(10 | 20)\n", + "print(10 ^ 20)\n", + "print(~12)\n", + "print(12 >> 10)\n", + "print(10 << 102)\n", + " #Bitwise or(|) -----------------------------------------> 10, 20 -------> Output is 30\n", + " #Bitwise(^) -----------------------------------------> 10, 20 -------> Output is 30\n", + " #Bitwise negation(~) ------------------------------------> 10 -------> Output is -11\n", + " #Bitwise left shift ------------------------------------> 10,2 -------> Output is 40\n", + " #Bitwise right shift ------------------------------------> 10,2 -------> Output is 2\n", + "#Cross check the output manually" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ { - "cell_type": "code", - "metadata": { - "id": "YCcx-Qx016hg" - }, - "source": [ - "#What is the output of expression inside print statement. Cross check before running the program.\n", - "a = 10\n", - "b = 10\n", - "print(a is b) #True or False?\n", - "print(a is not b) #True or False?\n", - "\n", - "a = 1000\n", - "b = 1000\n", - "print(a is b) #True or False?\n", - "print(a is not b) #True or False?" - ], - "execution_count": null, - "outputs": [] - }, + "data": { + "text/plain": [ + "-13" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "~12\n", + "# 12-> 00001100\n", + "# ~12->11110011\n", + "# 13-> 00001101\n", + "# 11110010 + 1 = 11110011-> 243" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "id": "YCcx-Qx016hg" + }, + "outputs": [ { - "cell_type": "code", - "metadata": { - "id": "Un2To3XN1_Il" - }, - "source": [ - "#What is the output of expression inside print statement. Cross check before running the program.\n", - "print(10+(10*32)//2**5&20+(~(-10))<<2)" - ], - "execution_count": null, - "outputs": [] - }, + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "False\n", + "False\n", + "True\n" + ] + } + ], + "source": [ + "#What is the output of expression inside print statement. Cross check before running the program.\n", + "a = 10\n", + "b = 10\n", + "print(a is b) #True or False?\n", + "print(a is not b) #True or False?\n", + "\n", + "a = 1000\n", + "b = 1000\n", + "print(a is b) #True or False?\n", + "print(a is not b) #True or False?" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "id": "Un2To3XN1_Il" + }, + "outputs": [ { - "cell_type": "code", - "metadata": { - "id": "kGRb5RMd1_1I" - }, - "source": [ - "#Membership operation\n", - "#in, not in are two membership operators and it returns boolean value\n", - "\n", - "print('2' in 'Python2.7.8')\n", - "print(10 in [10,10.20,10+20j,'Python'])\n", - "print(10 in (10,10.20,10+20j,'Python'))\n", - "print(2 in {1,2,3})\n", - "print(3 in {1:100, 2:200, 3:300})\n", - "print(10 in range(20))" - ], - "execution_count": null, - "outputs": [] - }, + "name": "stdout", + "output_type": "stream", + "text": [ + "20\n" + ] + } + ], + "source": [ + "#What is the output of expression inside print statement. Cross check before running the program.\n", + "print(10+(10*32)//2**5&20+(~(-10))<<2)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "id": "kGRb5RMd1_1I" + }, + "outputs": [ { - "cell_type": "code", - "metadata": { - "id": "Es7iSvL92B9W" - }, - "source": [ - "#An integer can be represented in binary, octal or hexadecimal form.\n", - "#Declare one binary, one octal and one hexadecimal value and store them in three different variables.\n", - "#Convert 9876 to its binary, octal and hexadecimal equivalent and print their corresponding value." - ], - "execution_count": null, - "outputs": [] - }, + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "True\n", + "True\n", + "True\n", + "False\n", + "True\n" + ] + } + ], + "source": [ + "#Membership operation\n", + "#in, not in are two membership operators and it returns boolean value\n", + "\n", + "print('2' in 'Python2.7.8')\n", + "print(10 in [10,10.20,10+20j,'Python'])\n", + "print(10 in (10,10.20,10+20j,'Python'))\n", + "print(2 in {1,2,3})\n", + "print(100 in {1:100, 2:200, 3:300})\n", + "print(10 in range(20))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "Es7iSvL92B9W" + }, + "outputs": [], + "source": [ + "#An integer can be represented in binary, octal or hexadecimal form.\n", + "#Declare one binary, one octal and one hexadecimal value and store them in three different variables.\n", + "#Convert 9876 to its binary, octal and hexadecimal equivalent and print their corresponding value." + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "id": "Hm0r03lH2E0i" + }, + "outputs": [ { - "cell_type": "code", - "metadata": { - "id": "Hm0r03lH2E0i" - }, - "source": [ - "#What will be the outut of following:-\n", - "a = 0b1010000\n", - "print(a)\n", - "\n", - "b = 0o7436\n", - "print(b)\n", - "\n", - "c = 0xfade\n", - "print(c)\n", - "\n", - "print(bin(80))\n", - "\n", - "print(oct(3870))\n", - "\n", - "print(hex(64222))\n", - "\n", - "print(bin(0b1010000))\n", - "\n", - "print(bin(0xfade))\n", - "\n", - "print(oct(0xfade))\n", - "\n", - "print(oct(0o7436))\n", - "\n", - "print(hex(0b1010000))\n", - "\n", - "print(hex(0xfade))" - ], - "execution_count": null, - "outputs": [] + "name": "stdout", + "output_type": "stream", + "text": [ + "80\n", + "3870\n", + "64222\n", + "0b1010000\n", + "0o7436\n", + "0xfade\n", + "0b1010000\n", + "0b1111101011011110\n", + "0o175336\n", + "0o7436\n", + "0x50\n", + "0xfade\n" + ] } - ] -} \ No newline at end of file + ], + "source": [ + "#What will be the output of following:-\n", + "a = 0b1010000\n", + "print(a)\n", + "\n", + "b = 0o7436\n", + "print(b)\n", + "\n", + "c = 0xfade\n", + "print(c)\n", + "\n", + "print(bin(80))\n", + "\n", + "print(oct(3870))\n", + "\n", + "print(hex(64222))\n", + "\n", + "print(bin(0b1010000))\n", + "\n", + "print(bin(0xfade))\n", + "\n", + "print(oct(0xfade))\n", + "\n", + "print(oct(0o7436))\n", + "\n", + "print(hex(0b1010000))\n", + "\n", + "print(hex(0xfade))" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [], + "source": [ + "# suppression and regression.\n", + "\n", + "# You catch yourself doing it, That is fine for now. \n", + "# That sight that you know this, has already poked a hole inside it." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "colab": { + "name": "int_assignment.ipynb", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "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.8.10" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +}