Class 5
Class 5
----
import time
x1=complex(input("Enter the value of x1:"))
x2=complex(input("Enter the value of x2:"))
res1=x1+x2
print("The sum of complex value is:",res1)
print()
time.sleep(2)
print("End of an application ...")
Ex2:
----
import time
x1=bool(input("Enter the value of x1:"))
x2=bool(input("Enter the value of x2:"))
res1=x1+x2
print("The sum of complex value is:",res1)
print()
time.sleep(2)
print("End of an application ...")
OUTPUT:
------
C:\Users\DELL\Desktop>Python test1.py
Enter the value of x1:1000
Enter the value of x2:2000
The sum of complex value is: 2
C:\Users\DELL\Desktop>Python test1.py
Enter the value of x1:12
Enter the value of x2:
The sum of complex value is: 1
C:\Users\DELL\Desktop>Python test1.py
Enter the value of x1:core Python
Enter the value of x2:Advacne Python
The sum of complex value is: 2
C:\Users\DELL\Desktop>Python test1.py
Enter the value of x1:
Enter the value of x2:
The sum of complex value is: 0
C:\Users\DELL\Desktop>Python test1.py
Enter the value of x1:''
Enter the value of x2:''
The sum of complex value is: 2
Ex1:
----
import time
x1=eval(input("Enter the any data from your wish:"))
print(x1)
print()
print(type(x1))
print()
time.sleep(2)
print("End of an application")
x1=100+200j
or
x1=-100-200j
Ex1:
---
import time
x1=10+20j
x2=-100-200j
print()
print(x1)
print()
print(type(x1))
print()
print(x2)
print()
print(type(x2))
print()
time.sleep(1)
print('End of an application ...')
Ex2:
===
import time
x1=10+20j
print(x1)
print()
print(type(x1))
print()
print("---Real part----")
print(x1.real)
print()
print("----Imaginary part----")
print(x1.imag)
print()
time.sleep(2)
print("End of an application ...")
Ex3:
---
import time
x2=1000j
print(x2)
print()
print(type(x2))
print()
print("The real part is:",x2.real)
print()
print("The imaginary part is:",x2.imag)
print()
time.sleep(2)
print('End of an application ')
Ex4:
----
import time
x1=120+230j
x2=-20-200j
res1=x1+x2
print("The result is:",res1)
print()
time.sleep(2)
print("End of an application ...")
Ex1:
---
import time
obj1=int(input("Enter the value of obj1:"))
obj2=int(input("Enter the value of obj2:"))
res1=obj1==obj2
res2=obj1!=obj2
print()
print("The result is:",res1)
print()
print("The data type is:",type(res1))
print()
print("The result is:",res2)
print()
print("The data type is:",type(res2))
print()
time.sleep(2)
print("End of an application")