0% found this document useful (0 votes)
12 views4 pages

Class 5

Uploaded by

kirpat1002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

Class 5

Uploaded by

kirpat1002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Ex1:

----
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

End of an application ...

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

End of an application ...

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

End of an application ...

C:\Users\DELL\Desktop>Python test1.py
Enter the value of x1:
Enter the value of x2:
The sum of complex value is: 0

End of an application ...

C:\Users\DELL\Desktop>Python test1.py
Enter the value of x1:''
Enter the value of x2:''
The sum of complex value is: 2

End of an application ...


eval():
=======
It is a predefine function in python.The main objective of eval() function is read
any data or information from the keyboard.Whilw reading string data or information
we must use '' or "".

Using eval() function we can perform following operations

->Normal arithmetic operations


->String repetation
->String concatenation

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")

Complex data type:


================
Python supports complex data type.It can be define or declare as follows
100+200j.The main objective of complex data type is perform complex operation in
our application.It may be either + complex data type or - complex data type

x1=100+200j
or
x1=-100-200j

100 ----real part ---->x1.real --->100.0


200 ----Imaginary part ---->x1.imag --->200.0

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 ...")

Boolean or bool data type:


=========================
Python supports boolean data type.The main objective of boolean data type is to
return boolean values either True or false after checking the condition based on
application requirement.

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")

You might also like