-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathday2.py
More file actions
152 lines (103 loc) · 3.34 KB
/
day2.py
File metadata and controls
152 lines (103 loc) · 3.34 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# -------------------------------Operators in python ------------------------------
# Arithmetic operators in Python are used to perform mathematical operations on numerical values. Here are the primary arithmetic operators in Python, along with explanations and examples: +,-,*,,/,%,,**,//,
# Addition +: Adds two operands.
# x = 5
# y = 3
# result = x + y
# print(result)
# Subtraction -: Subtracts the right operand from the left operand.
# x = 10
# y = 4
# result = x - y # result is 6
# print(result)
# Multiplication *: Multiplies two operands.
# x = 7
# y = 2
# result = x * y # result is 14
# Division /: Divides the left operand by the right operand as a floating-point division.
# x = 8
# y = 2
# result = x / y # result is 4.0
# Floor Division //: Divides the left operand by the right operand and rounds down to the
# x = 9
# y = 2
# result = x // y # result is 4
# Modulus %: Returns the remainder when the left operand is divided by the right operand.
# x = 15
# y = 7
# result = x % y # result is 1
# Exponentiation **: Raises the left operand to the power of the right operand.
# x = 2
# y = 3
# result = x ** y # result is 8
# ----------------------compairision operators ------------------------
"""
In Python, comparison operators are used to compare two values and return a Boolean (True or False) result. Here are the comparison operators in Python """
# Equal to (==): Checks if two values are equal.
# x=10
# y=20
# it return false
# print(x==y)
# x=20
# y=20
# # it return false
# print(x==y)
# Not equal to (!=): Checks if two values are not equal.
# x=10
# y=20
# # it return True
# print(x!=y)
# x=50
# y=50
# # it return false
# print(x!=y)
# Greater than (>): Checks if the left operand is greater than the right operand.
# x=10
# y=20
# print(x>y)
# it return false
# x=10
# y=20
# print(y>x)
# it return True
# Less than (<): Checks if the left operand is less than the right operand.
# x=10
# y=20
# print(x<y)
# it return false
# x=10
# y=20
# print(y<x)
# Greater than or equal to (>=): Checks if the left operand is greater than or equal to the right
# x=20
# y=20
# print(y>=x)
# x=21
# y=20
# print(y>=x)
# Less than or equal to (<=): Checks if the left operand is less than or equal to the right operand
5 <= 10 # True
10 <= 5 # False
""" In Python, assignment operators are used to assign values to variables. Python provides several assignment operators to make assignments and perform operations on variables in a concise manner. Here are some of the assignment operators in Python:"""
# = (Equal Sign): The basic assignment operator assigns the value on the right-hand side to the variable on the left-hand side
num=10
# print(num)
# +=,-=,*=,/=
# num+=30
# num=num+30
# print(num)
# next try yourself
# Logical operators
# ----------------------------and condition--------------------
# T and T =T
# T and F = F
# -------------------------- or codition -----------------------
# T or F =T
# F or F= F
# num1=30
# num2=40
# num3=num1+num2
# print(num1>num2 and num2>num3 or num3>400 and num1!=num1 or num2==num2 and num3==70)
# Guess the Answer
# special operators (in operators )
# ---------------------------The End -----------------------------------