diff --git a/.ipynb_checkpoints/int_assignment-checkpoint.ipynb b/.ipynb_checkpoints/int_assignment-checkpoint.ipynb new file mode 100644 index 0000000..bdd37ff --- /dev/null +++ b/.ipynb_checkpoints/int_assignment-checkpoint.ipynb @@ -0,0 +1,475 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "id": "8A5Jw5NR1iEI" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "140729058600752" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Declare an int value and store it in a variable. \n", + "\n", + "\n", + "a=1\n", + "#Check the type and print the id of the same.\n", + "\n", + "type(a)\n", + "id(a)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "id": "0YU8LFTn1rAX" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "140729058600816\n", + "140729058600816\n", + "2111255492240\n", + "2111255492432\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", + "\n", + "a=3\n", + "b=3\n", + "print(id(a))\n", + "print(id(b))\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", + "c=-6\n", + "d=-6\n", + "print(id(c))\n", + "print(id(d))\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "id": "YzEIG0ZZ1tSK" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Values of c,d,e,f,g,h 12 4 32 2.0 2 0\n" + ] + } + ], + "source": [ + "#Arithmatic Operations on integers\n", + "#Take two different intger values.\n", + "#Store them in two different variables.\n", + "a=8\n", + "b=4\n", + "#Do below operations on them:-\n", + " #Find sum of both numbers\n", + "c=a+b\n", + " #Find differce between them\n", + "d=a-b\n", + " #Find the product of both numbers.\n", + "e=a*b\n", + "\n", + " #Find value after dividing first num with second number\n", + "f=a/b\n", + "\n", + " #Find the remainder after dividing first number with second number\n", + "g=a//b\n", + " #Find the quotient after dividing first number with second number\n", + "h=a % b\n", + " #Find the result of first num to the power of second number.\n", + "print(\"Values of c,d,e,f,g,h\",c,d,e,f,g,h)" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": { + "id": "GGM7CdzA1wGn" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a,d,e,f True False True False\n", + " \n" + ] + } + ], + "source": [ + "#Comparison Operators on integers\n", + "#Take two different intger values.\n", + "#Store them in two different variables.\n", + "a=10\n", + "b=5\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", + "c=a>b\n", + "d=a=b\n", + "f=a<=b\n", + "print(\"a,d,e,f\",c,d,e,f)\n", + "print(type(c),type(d),type(e),type(f))\n", + "#Observe their output(return type should be boolean)" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": { + "id": "9x904sUE1y9t" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n", + "True\n" + ] + } + ], + "source": [ + "#Equality Operator\n", + "#Take two different intger values.\n", + "#Store them in two different variables.\n", + "#Equuate them using equality operator (==, !=)\n", + "a=5\n", + "b=8\n", + "print(a==b)\n", + "print(a!=b)\n", + "#Observe the output(return type should be boolean)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "v9-sAvlZZdoi" + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": { + "id": "JmQFHUwc11S-" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "20\n", + "0\n", + "0\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", + "\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", + "While the number being true and non zero its conditions print the second number else it prints the first number\n", + "\n", + "print(0 and 20) #----------------------------------------->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": 38, + "metadata": { + "id": "-0tvoulX14Hi" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0\n", + "30\n", + "30\n", + "-11\n", + "2\n", + "40\n" + ] + }, + { + "data": { + "text/plain": [ + "'0b1000'" + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], + "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", + "a=10\n", + "b=20\n", + "print(a&b)\n", + "print(a|b)\n", + "print(a^b)\n", + "print(~a)\n", + "print(10>>2)\n", + "print(10<<2)\n", + "\n", + "#Cross check the output manually" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": { + "id": "YCcx-Qx016hg" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "False\n", + "False\n", + "True\n", + "36\n", + "165\n", + "4\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\n", + "print(~-10<<2)\n", + "print(330//2)\n", + "print(5&20)" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "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": 45, + "metadata": { + "id": "kGRb5RMd1_1I" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "True\n", + "True\n", + "True\n", + "True\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(3 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": 46, + "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 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))" + ] + }, + { + "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.8" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/Jagadeesh/int_assignment.ipynb b/Jagadeesh/int_assignment.ipynb new file mode 100644 index 0000000..bdd37ff --- /dev/null +++ b/Jagadeesh/int_assignment.ipynb @@ -0,0 +1,475 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "id": "8A5Jw5NR1iEI" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "140729058600752" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Declare an int value and store it in a variable. \n", + "\n", + "\n", + "a=1\n", + "#Check the type and print the id of the same.\n", + "\n", + "type(a)\n", + "id(a)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "id": "0YU8LFTn1rAX" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "140729058600816\n", + "140729058600816\n", + "2111255492240\n", + "2111255492432\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", + "\n", + "a=3\n", + "b=3\n", + "print(id(a))\n", + "print(id(b))\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", + "c=-6\n", + "d=-6\n", + "print(id(c))\n", + "print(id(d))\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "id": "YzEIG0ZZ1tSK" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Values of c,d,e,f,g,h 12 4 32 2.0 2 0\n" + ] + } + ], + "source": [ + "#Arithmatic Operations on integers\n", + "#Take two different intger values.\n", + "#Store them in two different variables.\n", + "a=8\n", + "b=4\n", + "#Do below operations on them:-\n", + " #Find sum of both numbers\n", + "c=a+b\n", + " #Find differce between them\n", + "d=a-b\n", + " #Find the product of both numbers.\n", + "e=a*b\n", + "\n", + " #Find value after dividing first num with second number\n", + "f=a/b\n", + "\n", + " #Find the remainder after dividing first number with second number\n", + "g=a//b\n", + " #Find the quotient after dividing first number with second number\n", + "h=a % b\n", + " #Find the result of first num to the power of second number.\n", + "print(\"Values of c,d,e,f,g,h\",c,d,e,f,g,h)" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": { + "id": "GGM7CdzA1wGn" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a,d,e,f True False True False\n", + " \n" + ] + } + ], + "source": [ + "#Comparison Operators on integers\n", + "#Take two different intger values.\n", + "#Store them in two different variables.\n", + "a=10\n", + "b=5\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", + "c=a>b\n", + "d=a=b\n", + "f=a<=b\n", + "print(\"a,d,e,f\",c,d,e,f)\n", + "print(type(c),type(d),type(e),type(f))\n", + "#Observe their output(return type should be boolean)" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": { + "id": "9x904sUE1y9t" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n", + "True\n" + ] + } + ], + "source": [ + "#Equality Operator\n", + "#Take two different intger values.\n", + "#Store them in two different variables.\n", + "#Equuate them using equality operator (==, !=)\n", + "a=5\n", + "b=8\n", + "print(a==b)\n", + "print(a!=b)\n", + "#Observe the output(return type should be boolean)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "v9-sAvlZZdoi" + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": { + "id": "JmQFHUwc11S-" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "20\n", + "0\n", + "0\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", + "\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", + "While the number being true and non zero its conditions print the second number else it prints the first number\n", + "\n", + "print(0 and 20) #----------------------------------------->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": 38, + "metadata": { + "id": "-0tvoulX14Hi" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0\n", + "30\n", + "30\n", + "-11\n", + "2\n", + "40\n" + ] + }, + { + "data": { + "text/plain": [ + "'0b1000'" + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], + "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", + "a=10\n", + "b=20\n", + "print(a&b)\n", + "print(a|b)\n", + "print(a^b)\n", + "print(~a)\n", + "print(10>>2)\n", + "print(10<<2)\n", + "\n", + "#Cross check the output manually" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": { + "id": "YCcx-Qx016hg" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "False\n", + "False\n", + "True\n", + "36\n", + "165\n", + "4\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\n", + "print(~-10<<2)\n", + "print(330//2)\n", + "print(5&20)" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "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": 45, + "metadata": { + "id": "kGRb5RMd1_1I" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "True\n", + "True\n", + "True\n", + "True\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(3 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": 46, + "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 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))" + ] + }, + { + "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.8" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/int_assignment.ipynb b/int_assignment.ipynb index 6090fff..bdd37ff 100644 --- a/int_assignment.ipynb +++ b/int_assignment.ipynb @@ -1,267 +1,475 @@ { - "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": 2, + "metadata": { + "id": "8A5Jw5NR1iEI" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "140729058600752" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" } + ], + "source": [ + "#Declare an int value and store it in a variable. \n", + "\n", + "\n", + "a=1\n", + "#Check the type and print the id of the same.\n", + "\n", + "type(a)\n", + "id(a)" + ] }, - "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", - "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": [] - }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "id": "0YU8LFTn1rAX" + }, + "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": [ + "140729058600816\n", + "140729058600816\n", + "2111255492240\n", + "2111255492432\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", + "\n", + "a=3\n", + "b=3\n", + "print(id(a))\n", + "print(id(b))\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", + "c=-6\n", + "d=-6\n", + "print(id(c))\n", + "print(id(d))\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "id": "YzEIG0ZZ1tSK" + }, + "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": [] - }, + "name": "stdout", + "output_type": "stream", + "text": [ + "Values of c,d,e,f,g,h 12 4 32 2.0 2 0\n" + ] + } + ], + "source": [ + "#Arithmatic Operations on integers\n", + "#Take two different intger values.\n", + "#Store them in two different variables.\n", + "a=8\n", + "b=4\n", + "#Do below operations on them:-\n", + " #Find sum of both numbers\n", + "c=a+b\n", + " #Find differce between them\n", + "d=a-b\n", + " #Find the product of both numbers.\n", + "e=a*b\n", + "\n", + " #Find value after dividing first num with second number\n", + "f=a/b\n", + "\n", + " #Find the remainder after dividing first number with second number\n", + "g=a//b\n", + " #Find the quotient after dividing first number with second number\n", + "h=a % b\n", + " #Find the result of first num to the power of second number.\n", + "print(\"Values of c,d,e,f,g,h\",c,d,e,f,g,h)" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": { + "id": "GGM7CdzA1wGn" + }, + "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": [] - }, + "name": "stdout", + "output_type": "stream", + "text": [ + "a,d,e,f True False True False\n", + " \n" + ] + } + ], + "source": [ + "#Comparison Operators on integers\n", + "#Take two different intger values.\n", + "#Store them in two different variables.\n", + "a=10\n", + "b=5\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", + "c=a>b\n", + "d=a=b\n", + "f=a<=b\n", + "print(\"a,d,e,f\",c,d,e,f)\n", + "print(type(c),type(d),type(e),type(f))\n", + "#Observe their output(return type should be boolean)" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": { + "id": "9x904sUE1y9t" + }, + "outputs": [ { - "cell_type": "code", - "metadata": { - "id": "v9-sAvlZZdoi" - }, - "source": [ - "" - ], - "execution_count": null, - "outputs": [] - }, + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n", + "True\n" + ] + } + ], + "source": [ + "#Equality Operator\n", + "#Take two different intger values.\n", + "#Store them in two different variables.\n", + "#Equuate them using equality operator (==, !=)\n", + "a=5\n", + "b=8\n", + "print(a==b)\n", + "print(a!=b)\n", + "#Observe the output(return type should be boolean)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "v9-sAvlZZdoi" + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 30, + "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": [ + "20\n", + "0\n", + "0\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", + "\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", + "While the number being true and non zero its conditions print the second number else it prints the first number\n", + "\n", + "print(0 and 20) #----------------------------------------->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": 38, + "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", + "-11\n", + "2\n", + "40\n" + ] }, { - "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": [ + "'0b1000'" + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], + "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", + "a=10\n", + "b=20\n", + "print(a&b)\n", + "print(a|b)\n", + "print(a^b)\n", + "print(~a)\n", + "print(10>>2)\n", + "print(10<<2)\n", + "\n", + "#Cross check the output manually" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "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", + "36\n", + "165\n", + "4\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\n", + "print(~-10<<2)\n", + "print(330//2)\n", + "print(5&20)" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "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": 45, + "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", + "True\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(3 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": 46, + "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 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))" + ] + }, + { + "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.8" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +}