From 709f6e6f95abbdd8791c82a37a218995377adc2b Mon Sep 17 00:00:00 2001 From: Amar Mane <103245765+amaranagha@users.noreply.github.com> Date: Thu, 19 May 2022 15:50:44 +0530 Subject: [PATCH] Add files via upload --- Complex_Amar.ipynb | 232 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 Complex_Amar.ipynb diff --git a/Complex_Amar.ipynb b/Complex_Amar.ipynb new file mode 100644 index 0000000..a35ee89 --- /dev/null +++ b/Complex_Amar.ipynb @@ -0,0 +1,232 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "id": "JoMbQLjK3uHZ" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(10+3j) \n" + ] + } + ], + "source": [ + "#Declare a complex number and store it in a variable. \n", + "\n", + "a=10+3j\n", + "\n", + "#Check the type and print the id of the same.\n", + "\n", + "print(a,type(a))\n" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "id": "6N6Ee4BU33jk" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Enter x3+4j\n", + "Enter y2+3j\n", + "(5+7j)\n", + "(1+1j)\n", + "(-6+17j)\n", + "(1.3846153846153848-0.07692307692307697j)\n", + "(1.4260094753925756+0.6024346301905391j)\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", + " #Find differce between them\n", + " #Find the product of both numbers.\n", + " #Find value after dividing first num with second number\n", + " #Find the result of first num to the power of second number.\n", + " \n", + "x= complex(input(\"Enter x\"))\n", + "y= complex(input(\"Enter y\"))\n", + "\n", + "print(x+y)\n", + "print(x-y)\n", + "print(x*y)\n", + "print(x/y)\n", + "print(x**y)\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "xhkdg7LD352y" + }, + "outputs": [], + "source": [ + "#Comparison Operation not applicable between instance of complex values\n", + "#Object reusability concept is not applicable on complex numebr\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "id": "4lzPH2sb38KM" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Enter x2+3j\n", + "Enter y4+8j\n", + "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", + "x=complex(input(\"Enter x\"))\n", + "y=complex(input(\"Enter y\"))\n", + "print(x==y)\n", + "print(x!=y)\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "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) #20+30j #----------------------------------------->Output is 20+30j\n", + "print(0+0j and 20+30j) #0+0j #----------------------------------------->Output is 0j\n", + "print(20+30j and 0+0j) #0+0j #----------------------------------------->Output is 0j\n", + "print(0+0j and 0+0j) #0+0j #----------------------------------------->Output is 0j\n", + "\n", + "print(10+20j or 20+30j) #10+20j #----------------------------------------->Output is 10+20j\n", + "print(0+0j or 20+30j) #20+30j #----------------------------------------->Output is 20+30j\n", + "print(20+30j or 0+0j) #20+30j #----------------------------------------->Output is 20+30j\n", + "print(0+0j or 0+0j) #0+0j #----------------------------------------->Output is 0j\n", + "\n", + "print(not 10+20j) #False #----------------------------------------->Output is False\n", + "print(not 0+0j) #True #----------------------------------------->Output is True" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "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) #False #True or False?\n", + "print(a is not b) #True #True or False?\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "TxMbr5jQ4Dwl" + }, + "outputs": [], + "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" + ] + } + ], + "metadata": { + "colab": { + "name": "Complex_Assignement.ipynb", + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "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.9.7" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +}