Recents in Beach

Python Program to Perform Operators

About Blog Best learn Engg. Subject like DAA,Operating System,C language, Python ,Daily Coding Challenges ..this blog Provides Tutorials And coding Challenges of C,Python, OS,DAA,Algorithms and other...for all Beginners...
It is Great way to improve Your skills when learning to Code and solving code challenges,Solving Different Type of Challenges and Puzzles....

The best way to learn Python is by practicing examples. The page contains examples on basic concepts of Python. You are advised to take the references from these examples and try them on your own.


What is Operators ? explain list of python operators ? 


Python Program to Perform  Operators .


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# PYTHON
# Author :https://programokey.blogspot.com/
#  Python Operators

#Arithmetic Operators
print("\n******Arithmetic Operators********\n")
x= int(input("Enter the 1st number : "))
y= int(input("Enter the 2st number : "))
c = x + y
print("Addition of x and y is : ",c)

#Comparison Operators
print("\n******Comparison Operators********\n")
x= int(input("Enter the 1st number : "))
y= int(input("Enter the 2st number : "))
print('1st number > 2nd number  is',x>y)

#Assignment Operators
print("\n******Assignment Operators********\n")
x= int(input("Enter the 1st number : "))
y= int(input("Enter the 2st number : "))
print ("Line 1 - Value of 1st number : ", x)
print ("Line 2 - Value of 2nd number : ", y)

#compound assignment operator
print("\n******compound assignment operator********\n")
x= int(input("Enter the 1st number : "))
y= int(input("Enter the 2st number : "))
res = x + y
res += x
print (" Result of + is ", res)

#Logical Operators
print("\n******Logical Operators********\n")
a = True
b = False
print('a and b is',a and b)
print('a or b is',a or b)
print('not a is',not a)

#Membership Operators
print("\n******Membership Operators********\n")
x= int(input("Enter the 1st number : "))
y= int(input("Enter the 2st number : "))
list = [1, 2, 3, 4, 5 ]
if ( x in list ):
   print ("Line 1 - 1st number  is available in the given list")
else:
   print ("Line 1 - 1st number is not available in the given list")
if ( y not in list ):
   print ("Line 2 - 2nd number is not available in the given list")
else:
   print ("Line 2 - 2nd number is available in the given list")

#Identity Operators
print("\n******Identity Operators********\n")
x= int(input("Enter the 1st number : "))
y= int(input("Enter the 2st number : "))

if ( x is y ):
    print ("1st number & 2nd number  SAME identity")

if ( x is not y ):
    print( "1st number & 2nd number have DIFFERENT identity")

#Operator precedence
print("\n******Operator precedence********\n")
v = int(input("Enter the value of v : "))
w= int(input("Enter the value of w : "))
x= int(input("Enter the value of x : "))
y= int(input("Enter the value of y : "))
z = int(input("Enter the value of z : "))
result= (v+w) * x / y
print ("Value of (v+w) * x/ y is ",  result)

Post a Comment

0 Comments