Hướng dẫn assignment operators in python 3 - toán tử gán trong python 3


Giả sử biến A giữ giá trị 10 và biến B giữ giá trị 20, sau đó -a holds the value 10 and variable b holds the value 20, then −

Nhà điều hànhSự mô tảThí dụ
=Gán các giá trị từ các toán hạng bên phải sang bên trái bên tráic = a + b gán giá trị của a + b vào c
+= Thêm vàNó thêm toán hạng bên phải vào toán hạng bên trái và gán kết quả cho toán hạng bên tráiC + = A tương đương với C = C + A
-= trừ vàNó trừ đi toán hạng bên phải từ toán hạng bên trái và gán kết quả cho toán hạng bên tráic - = a tương đương với c = c - a
*= Nhân vàNó nhân lên bên phải với toán hạng bên trái và gán kết quả cho toán hạng bên tráic * = a tương đương với c = c * a
/= Chia vàNó chia toán hạng bên trái với toán hạng bên phải và gán kết quả cho toán hạng bên tráiC / = A tương đương với c = c / ac / = a tương đương với c = c / a
%= Mô đun vàNó lấy mô đun bằng hai toán hạng và gán kết quả cho toán hạng bên tráiC % = A tương đương với c = c % a
** = số mũ vàThực hiện tính toán theo cấp số nhân (nguồn) trên các toán tử và gán giá trị cho toán hạng bên tráic ** = a tương đương với c = c ** a
// = phân chia sànNó thực hiện phân chia sàn trên các nhà khai thác và gán giá trị cho toán hạng bên tráic // = a tương đương với c = c // a

Thí dụ

Giả sử biến A giữ giá trị 10 và biến B giữ giá trị 20, sau đó -a holds the value 10 and variable b holds the value 20, then −

#!/usr/bin/python3

a = 21
b = 10
c = 0

c = a + b
print ("Line 1 - Value of c is ", c)

c += a
print ("Line 2 - Value of c is ", c )

c *= a
print ("Line 3 - Value of c is ", c )

c /= a 
print ("Line 4 - Value of c is ", c )

c  = 2
c %= a
print ("Line 5 - Value of c is ", c)

c **= a
print ("Line 6 - Value of c is ", c)

c //= a
print ("Line 7 - Value of c is ", c)

=

Gán các giá trị từ các toán hạng bên phải sang bên trái bên trái

Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864

python_basic_operators.htm

Toán tử là các biểu tượng đặc biệt thực hiện các hoạt động trên các biến và giá trị. Ví dụ,

print(5 + 6)   # 11

Ở đây,

Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
6 là một toán tử thêm hai số: 5 và 6.5 and 6.


Các loại người vận hành python

Dưới đây là danh sách các loại nhà khai thác python khác nhau mà chúng ta sẽ học trong hướng dẫn này.

  1. Toán tử số học
  2. Toán tử chuyển nhượng
  3. Toán tử so sánh
  4. Toán tử logic
  5. Các nhà khai thác bitwise
  6. Các nhà khai thác đặc biệt

1. Các toán tử số học Python

Các toán tử số học được sử dụng để thực hiện các hoạt động toán học như bổ sung, trừ, nhân, v.v.

sub = 10 - 5 # 5

Ở đây,

Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
7 là một toán tử số học trừ hai giá trị hoặc biến.

Nhà điều hànhHoạt độngThí dụ
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
6
Phép cộng
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
9
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
7
Phép trừ
print(5 + 6)   # 11
1
print(5 + 6)   # 11
2
Phép nhân
print(5 + 6)   # 11
3
print(5 + 6)   # 11
4
Phân công
print(5 + 6)   # 11
5
print(5 + 6)   # 11
6
Modulo
print(5 + 6)   # 11
7
print(5 + 6)   # 11
8
Quyền lực
print(5 + 6)   # 11
9


Ví dụ 1: Người vận hành số học trong Python

a = 7
b = 2

# addition
print ('Sum: ', a + b)  

# subtraction
print ('Subtraction: ', a - b)   

# multiplication
print ('Multiplication: ', a * b)  

# division
print ('Division: ', a / b) 

# modulo
print ('Modulo: ', a % b)  

# a to the power b
print ('Power: ', a ** b)   

Đầu ra

Sum: 9
Subtraction: 5
Multiplication: 14
Division: 3.5
Modulo: 1
Power: 49

Trong ví dụ trên, chúng tôi đã sử dụng nhiều toán tử số học,

  • Line 1 - Value of c is  31
    Line 2 - Value of c is  52
    Line 3 - Value of c is  1092
    Line 4 - Value of c is  52.0
    Line 5 - Value of c is  2
    Line 6 - Value of c is  2097152
    Line 7 - Value of c is  99864
    
    6 để thêm
    sub = 10 - 5 # 5
    1 và
    sub = 10 - 5 # 5
    2
  • Line 1 - Value of c is  31
    Line 2 - Value of c is  52
    Line 3 - Value of c is  1092
    Line 4 - Value of c is  52.0
    Line 5 - Value of c is  2
    Line 6 - Value of c is  2097152
    Line 7 - Value of c is  99864
    
    7 để trừ
    sub = 10 - 5 # 5
    2 từ
    sub = 10 - 5 # 5
    1
  • print(5 + 6)   # 11
    2 với nhân
    sub = 10 - 5 # 5
    1 và
    sub = 10 - 5 # 5
    2
  • print(5 + 6)   # 11
    4 để chia
    sub = 10 - 5 # 5
    1 cho
    sub = 10 - 5 # 5
    2
  • print(5 + 6)   # 11
    6 để có được phần còn lại
  • print(5 + 6)   # 11
    8 để có được
    sub = 10 - 5 # 5
    1 cho sức mạnh
    sub = 10 - 5 # 5
    2

2. Các nhà khai thác phân công Python

Các toán tử gán được sử dụng để gán các giá trị cho các biến. Ví dụ,

# assign 5 to x 
var x = 5

Ở đây,

a = 7
b = 2

# addition
print ('Sum: ', a + b)  

# subtraction
print ('Subtraction: ', a - b)   

# multiplication
print ('Multiplication: ', a * b)  

# division
print ('Division: ', a / b) 

# modulo
print ('Modulo: ', a % b)  

# a to the power b
print ('Power: ', a ** b)   
6 là một toán tử gán gán
a = 7
b = 2

# addition
print ('Sum: ', a + b)  

# subtraction
print ('Subtraction: ', a - b)   

# multiplication
print ('Multiplication: ', a * b)  

# division
print ('Division: ', a / b) 

# modulo
print ('Modulo: ', a % b)  

# a to the power b
print ('Power: ', a ** b)   
7 cho
a = 7
b = 2

# addition
print ('Sum: ', a + b)  

# subtraction
print ('Subtraction: ', a - b)   

# multiplication
print ('Multiplication: ', a * b)  

# division
print ('Division: ', a / b) 

# modulo
print ('Modulo: ', a % b)  

# a to the power b
print ('Power: ', a ** b)   
8.

Dưới đây là danh sách các toán tử chuyển nhượng khác nhau có sẵn trong Python.

Nhà điều hànhHoạt độngThí dụ
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
6
Phép cộng
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
9
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
7
Phép trừ
print(5 + 6)   # 11
1
print(5 + 6)   # 11
2
Phép nhân
print(5 + 6)   # 11
3
print(5 + 6)   # 11
4
Phân công
print(5 + 6)   # 11
5
print(5 + 6)   # 11
6
Modulo
print(5 + 6)   # 11
7
print(5 + 6)   # 11
8
Quyền lực
print(5 + 6)   # 11
9
Ví dụ 1: Người vận hành số học trong PythonĐầu raTrong ví dụ trên, chúng tôi đã sử dụng nhiều toán tử số học,


Line 1 - Value of c is 31 Line 2 - Value of c is 52 Line 3 - Value of c is 1092 Line 4 - Value of c is 52.0 Line 5 - Value of c is 2 Line 6 - Value of c is 2097152 Line 7 - Value of c is 99864 6 để thêm sub = 10 - 5 # 51 và sub = 10 - 5 # 52

