1. ๋ค์๊ณผ ๊ฐ์ด ์ฝ๋๋ฅผ ์์ฑํ์ ๋, ์คํ ๊ฒฐ๊ณผ๋ฅผ ์์ฑํ์์ค.
a = "H-e-l-l-o-P-y-t-h-o-n"
print(a[::3])
2. ๋ค์๊ณผ ๊ฐ์ด ์ฝ๋๋ฅผ ์์ฑํ์ ๋, ์คํ ๊ฒฐ๊ณผ๋ก ์๋ง์ ๊ฒ์?
value_l = "5"
value_2 = "5 - 2 - 10 - 10".split("-")[-1]
print(int(value_l)) * 3 + float(value_2)
- 5.0
- 10.0
- ์๋ฌ ๋ฐ์
- 15.0
- 25.0
-> ๋ต : 3. ์๋ฌ ๋ฐ์
3. ๋ค์๊ณผ ๊ฐ์ ์ฝ๋ ์์ฑ์, ๋น ์นธ a, b์ ์๋ง์ ์ฝ๋๋ฅผ ๊ฐ๊ฐ ์์ฑํ์์ค.
sentence = "Hello, my name is python?!"
print(sentence[0]+sentence[ a ]+sentence[ b ])
#์คํ ๊ฒฐ๊ณผ : H,y n
-> ๋ต : a) 5:10:3, b) -9:-2:6
4. ๋ค์๊ณผ ๊ฐ์ด ์ฝ๋๋ฅผ ์์ฑํ์ ๋, ์คํ๊ฒฐ๊ณผ๋ฅผ ์์ฑํ์์ค.
first_word = "Python"
second_word = "Language"
print((first_word + second_word).capitalize())
print(first_word.find("p"))
print(second_word.isdigit())
5. sentence ๋ฌธ์์ด์ ์ฌ์ฉํ์ฌ ๋ค์ํ ํํ๋ก ์๋ก์ด ๋ฌธ์์ด์ ์์ฑํ์๋ค. ์ด ์ค ๊ธฐ์กด ๋ฌธ์์ด sentence์ ๊ฒฐ๊ณผ๊ฐ์ด ๊ฐ์ ๊ฒ์ ๋ฌด์์ธ๊ฐ?
sentence = "Life Is Short You Need Python"
a = sentence[-15:20]
b = sentence.lower()
c = sentence[:28]
d = sentence[0:]
e = sentence[:-1]
-> ๋ต : d
6. ๋ค์ ์ฝ๋๋ฅผ ์คํํ์ฌ ์๋์ ๊ฐ์ ์คํ ๊ฒฐ๊ณผ๋ฅผ ์ถ๋ ฅํ๋ ค ํ๋ค. ๋น ์นธ์ ์๋ง์ ์ฝ๋๋ฅผ ๊ณ ๋ฅด์์ค.
word = "word"
print(f"|{word:______10}|")
print(f"|{word:______10}|")
print(f"|{word:______10}|")
# ์คํ ๊ฒฐ๊ณผ
|word |
| word |
| word|
-> ๋ต : <, ^, >
7. ๋ค์๊ณผ ๊ฐ์ด ์ฝ๋๋ฅผ ์์ฑํ์ ๋, ์คํ ๊ฒฐ๊ณผ๋ฅผ ์์ฑํ์์ค.
name = "Hanbit"
a = name.find("H")
b = name.count("H") * 8
c = len(name) * 2 + 3
print("REMEMBER", str(a) + str(b) + str(c))
8. ๋ฌธ์์ด์ ์ ๋ ฅํ๋ฉด ๋ฌธ์์ด์ ์ฒซ ๊ธ์์ ๋ง์ง๋ง ๊ธ์๋ฅผ ์ถ๋ ฅํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ์์ค. (๋จ, ํ๋ก๊ทธ๋จ์ ์ฒซ ์ค์ ๋ฐ๋ณต ํ์๋ฅผ ์ ๋ ฅ๋ฐ์, ๋ฐ์ ํ์๋งํผ ๋ฐ๋ณต ์คํ๋๋๋ก ์์ฑํ ๊ฒ.)
trial = int(input("ํ
์คํธ ํ์ ์ค์ : "))
for i in range(trial):
sentence = input()
print(sentence[0]+sentence[-1])
'๐ ์คํฐ๋ > ํ์ด์ฌ ์คํฐ๋ ๊ณผ์ ์ ์ถ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[1ํ/์ด๋์ฐ] 6์ฃผ์ฐจ ํ์ด์ฌ ๊ณผ์ - ๋ฌธ์์ด (0) | 2023.05.09 |
---|---|
[1ํ/๊น์ํ]6์ฐจ์ ํ์ด์ฌ ๊ณผ์ - ๋ฌธ์์ด (0) | 2023.05.09 |
[4ํ/๊น์ค] 5์ฐจ์ ํ์ด์ฌ ๊ณผ์ - ํจ์ (0) | 2023.05.09 |
[2ํ/์ค์ํ] 6์ฐจ์ ํ์ด์ฌ ๊ณผ์ - ๋ฌธ์์ด (0) | 2023.05.07 |
[4ํ / ๊น์ ๊ฒฝ] 5์ฐจ์ ํ์ด์ฌ ๊ณผ์ - ํจ์ํ (0) | 2023.04.13 |