From fdfdd649de57c5baded7006cf34da0e8f65c3dd7 Mon Sep 17 00:00:00 2001 From: Sandhya-hub21 <82921090+Sandhya-hub21@users.noreply.github.com> Date: Tue, 3 Aug 2021 11:39:05 +0530 Subject: [PATCH] Add files via upload --- Sandhya/Boolean_Assignement.ipynb | 419 ++++++++++++++++++++++++++++++ Sandhya/Complex_Assignement.ipynb | 268 +++++++++++++++++++ Sandhya/float_assignment.ipynb | 200 ++++++++++++++ Sandhya/int_assignment.ipynb | 267 +++++++++++++++++++ 4 files changed, 1154 insertions(+) create mode 100644 Sandhya/Boolean_Assignement.ipynb create mode 100644 Sandhya/Complex_Assignement.ipynb create mode 100644 Sandhya/float_assignment.ipynb create mode 100644 Sandhya/int_assignment.ipynb diff --git a/Sandhya/Boolean_Assignement.ipynb b/Sandhya/Boolean_Assignement.ipynb new file mode 100644 index 0000000..1f9ed40 --- /dev/null +++ b/Sandhya/Boolean_Assignement.ipynb @@ -0,0 +1,419 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "id": "7JIFn6BP4M0R" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " 140719637845840\n" + ] + } + ], + "source": [ + "#Declare a boolean value and store it in a variable. \n", + "\n", + "bol_var =True\n", + "\n", + "#Check the type and print the id of the same.\n", + "\n", + "print(type(bol_var),id(bol_var))\n" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "id": "o9bjjhN64kAP" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "140719638128432 140719638129840\n" + ] + } + ], + "source": [ + "#Take one boolean value between 0 - 256.\n", + "#Assign it to two different variables.\n", + "\n", + "a =1\n", + "b=45\n", + "\n", + "#Check the id of both the variables. It should come same. Check why?\n", + "\n", + "print(id(a),id(b))\n", + "\n", + "# all non negative integers are converted to True \n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "id": "yr4ETGSf4l5y" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1\n", + "-1\n", + "0\n", + "0.0\n", + "0\n", + "0.0\n", + "0\n" + ] + } + ], + "source": [ + "#Arithmatic Operations on boolean data\n", + "#Take two different boolean values.\n", + "#Store them in two different variables.\n", + "\n", + "\n", + "\n", + "#Do below operations on them:-\n", + " #Find sum of both values\n", + " \n", + "a = False \n", + "b= True\n", + "\n", + "print (a + b)\n", + "\n", + " #Find differce between them\n", + "\n", + "print (a -b)\n", + "\n", + " #Find the product of both.\n", + "\n", + "print(a*b)\n", + "\n", + " #Find value after dividing first value with second value\n", + " \n", + "print(a/b)\n", + " \n", + " #Find the remainder after dividing first value with second value\n", + " \n", + "print(a%b)\n", + " \n", + " #Find the quotient after dividing first value with second value\n", + "print(a /b) \n", + "\n", + " \n", + " #Find the result of first value to the power of second value.\n", + "print(a **b)\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "id": "xG4mX84E4n2O" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n", + "True\n", + "False\n", + "True\n" + ] + } + ], + "source": [ + "#Comparison Operators on boolean values\n", + "#Take two different boolean values.\n", + "#Store them in two different variables.\n", + "\n", + "\n", + "\n", + "#Do below operations on them:-\n", + " #Compare these two values with below operator:-\n", + " \n", + " \n", + "a= False\n", + "b=True\n", + " #Greater than, '>'\n", + "print(a >b)\n", + "\n", + " #less than, '<'\n", + "print(a ='\n", + "print(a>=b)\n", + "\n", + " #Less than or equal to, '<=' \n", + "print(a<=b)\n", + "\n", + "#Observe their output(return type should be boolean)\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "id": "TUIo2Z9V4qBJ" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n", + "True\n" + ] + } + ], + "source": [ + "#Equality Operator\n", + "#Take two different boolean values.\n", + "#Store them in two different variables.\n", + "\n", + "a= False\n", + "b=True\n", + "\n", + "#Equuate them using equality operator (==, !=)\n", + "\n", + "print(a==b)\n", + "\n", + "#Observe the output(return type should be boolean)\n", + "\n", + "print(a!=b)\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "id": "XukEq5E44rxv" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "False\n", + "False\n", + "False\n", + "True\n", + "True\n", + "True\n", + "False\n", + "False\n", + "True\n" + ] + } + ], + "source": [ + "#Logical operators\n", + "#Observe the output of below code\n", + "#Cross check the output manually\n", + "\n", + "print(True and True) #1 and 1 =1 #----------------------------------------->Output is True\n", + "print(False and True) # 0 and 1 =0 #----------------------------------------->Output is False\n", + "print(True and False) #1 and 0 =0 #----------------------------------------->Output is False\n", + "print(False and False) #0 and 0 =0 #----------------------------------------->Output is False\n", + "\n", + "print(True or True) #1 or 1 =1 #----------------------------------------->Output is True\n", + "print(False or True)#0 or 1 =1 #----------------------------------------->Output is True\n", + "print(True or False)#1 or 0 =1 #----------------------------------------->Output is True\n", + "print(False or False)# 0 or 0 =0 #----------------------------------------->Output is False\n", + "\n", + "print(not True) # not 1 =0 #----------------------------------------->Output is False\n", + "print(not False) #not 0 =1 #----------------------------------------->Output is True" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": { + "id": "02jPgt094vK-" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "True\n", + "True\n", + "-2\n", + "4\n", + "0\n" + ] + } + ], + "source": [ + "#Bitwise Operators\n", + "#Do below operations on the values provided below:-\n", + " #Bitwise and(&) -----------------------------------------> True, True -------> Output is True\n", + "print(True & True)\n", + "\n", + "\n", + " #Bitwise or(|) -----------------------------------------> True, False -------> Output is True\n", + "\n", + "print(True | False)\n", + "\n", + " #Bitwise(^) -----------------------------------------> True, False -------> Output is True\n", + "\n", + "print(True ^ False) \n", + "\n", + " #Bitwise negation(~) ------------------------------------> True -------> Output is -2\n", + "\n", + "print(~True) \n", + "\n", + " #Bitwise left shift ------------------------------------> True,2 -------> Output is 4\n", + "\n", + "print(True <<2)\n", + "\n", + " #Bitwise right shift ------------------------------------> True,2 -------> Output is 0\n", + "\n", + "print(True >>2)\n", + "\n", + "#Cross check the output manually\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": { + "id": "cy5i7sWz4v_c" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n", + "False\n", + "True\n", + "False\n" + ] + } + ], + "source": [ + "#What is the output of expression inside print statement. Cross check before running the program.\n", + "a = True\n", + "b = True\n", + "print(a is b) # True #True or False? #\n", + "print(a is not b) #False #True or False?\n", + "\n", + "a = False\n", + "b = False\n", + "print(a is b) #True #True or False?\n", + "print(a is not b) #False #True or False?\n" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": { + "id": "AOcPQi8544M-" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "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(True in [10,10.20,10+20j,'Python', True]) #True\n", + "print(False in (10,10.20,10+20j,'Python', False))#True\n", + "print(True in {1,2,3, True}) #True\n", + "print(True in {True:100, False:200, True:300}) #True\n", + "print(False in {True:100, False:200, True:300})#True" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "MPa1Lpco46Ja" + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "colab": { + "name": "Boolean_Assignement.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/Sandhya/Complex_Assignement.ipynb b/Sandhya/Complex_Assignement.ipynb new file mode 100644 index 0000000..d3683c8 --- /dev/null +++ b/Sandhya/Complex_Assignement.ipynb @@ -0,0 +1,268 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "id": "JoMbQLjK3uHZ" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " 2270494691760\n" + ] + } + ], + "source": [ + "#Declare a complex number and store it in a variable. \n", + "a= 15+45j\n", + "\n", + "\n", + "#Check the type and print the id of the same.\n", + "print(type(a),id(a))\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "id": "6N6Ee4BU33jk" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(30+30j)\n", + "(-10+10j)\n", + "500j\n", + "(0.8+0.6j)\n", + "(-1.4908666720594243e+22+2.883627475588858e+21j)\n" + ] + } + ], + "source": [ + "#Arithmatic Operations on complex number\n", + "#Take two different complex number.\n", + "#Store them in two different variables.\n", + "#Do below operations on them:-\n", + " #Find sum of both numbers\n", + "a= 10 +20j\n", + "b= 20+10j\n", + "print(a +b )\n", + " #Find differce between them\n", + "print(a -b)\n", + " #Find the product of both numbers.\n", + "print(a*b)\n", + " #Find value after dividing first num with second number\n", + "print(a/b)\n", + " #Find the result of first num to the power of second number.\n", + "print(a**b)\n", + "\n", + "#print(a%b) # not allowed operation\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "id": "xhkdg7LD352y" + }, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'>' not supported between instances of 'complex' and 'complex'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[0mb\u001b[0m\u001b[1;33m=\u001b[0m \u001b[1;36m20\u001b[0m\u001b[1;33m+\u001b[0m\u001b[1;36m10j\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 7\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma\u001b[0m \u001b[1;33m>\u001b[0m \u001b[0mb\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 8\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mTypeError\u001b[0m: '>' not supported between instances of 'complex' and 'complex'" + ] + } + ], + "source": [ + "#Comparison Operation not applicable between instance of complex values\n", + "#Object reusability concept is not applicable on complex numebr\n", + "\n", + "a= 10 +20j\n", + "b= 20+10j\n", + "\n", + "print(a > b)\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "id": "4lzPH2sb38KM" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n", + "True\n" + ] + } + ], + "source": [ + "#Equality Operator\n", + "#Take two different complex numbers.\n", + "#Store them in two different variables.\n", + "#Equuate them using equality operator (==, !=)\n", + "#Observe the output(return type should be boolean)\n", + "\n", + "a= 10 +20j\n", + "b= 20+10j\n", + "\n", + "print(a==b)\n", + "\n", + "print(a!=b)\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "id": "EDEl19UD3_tr" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(20+30j)\n", + "0j\n", + "0j\n", + "0j\n", + "(10+20j)\n", + "(20+30j)\n", + "(20+30j)\n", + "0j\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+20j and 20+30j) #1 and 1 sosecond value #----------------------------------------->Output is 20+30j\n", + "print(0+0j and 20+30j) #0 and 1 so 0 #0+0j #----------------------------------------->Output is 0j\n", + "print(20+30j and 0+0j) # 1 and 0 so 0 #0+0j #----------------------------------------->Output is 0j\n", + "print(0+0j and 0+0j) #0 and 0 so 0 #0+0j #----------------------------------------->Output is 0j\n", + "\n", + "print(10+20j or 20+30j) # 1 or 1 so 1st value #10+20j #----------------------------------------->Output is 10+20j\n", + "print(0+0j or 20+30j) # 0 or 1 so 2nd value #20+30j #----------------------------------------->Output is 20+30j\n", + "print(20+30j or 0+0j) #1 or 0 so 1st value #20+30j #----------------------------------------->Output is 20+30j\n", + "print(0+0j or 0+0j) # 0 or 0 so o #0+0j #----------------------------------------->Output is 0j\n", + "\n", + "print(not 10+20j) #not True is #False #----------------------------------------->Output is False\n", + "print(not 0+0j) # not false is #True #----------------------------------------->Output is True" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "id": "4ifueKbP4Br1" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n", + "True\n" + ] + } + ], + "source": [ + "#What is the output of expression inside print statement. Cross check before running the program.\n", + "a = 10+20j\n", + "b = 10+20j\n", + "print(a is b) #Object reusability is not supported hence #False #True or False?\n", + "print(a is not b) #True #True or False?\n" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "id": "TxMbr5jQ4Dwl" + }, + "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.7' in 'Python2.7.8') #True\n", + "print(10+20j in [10,10.20,10+20j,'Python']) #True\n", + "print(10+20j in (10,10.20,10+20j,'Python')) #True\n", + "print(30+40j in {1,20.30,30+40j}) #True\n", + "print(30+40j in {1:100, 2.3:200, 30+40j:300}) #True\n", + "print(10 in range(20)) #True" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "colab": { + "name": "Complex_Assignement.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/Sandhya/float_assignment.ipynb b/Sandhya/float_assignment.ipynb new file mode 100644 index 0000000..ac5d028 --- /dev/null +++ b/Sandhya/float_assignment.ipynb @@ -0,0 +1,200 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "float_assignment.ipynb", + "provenance": [] + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + } + }, + "cells": [ + { + "cell_type": "code", + "metadata": { + "id": "dlrMB-Qy2taV" + }, + "source": [ + "#Declare a float value and store it in a variable. \n", + "num_f = 10.20\n", + "\n", + "\n", + "\n", + "\n", + "#Check the type and print the id of the same.\n", + "print(num_f)\n", + "print(type(num_f))\n", + "print(id(num_f))\n", + "\n" + ], + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "IL4fVDHg2wbI" + }, + "source": [ + "#Arithmatic Operations on float\n", + "#Take two different float values.\n", + "#Store them in two different variables.\n", + "\n", + "#Do below operations on them:-\n", + " #Find sum of both numbers\n", + "\n", + " #Find differce between them\n", + " #Find the product of both numbers.\n", + "\n", + " #Find value after dividing first num with second number\n", + "\n", + " #Find the remainder after dividing first number with second number\n", + "\n", + " #Find the quotient after dividing first number with second number\n", + "\n", + " #Find the result of first num to the power of second number." + ], + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "atCFaH6c2492" + }, + "source": [ + "#Comparison Operators on float\n", + "#Take two different float values.\n", + "#Store them in two different variables.\n", + "\n", + "#Do below operations on them:-\n", + " #Compare these two numbers with below operator:-\n", + " #Greater than, '>'\n", + "\n", + " #Smaller than, '<'\n", + "\n", + " #Greater than or equal to, '>='\n", + "\n", + " #Less than or equal to, '<='\n", + "\n", + "#Observe their output(return type should be boolean)\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ], + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "agi3U3863A5i" + }, + "source": [ + "#Equality Operator\n", + "#Take two different float values.\n", + "#Store them in two different variables.\n", + "\n", + "#Equuate them using equality operator (==, !=)\n", + "\n", + "#Observe the output(return type should be boolean)\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ], + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "3HLlgaEt3EnJ" + }, + "source": [ + "#Logical operators\n", + "#Observe the output of below code\n", + "#Cross check the output manually\n", + "\n", + "print(10.20 and 20.30) #both are true and second value taken >Output is 20.3\n", + "print(0.0 and 20.30) #First is false so first value taken->Output is 0.0\n", + "print(20.30 and 0.0) #Goes to till second and second value is false so second is taken>Output is 0.0\n", + "print(0.0 and 0.0) #First is false so first value is taken->Output is 0.0\n", + "\n", + "print(10.20 or 20.30) #First is True so first value is taken>Output is 10.2\n", + "print(0.0 or 20.30) #Goes to till second and second is true second value is taken->Output is 20.3\n", + "print(20.30 or 0.0) #First is True so first value is taken->Output is 20.3\n", + "print(0.0 or 0.0) #Goes to till second and secod is also false and second value is taken>Output is 0.0\n", + "\n", + "print(not 10.20) #-Not of true is false->Output is False\n", + "print(not 0.0) #Not of false is True>Output is True" + ], + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "7YdyRNtk3UZd" + }, + "source": [ + "#What is the output of expression inside print statement. Cross check before running the program.\n", + "a = 10.20\n", + "b - 10.20\n", + "print(a is b) #True or False? True 10.20<256\n", + "print(a is not b) #True or False? False\n", + "\n", + "\n", + "# Why the Id of float values are different when the same value is assigned to two different variables\n", + "# ex: a = 10.5 b=10.5. but id will be same if I assign the variable having float i.e. a=c then both a anc c's\n", + "# Id are same\n" + ], + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "iTvnIMLd3VLW" + }, + "source": [ + "#Bitwise operation is not applicable between instances of float.\n", + "## Why the Id of float values are different when the same value is assigned to two different variables\n", + "## ex: a = 10.5 b=10.5. but id will be same if I assign the variable having float i.e. a=c then both a anc c's\n", + "## Id are same\n", + "#Object reusability concept is not applicable on float values." + ], + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "29AVJHpx3YUo" + }, + "source": [ + "#Membership operation\n", + "#in, not in are two membership operators and it returns boolean value\n", + "\n", + "print('2.7' in 'Python2.7.8') #True\n", + "print(10.20 in [10,10.20,10+20j,'Python']) #True\n", + "print(10.20 in (10,10.20,10+20j,'Python')) # True\n", + "print(20.30 in {1,20.30,30+40j}) # True\n", + "print(2.3 in {1:100, 2.3:200, 30+40j:300}) # True\n", + "print(10 in range(20)) # True" + ], + "execution_count": null, + "outputs": [] + } + ] +} \ No newline at end of file diff --git a/Sandhya/int_assignment.ipynb b/Sandhya/int_assignment.ipynb new file mode 100644 index 0000000..6090fff --- /dev/null +++ b/Sandhya/int_assignment.ipynb @@ -0,0 +1,267 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "int_assignment.ipynb", + "provenance": [] + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + } + }, + "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", + "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": [] + }, + { + "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": [] + }, + { + "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": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "v9-sAvlZZdoi" + }, + "source": [ + "" + ], + "execution_count": null, + "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": [] + }, + { + "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": [] + }, + { + "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": [] + }, + { + "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": [] + }, + { + "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": [] + }, + { + "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": [] + }, + { + "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": [] + } + ] +} \ No newline at end of file