-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday_02variablesandoperators.py
More file actions
94 lines (63 loc) · 1.7 KB
/
Copy pathday_02variablesandoperators.py
File metadata and controls
94 lines (63 loc) · 1.7 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#------------------------------------
#day2_variablesandoperators
#------------------------------------
#1.Even or Odd
num=int(input("Enter the number :"))
if(num%2==0):
print("The given number is even.")
else:
print("The given number is odd.")
print("------------------------------")
#2.Positive/Negative/Zero
n=int(input("Enter the value:"))
if(n>0):
print("The given number is Positive.")
elif(n<0):
print("The given number is Negative.")
else:
print("The given number is Zero.")
print("------------------------------")
#3.Largest of 3 NUMBERS
x=int(input("Enter x="))
y=int(input("Enter y="))
z=int(input("Enter z="))
if(x>y and x>z):
print("Largest number is",x)
elif(y>x and y>z):
print("Largest number is",y)
else:
print("Largest number is",z)
print("-----------------------------")
#4.Leap year check
year=int(input("Enter year:"))
if(year%4==0):
print("It is a leap year.")
else:
print("It is not a leap year.")
print("----------------------------")
#5.Bitwise operators
a = 5
b = 3
print("a & b =", a & b)
print("a | b =", a | b)
print("a ^ b =", a ^ b)
print("------------------------------")
#6.Logical and Bitwise Operator
x = int(input("Enter x:"))
y = 3
print("Logical and:", (x > 2) and (y > 1))
print("Bitwise AND:", x & y)
print("-------------------------------")
#7.Operator Precedence example
print("Example of operator Precedence:")
x=15*(6+7(9*(4-1))/5)/3
print("Answer=",x)
#8.Increment without using +
n=int(input("Enter the number:"))
n+=1
print("After Increment with assignment operator:")
#---------------------------------------
n=int(input("Enter the number:"))
n=n-(-1)
print("After Increment with using +:",n)
print("--------------------------------")