# assign 10 to a
a = 10

# assign 5 to b
b = 5 

# assign the sum of a and b to a
a += b      # a = a + b

print(a)

# Output: 15

Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
7 để trừ
sub = 10 - 5 # 5
2 từ
sub = 10 - 5 # 5
1

print(5 + 6)   # 11
2 với nhân
sub = 10 - 5 # 5
1 và
sub = 10 - 5 # 5
2


print(5 + 6)   # 11
6 để có được phần còn lại

a = 5
b =2

print (a > b)    # True

print(5 + 6)   # 11
8 để có được
sub = 10 - 5 # 5
1 cho sức mạnh
sub = 10 - 5 # 5
2

Nhà điều hànhHoạt độngThí dụ
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
6
Phép cộng
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
9False
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
7
Phép trừ
print(5 + 6)   # 11
1True
print(5 + 6)   # 11
2
Phép nhân
print(5 + 6)   # 11
3False
print(5 + 6)   # 11
4
Phân công
print(5 + 6)   # 11
5True
print(5 + 6)   # 11
6
Modulo
print(5 + 6)   # 11
7False
print(5 + 6)   # 11
8
Quyền lực
print(5 + 6)   # 11
9True

Ví dụ 1: Người vận hành số học trong Python

a = 5

b = 2

# equal to operator
print('a == b =', a == b)

# not equal to operator
print('a != b =', a != b)

# greater than operator
print('a > b =', a > b)

# less than operator
print('a < b =', a < b)

# greater than or equal to operator
print('a >= b =', a >= b)

# less than or equal to operator
print('a <= b =', a <= b)

Đầu ra

Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
0

Trong ví dụ trên, chúng tôi đã sử dụng nhiều toán tử số học, Comparison operators are used in decision-making and loops. We'll discuss more of the comparison operator and decision-making in later tutorials.


Line 1 - Value of c is 31 Line 2 - Value of c is 52 Line 3 - Value of c is 1092 Line 4 - Value of c is 52.0 Line 5 - Value of c is 2 Line 6 - Value of c is 2097152 Line 7 - Value of c is 99864 6 để thêm sub = 10 - 5 # 51 và sub = 10 - 5 # 52

Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
7 để trừ
sub = 10 - 5 # 5
2 từ
sub = 10 - 5 # 5
1

Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
1

print(5 + 6)   # 11
2 với nhân
sub = 10 - 5 # 5
1 và
sub = 10 - 5 # 5
2AND. Since both
a = 5
b =2

print (a > b)    # True
7 and
a = 5
b =2

print (a > b)    # True
8 are
# assign 5 to x 
var x = 5
7, the result is
# assign 5 to x 
var x = 5
7.

Nhà điều hànhThí dụHoạt động
Thí dụ
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
6and b
Phép cộng:
# assign 5 to x 
var x = 5
7 only if both the operands are
# assign 5 to x 
var x = 5
7
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
9
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
7or b
Phép trừ:
# assign 5 to x 
var x = 5
7 if at least one of the operands is
# assign 5 to x 
var x = 5
7
print(5 + 6)   # 11
1
print(5 + 6)   # 11
2
a
Phép nhân:
# assign 5 to x 
var x = 5
7 if the operand is
# assign 5 to x 
var x = 5
8 and vice-versa.


Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
2

print(5 + 6)   # 11
4: Here is the truth table for these logical operators.


Phân công

print(5 + 6)   # 11
5

print(5 + 6)   # 11
62 is
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
00 in binary and 7 is
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
01.

Modulo Let x = 10 (

Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
02 in binary) and y = 4 (
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
03 in binary)

Nhà điều hànhHoạt độngThí dụ
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
6
Phép cộng
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
9
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
7
Phép trừ
print(5 + 6)   # 11
1
print(5 + 6)   # 11
2
Phép nhân
print(5 + 6)   # 11
3
print(5 + 6)   # 11
4
Phân công
print(5 + 6)   # 11
5
print(5 + 6)   # 11
6
Modulo
print(5 + 6)   # 11
7
print(5 + 6)   # 11
8
Quyền lực


