# 주석1
'''주석2'''

a = 10
b = 5
c = 'Hi My Name is \'Seungyub Lee\'\nNice to meet you!'
d = "Hava a nice day"
e = "abcdefghijklmnop"

print(a/b) # 2.0
print(a//b) # 2
print(type(a)) # <class 'int'>
print(c + d) # Hi My Name is 'Seungyub Lee'
             # Nice to meet you!Hava a nice day
print(type(c)) # <class 'str'>
print(c[0:7]) # Hi My N
print(e[0:5:2]) # ace
print(c[:8]) # Hi My Na
print(e[::-1]) # ponmlkjihgfedcba

f = "I ate %d apples. %s" % (a, d)

print(f) # I ate 10 apples. Hava a nice day

g = "Hi {name} How old are you? I'm {age} years old" .format(name="Roy", age=30)

print(g) # Hi Roy How old are you? I'm 30 years old

h = "Roy"
i = f"My name is {h}"

print(i) # My name is Roy

j = "%0.4f" % 3.141592

print(j) # 3.1416

k = "hobby"

print(k.count('b')) # 2
print(k.find('b')) # 2
print(k.find('x')) # -1

l = ','

print(l.join('abcd')) # a,b,c,d

m = "Lionel Messi"

print(m.upper()) # LIONEL MESSI
print(m.lower()) # lionel messi

n = "  Hi   "

print(n.strip()) # Hi

o = "Life is too short"

print(o.replace("Life", "Your hair")) # Your hair is too short
print(o.split()) # ['Life', 'is', 'too', 'short']

p = ["ABC", "DEF", "GHI", "JKL"]

print(p) # ['ABC', 'DEF', 'GHI', 'JKL']
print(p[1]) # DEF
print(p[3]) # JKL
print(p[-1]) # JKL

p[0] = "CBA"

print(p) # ['CBA', 'DEF', 'GHI', 'JKL']

p[0:2] = ["DEF", "ABC"]

print(p) # ['DEF', 'ABC', 'GHI', 'JKL']

q = ["ABC", "DEF", "GHI", ["JKL","MNO"]]

print(q) # ['ABC', 'DEF', 'GHI', ['JKL', 'MNO']]
print(q[3]) # ['JKL', 'MNO']
print(q[3][0]) # JKL
print(q[0:2]) # ['ABC', 'DEF']
print(p + q) # ['DEF', 'ABC', 'GHI', 'JKL', 'ABC', 'DEF', 'GHI', ['JKL', 'MNO']]

q[2:4] = []

print(q) # ['ABC', 'DEF']

del q[0]

print(q) # ['DEF']

q.append('GHI')

print(q) # ['DEF', 'GHI']

q.reverse()

print(q) # ['GHI', 'DEF']

q.sort()

print(q) # ['DEF', 'GHI']

q.insert(0, 'ABC')

print(q) # ['ABC', 'DEF', 'GHI']

q.remove('DEF')

print(q) # ['ABC', 'GHI']

r = [1, 2, 1, 3, 5, 2, 1]

r.remove(1)

print(r) # [2, 1, 3, 5, 2, 1]

print(r.pop()) # 1

print(r) # [2, 1, 3, 5, 2]

print(r.count(2)) # 2

r.extend([6, 7])

print(r) # [2, 1, 3, 5, 2, 6, 7]

+ Recent posts