2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
"""
Python Introduction
Python comments
# Single line comment: #
# Multi-line comment: ''' r """"""
Python output and input
# print: Output
# input: Input ① will pause the program, ② will get the string content int("100")
Python variables
# Define variable: age = 18
# a, b = 3, 4
# x = y = z = 1
# Swap the values of variables:
# a, b = b, a
# Variable naming conventions:
# Keyword: keyword.kwlist, 35 in total
# Delete a variable: del a
"""
print(100)
print(100, 'hello', sep='=', end='ok') # n means line break
print(200)
name = input('Please enter your name:')
print(name)
'''
while True:
name = input('Please enter your name:')
print(name)
'''
'''
# Expand (Understand)
a = 6
b = 8
# Swap the values of two variables
'''
# a, b = b, a
# print(a, b) # 8 6
'''
# other methods
'''
a = 6
b = 8
c = a # a=6,b=8,c=6
a = b # a=8,b=8,c=6
b = c # a=8,b=6,c=6
print(a, b)
'''
# No need for the third variable c
'''
a = a + b # a=8+6 , b=8
b = a - b # a=8+6 , b=6
a = a - b # a=8 , b=6
print(a, b)
'''
Bitwise Operators
# ^ : Bitwise XOR: Different is 1, Same is 0
a = 6
b = 8
a = a ^ b
b = a ^ b
a = a ^ b
Bitwise Operations
# Decimal Binary 0 1
# a= 6 0110
# b= 8 1000
# 8421 Law
# Binary: 1 1 1 1
# Decimal: 8 4 2 1
# a = a ^ b XOR: same is 0, different is 1
# a= 6 0110
# b= 8 1000
# ---------------
# a=a^b=14 1110
# b = a ^ b
# a= 14 1110
# b= 8 1000
# ---------------
# b=a^b=6 0110
# a = a ^ b
# a= 14 1110
# b= 6 0110
# ---------------
# a=a^b=8 1000
print(a, b) # 8 6
'''