Ví dụ 1: Người vận hành số học trong Pythonidentity operator and the membership operator. They are described below with examples.

Đầu ra

Trong ví dụ trên, chúng tôi đã sử dụng nhiều toán tử số học,

Nhà điều hànhHoạt độngThí dụ
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
6
Phép cộng
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
13
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
10
# assign 5 to x 
var x = 5
7 Nếu các toán hạng không giống nhau (không tham khảo cùng một đối tượng)
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
16

Ví dụ 4: Người vận hành danh tính trong Python

Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
3

Ở đây, chúng ta thấy rằng X1 và Y1 là số nguyên của cùng một giá trị, vì vậy chúng bằng nhau cũng như giống hệt nhau. Tương tự là trường hợp với x2 và y2 (chuỗi).

Nhưng x3 và y3 là danh sách. Họ bằng nhau nhưng không giống nhau. Đó là bởi vì trình thông dịch định vị chúng riêng biệt trong bộ nhớ mặc dù chúng bằng nhau.


Các nhà khai thác thành viên

Trong Python,

Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
17 và
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
18 là các nhà khai thác thành viên. Chúng được sử dụng để kiểm tra xem một giá trị hoặc biến được tìm thấy trong một chuỗi (chuỗi, danh sách, tuple, bộ và từ điển).

Trong một từ điển, chúng ta chỉ có thể kiểm tra sự hiện diện của khóa, không phải giá trị.

Nhà điều hànhNghĩaThí dụ
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
17
# assign 5 to x 
var x = 5
7 Nếu giá trị/biến được tìm thấy trong chuỗifound in the sequence
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
21
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
18
# assign 5 to x 
var x = 5
7 Nếu giá trị/biến không được tìm thấy trong chuỗinot found in the sequence
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
24

Ví dụ 5: Các nhà khai thác thành viên trong Python

Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
4

Đầu ra

Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
5

Ở đây,

Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
25 nằm trong x nhưng
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
26 không có trong X (hãy nhớ, Python là trường hợp nhạy cảm).

Tương tự,

Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
27 là chìa khóa và
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
28 là giá trị trong từ điển y. Do đó,
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864
29 trả về
# assign 5 to x 
var x = 5
8.

Các toán tử chuyển nhượng trong Python là gì?

Sau đây là các loại toán tử phân công khác nhau trong Python:..
Toán tử gán đơn giản (=).
Thêm và toán tử bằng ( +=).
Trừ và toán tử bằng ( -=).
Dấu hoa thị và toán tử bằng nhau ( *=).
Chia và toán tử bằng ( /=).
Mô đun và toán tử bằng nhau ( %=).
Phân chia kép và toán tử bằng nhau (// =).

3 toán tử trong Python là gì?

Python chia các toán tử trong các nhóm sau: toán tử số học. Toán tử chuyển nhượng. Toán tử so sánh.Arithmetic operators. Assignment operators. Comparison operators.

6 toán tử gán là gì?

Các loại toán tử chuyển nhượng trong C..
Bài tập cơ bản (=).
Bài tập trừ ( -=).
Bổ sung gán ( +=).
Phân chia phân công ( /=).
Bài tập nhân ( *=).
gán modulo ( %=).
BitWise XOR gán ( ^=).
bitwise hoặc gán (| =).

Toán tử gán và loại của nó là gì?

Có hai loại hoạt động gán: gán đơn giản, trong đó giá trị của toán hạng thứ hai được lưu trữ trong đối tượng được chỉ định bởi toán hạng đầu tiên.Việc gán hợp chất, trong đó hoạt động số học, dịch chuyển hoặc bitwise được thực hiện trước khi lưu trữ kết quả.

Các toán tử chuyển nhượng là gì?

Toán tử gán = gán giá trị của toán hạng bên phải của nó cho một biến, thuộc tính hoặc phần tử chỉ mục được đưa ra bởi toán hạng bên trái của nó.Kết quả của một biểu thức gán là giá trị được gán cho toán hạng bên trái.assigns the value of its right-hand operand to a variable, a property, or an indexer element given by its left-hand operand. The result of an assignment expression is the value assigned to the left-hand operand.