Python Syntax
a=float(input()) print("{:.6f}".format(a))a=[1,2,3] a.reverse() print(a) => [3,2,1]print('!'.join(word)) ###join μμ μ°κ²°κ³ 리λ₯Ό κΈ°μ ν΄μ€ print(' '.join(word))a,b,c = input().split('.') print("{:0>4}.{:0>2}.{:0>2}".format(a,b,c))value = 60 b = bin(value) = "0b~" o = oct(value) = "0o~" h = hex(value) = "0x~" b = "{:#b}".format(value) o = "{:#o}".format(value) h = "{:#h}".format(value) value = int("0o13",8) = 11 value = int("0b11",2) = 3 value = int("0xf",16) = 15a = oct(int(input()) # a = '0o12' print(a.lstrip('0o')print(chr(45)) print(ord("A"))λΉνΈ μ°μ°μ (Bitwise Operators): a = 60, b = 13 μ΄λΌ κ°μ νλ€. a = 0011 1100 b = 0000 1101 Operator Description Example & AND μ°μ°. λλ€ μ°ΈμΌλλ§ λ§μ‘± (a & b) = 12 β 0000 1100 | OR μ°μ°. λ μ€ νλλ§ μ°Έμ΄μ¬λ λ§μ‘± (a | b) = 61 β 0011 1101 ^ XOR μ°μ°. λ μ€ νλλ§ μ°ΈμΌ λ λ§μ‘± (a ^ b) = 49 β 0011 0001 ~ 보μ μ°μ°. (~a) = -61 β 1100 0011 << μΌμͺ½ μννΈ μ°μ°μ. λ³μμ κ°μ μΌμͺ½μΌλ‘ μ§μ λ λΉνΈ μ λ§νΌ μ΄λ a << 2 = 240 β 1111 0000 >> μ€λ₯Έμͺ½ μννΈ μ°μ°μ. λ³μμ κ°μ μ€λ₯Έμͺ½μΌλ‘ μ§μ λ λΉνΈ μ λ§νΌ μ΄λ a >> 2 = 15 β 0000 1111array = [i for i in range(20) if i % 2 == 1 ] array = [i * i for i in range(1,10)]a = [1,2,3,4,5,5,5] remove_set = {3,5} result = [i for i in a if not in remove_set] print(result) [1,2,4]
Last updated